forked from rohit/spurrin-backend
Forking for research
| __pycache__ | ||
| certificates | ||
| docs | ||
| llm-uploads | ||
| logs | ||
| public/images | ||
| scripts | ||
| src | ||
| tests | ||
| uploads | ||
| .DS_Store | ||
| .env.example | ||
| .gitignore | ||
| certificates.zip | ||
| CHANGES.md | ||
| chat copy 2.py | ||
| chat copy 3.py | ||
| chat copy 4.py | ||
| chat copy 5.py | ||
| chat copy.py | ||
| chat.py | ||
| error.log | ||
| Jenkinsfile | ||
| model_manager.py | ||
| nodemon.json | ||
| package-lock.json | ||
| package.json | ||
| readme.md | ||
| requirements.txt | ||
| spurrin_testing_code.py | ||
SpurrinAI Backend
A Node.js backend application for SpurrinAI platform.
Project Structure
project-root/
├── src/ # Source code
│ ├── app.js # App entry point
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Custom middleware
│ ├── migrations/ # Database migrations
│ ├── routes/ # Route definitions
│ ├── services/ # Business logic
│ └── utils/ # Utility functions
├── docs/ # Documentation
├── logs/ # Application logs
├── scripts/ # Build and setup scripts
├── tests/ # Test files
└── uploads/ # User uploads
Prerequisites
- Node.js >= 14.0.0
- MySQL >= 5.7
- npm >= 6.0.0
Installation
- Clone the repository:
git clone -b dev https://git.tech4biz.wiki/Tech4Biz-Services/spurrin-cleaned-node.git
cd spurrinai-backend
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Run the setup script:
npm run setup
Development Mode
- Start the development server with hot-reload:
npm run dev
- Run tests:
# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests only
npm run test:integration
- Code Quality:
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format
Production Mode
- Build the application:
npm run build
- Start the production server:
npm start
- For production deployment, ensure:
- Set
NODE_ENV=productionin.env - Configure proper database credentials
- Set up SSL/TLS certificates
- Configure proper logging
- Set up process manager (PM2 recommended)
- Set
Using PM2 (Recommended for Production)
- Install PM2 globally:
npm install -g pm2
- Start the application with PM2:
pm2 start src/app.js --name spurrinai-backend
- Other useful PM2 commands:
# Monitor application
pm2 monit
# View logs
pm2 logs spurrinai-backend
# Restart application
pm2 restart spurrinai-backend
# Stop application
pm2 stop spurrinai-backend
# Flush logs
pm2 flush
# Delete all logs
pm2 flush spurrinai-backend
# Reload application with zero downtime
pm2 reload spurrinai-backend
Database Migrations
# Create new migration
npm run migrate:create
# Run all migrations
npm run migrate
# Run migrations up
npm run migrate:up
# Run migrations down
npm run migrate:down
API Documentation
Detailed API documentation can be found in the docs/API.md file.
Environment Variables
Required environment variables in .env:
# Server Configuration
PORT=3000
NODE_ENV=development
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=spurrinai
DB_USER=postgres
DB_PASSWORD=your_password
# JWT Configuration
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=24h
# Email Configuration
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_app_password
# File Upload Configuration
UPLOAD_DIR=uploads
MAX_FILE_SIZE=5242880 # 5MB
Support
For support, please contact:
- Email: contact@tech4biz.io
- Issue Tracker: GitHub Issues
License
UNLICENSED - All rights reserved by Tech4biz Solutions