Deployment Setup Guide¶
Step-by-step instructions for deploying MessWala to production.
📋 Prerequisites¶
Before starting, ensure you have:
- ✅ GitHub account with repository access
- ✅ MongoDB Atlas account (free tier available)
- ✅ Render account (for backend)
- ✅ Vercel account (for frontend)
- ✅ Google OAuth credentials
- ✅ reCAPTCHA v3 keys
Phase 1: Database Setup (MongoDB Atlas)¶
Step 1: Create MongoDB Atlas Account¶
- Go to mongodb.com/atlas
- Click "Try Free"
- Create account with email/GitHub
- Verify email
Step 2: Create Cluster¶
- Click "Create a Deployment"
- Choose "Free" tier (M0 Sandbox)
- Select cloud provider (AWS/GCP/Azure)
- Select region closest to you
- Click "Create Deployment"
- Wait 5-10 minutes for cluster creation
Step 3: Create Database User¶
- Go to "Database Access"
- Click "Add New Database User"
- Choose "Autogenerated Secure Password"
- Copy the username (usually
dbuser) - Copy the password securely
- Role: "Read and write to any database"
- Click "Add User"
Step 4: Configure Network Access¶
- Go to "Network Access"
- Click "Add IP Address"
- Select "Allow access from anywhere"
- CIDR:
0.0.0.0/0 - Click "Confirm"
⚠️ For production: Whitelist specific IPs instead
Step 5: Get Connection String¶
- Click "Databases" → "Connect"
- Choose "Drivers" (not Compass)
- Select "Node.js" and version "4.x or later"
- Copy connection string from MongoDB Atlas Example format (with placeholders):
mongodb+srv://<USERNAME>:<PASSWORD>@<CLUSTER>.mongodb.net/<DATABASE>?retryWrites=true&w=majority - Store in environment-only (
.envfile or platform secrets): - DO NOT paste actual credentials in code
- Use:
MONGO_URI=<your-actual-connection-string> - CRITICAL: Never commit any credentials or connection strings to git
Phase 2: Backend Deployment (Render)¶
Step 1: Prepare Backend¶
- Ensure
backend/folder has: package.jsonserver.js-
src/directory with code -
Create
.gitignore(if not exists):node_modules/ .env *.log .DS_Store -
Commit to GitHub:
git add backend/ git commit -m "Backend ready for deployment" git push origin main
Step 2: Create Render Service¶
- Go to render.com
- Click "New" → "Web Service"
- Connect your GitHub account
- Select
MessWalarepository - Fill in:
- Name:
messwala - Root Directory:
backend - Runtime: Node
- Build Command:
npm install - Start Command:
node server.js - Instance Type: Free
Step 3: Set Environment Variables¶
- Click "Environment"
- Add each variable:
| Variable | Value |
|---|---|
MONGO_URI | Your MongoDB connection string |
JWT_SECRET | Random 32+ char string (use this) |
NODE_ENV | production |
GOOGLE_CLIENT_ID | From Google OAuth setup |
RECAPTCHA_SECRET | From reCAPTCHA setup |
SMTP_EMAIL | Your email (for OTP) |
SMTP_PASSWORD | Gmail app password (not your password) |
- Click "Save Changes"
Step 4: Deploy¶
- Render automatically deploys
- Wait for build to complete (~2-3 min)
- You'll get a URL like:
https://messwala-xxxx.onrender.com - Note this URL for frontend setup
Step 5: Verify Deployment¶
- Open your Render URL in browser
- Navigate to
/api/health - You should see:
{ "status": "ok", "dbState": 1 }
Phase 3: Frontend Deployment (Vercel)¶
Step 1: Prepare Frontend¶
- Ensure
frontend/folder has: package.jsonvite.config.js-
src/directory -
Commit to GitHub:
git add frontend/ git commit -m "Frontend ready for deployment" git push origin main
Step 2: Create Vercel Project¶
- Go to vercel.com
- Click "Add New" → "Project"
- Import your
MessWalarepository - Configure:
- Framework Preset: Vite
- Root Directory:
frontend
Step 3: Set Environment Variables¶
- In Vercel project settings
- Go to "Environment Variables"
- Add:
| Variable | Value |
|---|---|
VITE_API_URL | https://messwala-6jvj.onrender.com/api |
VITE_GOOGLE_CLIENT_ID | From Google OAuth setup |
VITE_RECAPTCHA_SITE_KEY | From reCAPTCHA setup |
- Save
Step 4: Deploy¶
- Click "Deploy"
- Wait for build (~2-3 min)
- You'll get a URL:
https://mess-walah.vercel.app
Step 5: Verify Deployment¶
- Open the Vercel URL
- Try to login
- Check browser console for errors
Phase 4: Linking Backend & Frontend¶
Update CORS on Backend¶
- Go to Render → Environment
- Find
ALLOWED_ORIGINS - Update to only include your production URLs:
https://your-frontend-domain.vercel.app - Remove any localhost URLs (they should only be in development mode)
- Redeploy Render service
Phase 5: Admin Setup¶
Step 1: Create Admin Account¶
- Navigate to your Vercel URL
- Click "Sign Up"
- Complete the registration form:
- The first user to sign up automatically becomes the admin
- Use a secure password (minimum 12 characters recommended)
- Save credentials in a secure location (password manager)
Step 2: Configure Mess¶
After login, you'll see setup wizard:
- Mess Information
- Name (required)
- Description (optional)
-
Email & phone
-
Expense Categories
- Select presets: Vegetables, Rice, Gas, Salary, Dairy, Spices
-
Add custom: WiFi, Maintenance, etc.
-
Meal Times
- Breakfast (7:30 - 9:00 AM)
- Lunch (12:30 - 2:00 PM)
-
Dinner (7:30 - 9:00 PM)
-
Click "Complete Setup"
Step 3: Go Live¶
- System is now ready
- Students can register
- Managers can start recording expenses
- Everything is configured!
🔧 Troubleshooting Deployment¶
Backend Won't Start¶
Check Render logs: 1. Go to Render dashboard 2. Click on messwala service 3. Go to "Logs" 4. Look for error messages
Common issues: - MONGO_URI not set or incorrect - JWT_SECRET missing - Port already in use (shouldn't happen on Render)
Frontend Won't Load¶
Check Vercel logs: 1. Go to Vercel dashboard 2. Click project 3. Go to "Deployments" 4. Click latest deployment 5. Check build logs
Common issues: - VITE_API_URL incorrect - Missing environment variables - Build errors in source code
CORS Error on Frontend¶
Fix: 1. Get your Vercel URL 2. Add to Render ALLOWED_ORIGINS 3. Restart Render service 4. Wait 2-3 minutes 5. Try again
Database Connection Failed¶
Check: 1. MongoDB Atlas network access 2. Connection string format 3. Database user password 4. Username/password don't have special characters that need escaping
Test Connection (Example - use YOUR actual credentials):
# Use your env var locally instead of embedding credentials in commands:
mongosh "$env:MONGO_URI"
⚠️ SECURITY NOTE: Never put real credentials in example code or documentation. Always use environment variables (.env files).
🚀 Post-Deployment Checklist¶
- [ ] Health endpoint responds:
/api/health - [ ] Frontend loads without CORS errors
- [ ] Can login (email/password)
- [ ] Can login (Google OAuth)
- [ ] Admin setup wizard works
- [ ] Can create expense
- [ ] Can mark attendance
- [ ] Can view analytics
- [ ] Mobile responsive (check on phone)
- [ ] Performance acceptable (<3s load)
🔐 Security Checklist¶
- [ ] MongoDB whitelist not
0.0.0.0/0(production) - [ ] JWT_SECRET is random & strong
- [ ] ADMIN password is strong
- [ ] Google OAuth credentials are right
- [ ] reCAPTCHA keys configured
- [ ] HTTPS enforced (should be default)
- [ ] No API keys in code
- [ ] Sentry/monitoring enabled (optional
)
📊 Monitoring¶
Health Check Endpoint¶
Regularly check your backend health:
curl https://messwala-6jvj.onrender.com/api/health
Should return:
{
"status": "ok",
"dbState": 1,
"timestamp": "2024-01-15T10:00:00Z"
}
Performance Monitoring¶
Use built-in tools: - Vercel: Dashboard → Analytics - Render: Dashboard → Metrics - MongoDB: Atlas → Performance
🔄 Updating Deployment¶
Deploy Code Changes¶
# Make changes locally
# Commit and push
git add .
git commit -m "Fix: issue description"
git push origin main
# Automatic deployment:
# Vercel & Render redeploy automatically
Update Environment Variables¶
- Change in Render or Vercel
- Service redeploys automatically
- Or manually redeploy by clicking button
📝 Important URLs¶
Live Application: - Frontend: https://mess-walah.vercel.app - Backend: https://messwala-6jvj.onrender.com - API Root: https://messwala-6jvj.onrender.com/api
Management Dashboards: - MongoDB Atlas - Render Dashboard - Vercel Dashboard - GitHub Repository
Last Updated: March 17, 2026
Version: 2.0