Global Expansion Management API built with NestJS, MySQL, and MongoDB.
- Node.js 18+
- MySQL 8.0+
- Redis (optional for local dev)
- MongoDB Atlas account
- Brevo SMTP account
- Clone the repository
- Copy
.env.exampleto.envand update all values - NEVER commit your .env file!
- users: Authentication and authorization
- clients: Company information
- projects: Expansion projects with country and services
- vendors: Service providers with ratings and SLAs
- matches: Calculated matches between projects and vendors
- researchdocuments: Unstructured documents linked to projects
Base URL: http://localhost:3000
Swagger Docs: http://localhost:3000/api
POST /auth/register- Register new userPOST /auth/login- Login (returns JWT token)
GET /projects- List all projectsPOST /projects- Create new project (Client only)GET /projects/:id- Get project detailsPATCH /projects/:id- Update project (Client only)DELETE /projects/:id- Delete project (Client only)
GET /vendors- List all vendorsPOST /vendors- Create vendor (Admin only)GET /vendors/:id- Get vendor detailsPATCH /vendors/:id- Update vendor (Admin only)DELETE /vendors/:id- Delete vendor (Admin only)
POST /projects/:projectId/matches/rebuild- Rebuild matches for a projectGET /projects/:projectId/matches- Get matches for a project
POST /documents- Upload research documentGET /documents/project/:projectId- Get documents by projectPOST /documents/search- Search documents
GET /analytics/top-vendors- Top vendors per country with document countsGET /analytics/expired-slas- Vendors with expired SLAs
Score = (Services Overlap × 2) + Vendor Rating + SLA Weight
- Services Overlap: Number of matching services between project and vendor
- SLA Weight: 5 - (Response Hours / 24), capped at 0 minimum
- Vendors must support the project country
- Daily at Midnight: Refresh matches for all active projects
- Weekly: Check and notify about expired SLAs (>72 hours)
# Install dependencies
npm install
# Start the application
npm run start:dev
# Run tests
npm run test
# Run tests with coverage
npm run test:cov
# Run e2e tests
npm run test:e2eThought Process
Installation steps
Database setup/migrations
Testing details
Deployment instructions
API Examples
Contributing guidelines
License
Troubleshooting
npm run test:cov
npm run test:e2e
git clone https://github.com/yourusername/expanders360-api.git
cd expanders360-api
npm install
cp .env.example .env
npm run migration:run
npm run seed:run
npm run start:dev
npm run migration:generate -- -n YourMigrationName
npm run migration:run
npm run migration:revert
API Examples Register a new client
curl -X POST http://localhost:3000/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "securepassword123",
"role": "client",
"companyName": "Tech Corp"
}'
Login and get JWT token
curl -X POST http://localhost:3000/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "securepassword123"
}'
Create a new project (with JWT token)
curl -X POST http://localhost:3000/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"name": "US Market Expansion",
"country": "United States",
"services": ["Legal", "Accounting", "Marketing"],
"timeline": "Q2 2024",
"budget": 100000
}'
Vercel Deployment
npm i -g vercel
vercel --prod
Required Environment Variables
Set these in your production environment:
# Application
NODE_ENV=production
PORT=3000
# JWT
JWT_SECRET=your-super-secret-jwt-key
JWT_EXPIRATION=7d
# MySQL Database
MYSQL_HOST=your-mysql-host
MYSQL_PORT=3306
MYSQL_USERNAME=your-username
MYSQL_PASSWORD=your-password
MYSQL_DATABASE=your-database
DATABASE_SSL=true
# MongoDB
MONGODB_URI=mongodb+srv://username:[email protected]/dbname
# Email (Brevo SMTP)
SMTP_HOST=smtp-relay.brevo.com
SMTP_PORT=587
SMTP_USER=your-smtp-user
SMTP_PASSWORD=your-smtp-password
[email protected]
Docker Support
docker-compose up -d
docker-compose logs -f app
docker-compose down
Project Structure
.
├── src/
│ ├── auth/ # JWT authentication
│ ├── users/ # User management
│ ├── clients/ # Client companies
│ ├── projects/ # Expansion projects
│ ├── vendors/ # Service vendors
│ ├── matches/ # Matching algorithm
│ ├── documents/ # MongoDB documents
│ ├── analytics/ # Analytics & reporting
│ ├── notifications/ # Email notifications
│ ├── scheduler/ # Cron jobs
│ ├── database/ # Migrations & seeds
│ └── config/ # Configuration
├── test/ # Test files
├── api/ # Vercel serverless functions
└── dist/ # Compiled output
Default Users
After running seeds, these users are available:
Admin: [email protected] / admin123
Client 1: [email protected] / client123
Client 2: [email protected] / client123
Troubleshooting Common Issues
Database Connection Failed
Check your MySQL/MongoDB credentials in .env
Ensure database services are running
For production, ensure SSL is properly configured
JWT Authentication Errors
Ensure JWT_SECRET is set in environment
Check token format: Bearer <token>
Verify token hasn't expired
Build Errors on Vercel
Ensure all environment variables are set in Vercel dashboard
Check build logs for missing dependencies
Verify vercel.json configuration
CORS Issues
CORS is enabled for all origins in development
Configure specific origins for production in main.ts
Contributing
Fork the repository
Create your feature branch (git checkout -b feature/AmazingFeature)
Commit your changes (git commit -m 'Add some AmazingFeature')
Push to the branch (git push origin feature/AmazingFeature)
Open a Pull Request
License
This project is licensed under the UNLICENSED License - see the LICENSE file for details.
Support
For support, email [email protected] or open an issue in the GitHub repository.