npm install# Copy .env.example to .env
cp .env.example .env
# Edit .env and set:
# - MONGODB_URI (local or Atlas)
# - JWT_SECRET (any random string, 32+ chars)# Local MongoDB
mongod
# Or use MongoDB Atlas (cloud)
# Just update MONGODB_URI in .envnpm run seed
# Creates: admin@smg.com / admin123npm run dev# Test Chat API
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{"userMessage": "Hello"}'
# Test Admin Login
curl -X POST http://localhost:3000/api/admin/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@smg.com", "password": "admin123"}'| Endpoint | Method | Auth | Description |
|---|---|---|---|
/api/chat |
POST | Public | Process chat message |
/api/leads |
POST | Public | Create lead |
/api/programs |
GET | Public | Get programs info |
/api/admin/login |
POST | Public | Admin login |
/api/admin/conversations |
GET | Admin | Get conversations |
/api/admin/leads |
GET | Admin | Get leads |
/api/admin/analytics |
GET | Admin | Get analytics |
POST /api/chat
{
"userMessage": "Tell me about internships"
}POST /api/leads
{
"name": "John Doe",
"phone": "9876543210",
"email": "john@example.com",
"interest": "internship",
"city": "Mumbai"
}GET /api/admin/conversations?intent=products&page=1&limit=20
Headers: Authorization: Bearer <token>GET /api/admin/analytics?startDate=2024-01-01&endDate=2024-01-31
Headers: Authorization: Bearer <token>After running npm run seed:
- Email: admin@smg.com
- Password: admin123
src/
├── config/ # Database & JWT config
├── controllers/ # Request handlers
├── models/ # MongoDB schemas
├── routes/ # API routes
├── services/ # Business logic
├── middlewares/ # Auth & error handling
└── utils/ # Helper functions
- Check if MongoDB is running
- Verify MONGODB_URI in .env
- Check network/firewall settings
- Verify JWT_SECRET is set in .env
- Check token format:
Bearer <token> - Ensure token hasn't expired
- Change PORT in .env
- Or kill process using port 3000
- Read API_DOCUMENTATION.md for detailed API reference
- Review README.md for complete setup guide
- Customize chatbot intents in
src/services/chatbotService.js - Add more admin features as needed
- Use Postman/Insomnia for API testing
- Check MongoDB Compass to view data
- Enable MongoDB logging for debugging
- Use environment-specific .env files