Deployment Architecture
Evaly uses a split deployment architecture:- Frontend: Deployed to Cloudflare Workers (serverless edge computing)
- Backend: Deployed to Convex (serverless backend platform)
- File Storage: Cloudflare R2 (object storage)
The frontend and backend are deployed independently. This allows you to update each component without affecting the other.
Prerequisites
Before deploying, ensure you have:- Wrangler CLI installed
- A Cloudflare account
- A Convex account with a production deployment
- All environment variables configured
Backend Deployment (Convex)
Set Production Environment Variables
Configure all required environment variables for production. Make sure to update URLs and use production credentials:
Use the
--prod flag to set environment variables specifically for production.Deploy to Convex
Deploy your Convex backend to production:This will:
- Push all functions from the
convex/directory - Update database schemas
- Set up scheduled functions (crons)
- Deploy all Convex components (R2, presence, agent, polar)
Verify Deployment
Check the deployment status in the Convex Dashboard:
- Verify all functions are deployed
- Check that database tables are created
- Ensure environment variables are set correctly
- Review deployment logs for any errors
Frontend Deployment (Cloudflare Workers)
Configure Cloudflare
Install Wrangler CLI if you haven’t already:Authenticate with Cloudflare:This will open a browser window for you to log in to your Cloudflare account.
Update Frontend Environment
Update your
.env.local file to point to your production Convex deployment:.env.local
Update Wrangler Configuration
Review your You can customize:
wrangler.jsonc configuration:wrangler.jsonc
name: Your worker name (used in the Cloudflare dashboard)compatibility_date: The date for Cloudflare Workers API compatibilityobservability: Enable/disable monitoring and analytics
Build and Deploy
Deploy the frontend to Cloudflare Workers:This single command will:
- Build the application with Vite (
vite build) - Generate a sitemap for SEO (
bun run generate:sitemap) - Deploy to Cloudflare Workers (
wrangler deploy)
Configure Custom Domain (Optional)
To use a custom domain:
- Go to your Cloudflare Dashboard
- Navigate to Workers & Pages > Your worker
- Go to Settings > Domains & Routes
- Click Add Custom Domain
- Enter your domain (e.g.,
evaly.io) - Cloudflare will automatically configure DNS if your domain is managed by Cloudflare
If your domain is not managed by Cloudflare, you’ll need to add CNAME records manually.
Deployment Scripts
Evaly provides several npm scripts for deployment:Environment-Specific Deployments
Development/Staging
For staging deployments, you can use a separate Cloudflare Worker:wrangler.staging.jsonc for staging-specific configuration.
Production
Always use the--prod flag for production Convex deployments:
Post-Deployment Checklist
After deploying, verify the following:Test Authentication
- Test Google OAuth login flow
- Verify redirects work correctly
- Check user session persistence
Test File Uploads
- Upload an image in the question editor
- Verify files are stored in R2
- Check that uploaded files are publicly accessible via CDN
Test Email Delivery
- Send a test invitation
- Trigger a password reset
- Verify emails are delivered successfully
Test Real-Time Features
- Create a test and monitor participants
- Verify presence tracking works
- Check that notifications appear in real-time
Monitoring and Observability
Cloudflare Workers
Cloudflare provides built-in observability:- Go to Workers & Pages in Cloudflare Dashboard
- Select your worker
- View metrics:
- Request volume
- Success/error rates
- CPU time
- Response times
Convex Backend
Monitor your Convex deployment:- Visit Convex Dashboard
- Select your production deployment
- Review:
- Function execution metrics
- Database query performance
- Real-time connection count
- Error logs
Continuous Deployment
GitHub Actions
Create a GitHub Actions workflow for automated deployments:.github/workflows/deploy.yml
Generate a Convex deploy key from your Convex Dashboard under Settings → Deploy Keys.
Rollback Procedure
If you need to rollback a deployment:Frontend Rollback
Backend Rollback
Convex doesn’t support direct rollbacks, but you can:- Revert your Git repository to the previous commit
- Run
npx convex deploy --prodto redeploy the old version
Performance Optimization
Build Optimization
The Vite build is already optimized, but you can further improve it:- Enable compression in Cloudflare (automatic)
- Configure caching headers for static assets
- Use Cloudflare’s CDN for global distribution
Database Optimization
Convex automatically optimizes queries, but consider:- Adding indexes for frequently queried fields
- Using pagination for large datasets
- Implementing soft deletes (already done in Evaly)
Troubleshooting
Deployment Fails
Build errors:- Run
bun run typecheckto catch TypeScript errors - Ensure all dependencies are installed with
bun install
- Run
wrangler loginto re-authenticate - Check API token permissions in Cloudflare Dashboard
Runtime Errors
OAuth redirect issues:- Verify
SITE_URLmatches your production domain - Check OAuth redirect URIs in Google Cloud Console
- Verify R2 bucket permissions
- Check
R2_CDN_URLis publicly accessible - Review R2 CORS configuration
- Check WebSocket connections in browser DevTools
- Verify Convex deployment is running
- Review Convex logs for errors
Security Considerations
- Rotate API keys regularly
- Use separate credentials for production and development
- Enable Cloudflare’s security features (WAF, DDoS protection)
- Review Convex function permissions
- Implement rate limiting for sensitive operations
Cost Optimization
Cloudflare Workers
- Free Tier: 100,000 requests/day
- Workers Paid: $5/month for 10 million requests
Convex
- Starter: Free tier with generous limits
- Professional: Pay-as-you-go for larger deployments
Next Steps
- Review the Architecture Overview
- Explore the API Overview
- Learn about Contributing to the project