This guide walks you through deploying CodeLearnHub to Vercel (Frontend) and Render (Backend).
Before deploying, ensure you have:
- ✅ GitHub account with this repository
- ✅ MongoDB Atlas account with a cluster
- ✅ GitHub OAuth App (for authentication)
- ✅ Google OAuth App (optional, for Google login)
-
Create a MongoDB Atlas Account
- Go to mongodb.com/atlas
- Sign up for a free account
-
Create a Cluster
- Choose the FREE tier (M0 Sandbox)
- Select a region close to your users
-
Create a Database User
- Go to Database Access → Add New Database User
- Create a username and password (save these!)
-
Configure Network Access
- Go to Network Access → Add IP Address
- Click "Allow Access from Anywhere" (0.0.0.0/0)
- This is required for cloud services like Render and Vercel
-
Get Connection String
- Go to Database → Connect → Connect your application
- Copy the connection string
- Replace
<password>with your database user password
- Go to GitHub Developer Settings
- Click "New OAuth App"
- Fill in the details:
Application name: CodeLearnHub Homepage URL: https://your-app.vercel.app Authorization callback URL: https://your-backend.onrender.com/api/auth/callback/github - Click "Register application"
- Copy the Client ID
- Click "Generate a new client secret" and copy it
- Go to Google Cloud Console
- Create a new project or select existing
- Go to APIs & Services → Credentials
- Click "Create Credentials" → "OAuth client ID"
- Configure consent screen if prompted
- Application type: Web application
- Add to Authorized redirect URIs:
https://your-backend.onrender.com/api/auth/callback/google - Copy the Client ID and Client Secret
-
Sign Up for Render
- Go to render.com
- Sign up with GitHub
-
Create Web Service
- Click "New +" → "Web Service"
- Connect your GitHub repository
- Configure:
Setting Value Name codelearnhub-backendRegion Oregon (US West) Branch mainRoot Directory backendRuntime Python 3 Build Command pip install -r requirements.txtStart Command uvicorn server:app --host 0.0.0.0 --port $PORT -
Add Environment Variables
Click "Advanced" → "Add Environment Variable":
Key Value MONGO_URLmongodb+srv://username:password@cluster.mongodb.net/DB_NAMEcodelearnhubFRONTEND_URLhttps://your-app.vercel.app(update later)CORS_ORIGINShttps://your-app.vercel.app(update later)GITHUB_CLIENT_IDYour GitHub OAuth Client ID GITHUB_CLIENT_SECRETYour GitHub OAuth Secret GOOGLE_CLIENT_IDYour Google OAuth Client ID (optional) GOOGLE_CLIENT_SECRETYour Google OAuth Secret (optional) -
Deploy
- Click "Create Web Service"
- Wait 3-5 minutes for deployment
- Note your URL:
https://codelearnhub-backend.onrender.com
-
Test Backend
- Visit:
https://your-backend.onrender.com/api/health - You should see:
{"status": "healthy", ...}
- Visit:
-
Sign Up for Vercel
- Go to vercel.com
- Sign up with GitHub
-
Import Project
- Click "Add New..." → "Project"
- Select your GitHub repository
-
Configure Project
Setting Value Framework Preset Create React App Root Directory frontendBuild Command npm run buildoryarn buildOutput Directory buildInstall Command npm installoryarn install -
Add Environment Variables
Key Value REACT_APP_BACKEND_URLhttps://your-backend.onrender.comREACT_APP_ENVproduction -
Deploy
- Click "Deploy"
- Wait 1-2 minutes
- Your app is live at:
https://your-project.vercel.app
- Go to Render Dashboard → Your Service → Environment
- Update these variables with your actual Vercel URL:
FRONTEND_URL→https://your-project.vercel.appCORS_ORIGINS→https://your-project.vercel.app
- Click "Save Changes" (triggers redeploy)
GitHub:
- Go to your GitHub OAuth App settings
- Update Authorization callback URL to:
https://your-backend.onrender.com/api/auth/callback/github
Google:
- Go to Google Cloud Console → Credentials
- Update Authorized redirect URIs to:
https://your-backend.onrender.com/api/auth/callback/google
Run this command to populate initial articles:
curl -X POST https://your-backend.onrender.com/api/seed/articlesOr visit: https://your-backend.onrender.com/docs and use the Swagger UI.
- Backend health check works:
/api/health - Frontend loads without errors
- GitHub login works
- Google login works (if configured)
- Articles are seeded and visible
- Documentation pages load
- Dark/Light mode toggle works
| Issue | Solution |
|---|---|
| CORS errors | Ensure CORS_ORIGINS includes your Vercel URL |
| OAuth redirect fails | Check callback URLs match exactly |
| Database connection fails | Verify MongoDB Atlas IP whitelist includes 0.0.0.0/0 |
| 500 errors on backend | Check Render logs for Python errors |
| Blank page on frontend | Check browser console for errors |
- Go to Project Settings → Domains
- Add your domain:
www.yourdomain.com - Follow DNS configuration instructions
- Go to Service Settings → Custom Domains
- Add your API domain:
api.yourdomain.com - Follow DNS configuration instructions
- Push changes to GitHub
- Vercel and Render will auto-deploy
- Render: View logs in the dashboard
- Vercel: View deployment logs and analytics
- MongoDB Atlas: Monitor database metrics
Render Free Tier:
- Spins down after 15 minutes of inactivity
- First request after sleep takes 30-60 seconds
- 750 hours/month
Vercel Free Tier:
- 100GB bandwidth/month
- Unlimited deployments
- Serverless functions limited
If you encounter issues:
- Check the GitHub Issues
- Review Render and Vercel logs
- Ensure all environment variables are set correctly
Happy Deploying! 🚀