Deployment
Production deployment guide for the SLMS frontend and backend — Vercel configuration, environment variables, and deployment architecture.
Deployment
Both the frontend and backend are configured for deployment on Vercel as serverless functions. Each application has its own vercel.json configuration file.
Architecture
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ Frontend (Vercel) │ │ Backend (Vercel) │
│ Next.js 16 App │────▶│ Express.js Serverless │
│ slms.anandverse.qzz.io │ │ api.slms.anandverse.qzz.io │
└──────────────────────────────┘ └──────────┬───────────────────┘
│
▼
┌──────────────────────────────┐
│ MongoDB Atlas (Cloud) │
└──────────────────────────────┘Live URLs:
- Frontend: https://slms.anandverse.qzz.io/
- Backend API: https://api.slms.anandverse.qzz.io/
- Documentation: https://docs.slms.anandverse.qzz.io/docs
Backend Deployment
Vercel Configuration
File: backend/vercel.json
{
"version": 2,
"builds": [
{
"src": "server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/server.js"
}
]
}Key details:
- Uses
@vercel/nodebuilder to runserver.jsas a serverless function - All incoming requests are routed to the Express app via the catch-all route
- The server conditionally listens only in non-production (
process.env.NODE_ENV !== 'production'), since Vercel handles routing
Backend Environment Variables
Set these in the Vercel dashboard under Settings → Environment Variables:
| Variable | Required | Description |
|---|---|---|
DATABASE_URL | ✅ | MongoDB Atlas connection string |
AUTH_SECRET or JWT_SECRET | ✅ | Secret key for JWT signing |
NODE_ENV | ✅ | Set to production |
SMTP_HOST | — | SMTP server hostname (default: smtp.gmail.com) |
SMTP_PORT | — | SMTP port (default: 587) |
SMTP_USER | — | SMTP username/email |
SMTP_PASS | — | SMTP password or app password |
Frontend Deployment
Vercel Configuration
File: frontend/vercel.json
{
"framework": "nextjs"
}Next.js is auto-detected by Vercel. No additional build configuration is needed.
Frontend Environment Variables
Set these in the Vercel dashboard:
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_API_URL | ✅ | Full URL to the deployed backend (e.g., https://slms-backend.vercel.app/api/v1) |
AUTH_SECRET | ✅ | NextAuth.js secret for session encryption |
MONGODB_URI | ✅ | MongoDB connection string (used by NextAuth for the setup flow) |
NEXTAUTH_URL | ✅ | Canonical URL of the frontend (e.g., https://slms.vercel.app) |
Deployment Checklist
Pre-Deployment
- Ensure MongoDB Atlas cluster is provisioned and connection string is ready
- Set all required environment variables in Vercel
- Verify CORS is configured to allow the frontend origin on the backend
- Test the health check endpoint after deploying the backend
Post-Deployment Verification
-
Backend Health Check:
curl https://your-backend.vercel.app/health # Expected: { "status": "ok", "message": "SLMS API is running" } -
Frontend Smoke Test:
- Navigate to the deployed frontend URL
- Verify the login page loads
- Test login with admin credentials
- Confirm role-based redirect works
Local Development vs Production
| Aspect | Local | Production |
|---|---|---|
| Backend URL | http://localhost:5000/api/v1 | https://api.slms.anandverse.qzz.io/api/v1 |
| Frontend URL | http://localhost:3000 | https://slms.anandverse.qzz.io |
| Docs URL | http://localhost:3000/docs | https://docs.slms.anandverse.qzz.io/docs |
| Server Listening | app.listen() runs | Vercel handles routing |
| HTTPS | Not enforced | Enforced via src/app.js middleware |
| Rate Limiting | Active | Active (15-min window, 100 req/IP) |
Important Notes
-
Cron Jobs: Vercel serverless functions do not natively support persistent cron jobs. The fine calculator cron job (
node-cron) starts when thesrc/app.jsmodule is loaded but may not run reliably in a cold-start serverless environment. Consider using Vercel Cron Jobs or an external scheduler for production. -
Cold Starts: Serverless functions may have cold start delays. The MongoDB connection is cached across invocations within the same function instance.
-
File Uploads: The current deployment does not include file upload handling. Cover images referenced in the Book model use external URLs.