- GitHub repository with the Qmart backend code
- Render account
- MongoDB Atlas database (or other MongoDB instance)
- Environment variables configured
In your Render dashboard, set the following environment variables:
Required:
NODE_ENV=production
PORT=10000
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/qmart-prod
JWT_SECRET=your-super-secure-jwt-secret-key
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
Optional but Recommended:
CORS_ORIGIN=https://your-frontend-domain.com
RATE_LIMIT_MAX=100
AUTH_RATE_LIMIT_MAX=5
BCRYPT_ROUNDS=12
Option A: Using render.yaml (Recommended)
- Ensure
render.yamlis in your repository root - Connect your GitHub repository to Render
- Render will automatically use the configuration from
render.yaml
Option B: Manual Configuration
- Create a new Web Service on Render
- Connect your GitHub repository
- Configure the following settings:
- Build Command:
npm install && npm run build:render - Start Command:
npm run start:prod - Environment: Node
- Node Version: 18 or higher
- Build Command:
After deployment, check these endpoints:
- Health Check:
https://your-app.onrender.com/health - API Info:
https://your-app.onrender.com/api - Documentation:
https://your-app.onrender.com/api/docs
The deployment uses a robust build process:
- Install Dependencies:
npm install - TypeScript Compilation:
tsc - Post-Build Tasks: Copy Swagger files and verify build
- Verification: Ensure all critical files exist
1. Module Resolution Errors
- ✅ Fixed: Updated tsconfig.json with proper module resolution
- ✅ Fixed: Simplified build process to avoid path issues
2. Missing Files
- ✅ Fixed: Post-build script copies all necessary files
- ✅ Fixed: Verification step ensures critical files exist
3. Database Connection Issues
- Check MongoDB URI format
- Ensure database user has proper permissions
- Verify network access from Render
4. Environment Variable Issues
- Double-check all required environment variables are set
- Ensure no typos in variable names
- Check that sensitive values are properly escaped
For Production:
- Enable MongoDB connection pooling
- Configure proper rate limiting
- Set up monitoring with Prometheus metrics
- Use CDN for static assets if needed
The application includes built-in monitoring:
- Health Check:
/health - Metrics:
/metrics(Prometheus format) - API Status:
/api
Production security features:
- Rate limiting on all endpoints
- Helmet.js security headers
- CORS configuration
- JWT token authentication
- Bcrypt password hashing
- Input validation with Zod schemas
For high-traffic scenarios:
- Upgrade Render plan
- Implement Redis for session storage
- Use MongoDB Atlas clusters
- Consider microservices architecture
# Install dependencies
npm install
# Copy environment file
cp .env.example .env
# Start development server
npm run dev# Test production build locally
npm run build:render
npm run start:prodnpm run dev- Development server with hot reloadnpm run build- Production buildnpm run build:render- Render-specific build with verificationnpm run start- Start production servernpm run start:prod- Start with NODE_ENV=productionnpm test- Run testsnpm run lint- Code linting
After deployment, access the comprehensive API documentation:
- Main Hub:
/api/docs - Customer API:
/api/docs/customers - Merchant API:
/api/docs/merchants - Admin API:
/api/docs/admin
If you encounter deployment issues:
- Check Render build logs
- Verify environment variables
- Test the build process locally
- Check database connectivity
- Review the troubleshooting section above