This guide will help you deploy the StackIt Q&A platform to Vercel (frontend) and Render (backend) with MongoDB Atlas.
- GitHub account
- Vercel account (free)
- Render account (free)
- MongoDB Atlas account (free tier available)
-
Create MongoDB Atlas Account
- Go to MongoDB Atlas
- Sign up for a free account
- Create a new cluster (M0 Free tier)
-
Configure Database
- Create a database user with read/write permissions
- Get your connection string
- Add your IP address to the whitelist (or use 0.0.0.0/0 for all IPs)
-
Connection String Format
mongodb+srv://username:password@cluster.mongodb.net/stackit?retryWrites=true&w=majority
-
Connect to GitHub
- Go to Render
- Sign up and connect your GitHub account
- Import your repository
-
Create Web Service
- Click "New +" → "Web Service"
- Connect your repository
- Set the following configuration:
- Name:
stackit-api - Root Directory:
server - Environment:
Node - Build Command:
npm install - Start Command:
npm start
- Name:
-
Environment Variables Add these environment variables in Render:
NODE_ENV=production PORT=10000 MONGODB_URI=mongodb+srv://your-connection-string JWT_SECRET=your-super-secret-jwt-key CLIENT_URL=https://your-frontend-url.vercel.app -
Deploy
- Click "Create Web Service"
- Wait for deployment to complete
- Copy the generated URL (e.g.,
https://stackit-api.onrender.com)
-
Connect to GitHub
- Go to Vercel
- Sign up and connect your GitHub account
- Import your repository
-
Configure Project
- Set the following configuration:
- Framework Preset:
Vite - Root Directory:
client - Build Command:
npm run build - Output Directory:
dist
- Framework Preset:
- Set the following configuration:
-
Environment Variables Add these environment variables in Vercel:
VITE_API_URL=https://your-backend-url.onrender.com/api -
Deploy
- Click "Deploy"
- Wait for deployment to complete
- Copy the generated URL (e.g.,
https://stackit-frontend.vercel.app)
- Update Environment Variable
- Go back to Render dashboard
- Update the
CLIENT_URLenvironment variable with your Vercel URL - Redeploy the service
NODE_ENV=production
PORT=10000
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/stackit?retryWrites=true&w=majority
JWT_SECRET=your-super-secret-jwt-key
CLIENT_URL=https://your-frontend-url.vercel.appVITE_API_URL=https://your-backend-url.onrender.com/api- Backend:
https://your-backend-url.onrender.com/api/health - Should return:
{"status":"OK","timestamp":"..."}
- Visit your Vercel URL
- Try to register a new user
- Create a question
- Test all features
curl https://your-backend-url.onrender.com/api/health- Use a strong, random JWT secret
- Generate one:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
- Use strong database passwords
- Enable network access restrictions
- Use connection string with authentication
- Never commit sensitive data to Git
- Use environment variables for all secrets
- Regularly rotate secrets
- View logs in Render dashboard
- Monitor resource usage
- Set up alerts for downtime
- Enable Vercel Analytics
- Monitor performance metrics
- Track user behavior
- Monitor database performance
- Set up alerts for high usage
- Regular backups
-
Build Failures
- Check build logs in Vercel/Render
- Ensure all dependencies are in package.json
- Verify build commands
-
Database Connection
- Verify MongoDB connection string
- Check IP whitelist in Atlas
- Ensure database user has correct permissions
-
CORS Issues
- Verify CLIENT_URL in backend environment
- Check CORS configuration in server
-
Environment Variables
- Ensure all variables are set correctly
- Check for typos in variable names
- Redeploy after changing variables
# Check backend logs
curl https://your-backend-url.onrender.com/api/health
# Test database connection
# Add this to your backend temporarily
console.log('MongoDB URI:', process.env.MONGODB_URI)- Both Vercel and Render support automatic deployments
- Push to main branch triggers deployment
- Preview deployments for pull requests
- Vercel: Use Vercel CLI
- Render: Trigger from dashboard
- Enable Vercel Edge Functions
- Use CDN for static assets
- Optimize images and bundles
- Enable Render auto-scaling
- Use MongoDB Atlas M10+ for production
- Implement caching strategies
- Create proper indexes
- Monitor query performance
- Use MongoDB Atlas performance advisor
-
Custom Domain
- Add custom domain in Vercel
- Configure DNS settings
- Update environment variables
-
SSL Certificate
- Automatically handled by Vercel/Render
- Ensure HTTPS is enforced
-
Backup Strategy
- Set up MongoDB Atlas backups
- Regular database exports
- Version control for code
-
Monitoring
- Set up error tracking (Sentry)
- Performance monitoring
- User analytics
Need Help? Create an issue in the repository or contact the development team.