Deployment Guide
Complete guide for deploying Dashtray to production.Overview
Dashtray is deployed using:- Backend: Convex (serverless functions and database)
- Frontend: Cloudflare Pages (SSR + static assets)
- Payments: DodoPayments (merchant of record)
- Email: Resend (transactional emails)
Prerequisites
- Node.js 18+ and pnpm installed
- Convex account (convex.dev)
- Cloudflare account (cloudflare.com)
- DodoPayments account (dodopayments.com)
- Resend account (resend.com)
- Custom domain (optional)
Environment Setup
1. Convex Environment Variables
Set these in Convex usingnpx convex env set KEY value:
2. SvelteKit Environment Variables
Create.env.production:
3. Cloudflare Environment Variables
Set in Cloudflare Pages dashboard:PUBLIC_CONVEX_URL: Your Convex deployment URLPUBLIC_CONVEX_SITE_URL: Your Convex site URLSITE_URL: Your application URL
Deployment Steps
Step 1: Deploy Convex Backend
- Deployment URL (use for
PUBLIC_CONVEX_URL) - Site URL (use for
PUBLIC_CONVEX_SITE_URL)
Step 2: Configure OAuth Providers (Optional)
Google OAuth
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URI:
- Copy Client ID and Secret to Convex env
GitHub OAuth
- Go to GitHub Settings → Developer settings
- Create new OAuth App
- Set Authorization callback URL:
- Copy Client ID and Secret to Convex env
Step 3: Configure DodoPayments
- Log in to DodoPayments Dashboard
- Get your API key from Settings → API Keys
- Set up webhook endpoint:
- Copy webhook secret
- Set environment variables in Convex
Step 4: Configure Resend
- Log in to Resend Dashboard
- Get your API key from Settings → API Keys
- Verify your sending domain
- Set environment variables in Convex
Step 5: Build SvelteKit Application
Step 6: Deploy to Cloudflare Pages
Option A: Using Wrangler CLI
Option B: Using Cloudflare Dashboard
- Go to Cloudflare Dashboard
- Navigate to Pages
- Click “Create a project”
- Connect your Git repository (GitHub, GitLab, etc.)
- Configure build settings:
- Build command:
pnpm build - Build output directory:
.svelte-kit/cloudflare - Root directory:
/
- Build command:
- Add environment variables (see Step 3 above)
- Click “Save and Deploy”
Step 7: Configure Custom Domain (Optional)
- In Cloudflare Pages, go to your project
- Click “Custom domains”
- Click “Set up a custom domain”
- Enter your domain (e.g.,
dashtray.com) - Follow DNS configuration instructions
- Wait for SSL certificate provisioning (automatic)
Step 8: Verify Deployment
-
Test authentication:
- Sign up with email
- Verify email works
- Test OAuth (if configured)
-
Test integrations:
- Connect Stripe
- Verify metrics sync
- Check dashboard displays
-
Test webhooks:
- Trigger DodoPayments webhook (test subscription)
- Check webhook logs in Convex
-
Test alerts:
- Create an alert
- Verify it triggers correctly
- Check notifications
-
Test AI:
- Set up AI key
- Ask a question
- Verify response
CI/CD Setup
GitHub Actions
Create.github/workflows/deploy.yml:
Required Secrets
Add these to GitHub repository secrets:CONVEX_DEPLOY_KEY: Get from Convex dashboardPUBLIC_CONVEX_URL: Your Convex deployment URLPUBLIC_CONVEX_SITE_URL: Your Convex site URLSITE_URL: Your application URLCLOUDFLARE_API_TOKEN: Get from Cloudflare dashboard
Monitoring
Convex Monitoring
- Go to Convex Dashboard
- Select your deployment
- Monitor:
- Function execution times
- Database query performance
- Error rates
- Cron job status
Cloudflare Analytics
- Go to Cloudflare Pages dashboard
- View analytics:
- Page views
- Unique visitors
- Bandwidth usage
- Error rates
Error Tracking (Optional)
Sentry Setup
Uptime Monitoring
Use services like: Monitor endpoints:https://dashtray.com(homepage)https://dashtray.com/api/health(health check)
Backup Strategy
Convex Backups
Convex automatically backs up your data:- Continuous backups
- Point-in-time recovery
- 30-day retention
Environment Variables Backup
Store encrypted backups of environment variables:Rollback Procedure
Rollback Convex
Rollback Cloudflare Pages
- Go to Cloudflare Pages dashboard
- Click on your project
- Go to “Deployments”
- Find previous successful deployment
- Click “Rollback to this deployment”
Scaling Considerations
Convex Scaling
Convex scales automatically:- No configuration needed
- Handles traffic spikes
- Global edge network
Cloudflare Pages Scaling
Cloudflare Pages scales automatically:- Global CDN
- Unlimited bandwidth
- DDoS protection
Database Optimization
- Add indexes: For frequently queried fields
- Paginate results: Don’t fetch all data at once
- Cache responses: Use Convex’s built-in caching
- Optimize queries: Use indexes effectively
Security Checklist
- HTTPS enabled (automatic with Cloudflare)
- Environment variables set correctly
- Master encryption key is secure and backed up
- OAuth credentials are production keys
- DodoPayments webhook secret is set
- Resend API key is production key
- CORS configured correctly
- CSP headers configured
- Rate limiting enabled
- Error messages don’t leak sensitive info
Performance Optimization
Frontend
- Enable caching: Cloudflare automatically caches static assets
- Optimize images: Use WebP format, lazy loading
- Code splitting: SvelteKit does this automatically
- Minimize JavaScript: Remove unused dependencies
Backend
- Optimize queries: Use indexes, limit results
- Batch operations: Group related mutations
- Cache frequently accessed data: Use Convex caching
- Monitor slow queries: Use Convex dashboard
Troubleshooting
Deployment Fails
Convex deployment fails:Application Errors
500 errors:- Check Convex logs:
npx convex logs - Check Cloudflare Pages logs
- Verify environment variables
- Check for missing dependencies
- Verify
BETTER_AUTH_SECRETis set - Check OAuth redirect URIs
- Verify
SITE_URLmatches actual URL
- Verify webhook URL is correct
- Check webhook secret matches
- Review webhook logs in DodoPayments dashboard
- Check Convex logs for errors
Maintenance
Regular Tasks
Weekly:- Review error logs
- Check uptime metrics
- Monitor database size
- Review and optimize slow queries
- Check for dependency updates
- Review security advisories
- Rotate encryption keys (if needed)
- Review and update documentation
- Conduct security audit
Updates
Dependency updates:Cost Estimation
Convex
- Free tier: 1M function calls/month
- Pro: $25/month + usage
- Estimated: $50-200/month depending on traffic
Cloudflare Pages
- Free tier: Unlimited requests, 500 builds/month
- Pro: $20/month + usage
- Estimated: $0-50/month
DodoPayments
- Commission: 5% + payment processing fees
- No monthly fee
Resend
- Free tier: 3,000 emails/month
- Pro: $20/month for 50,000 emails
- Estimated: $0-20/month
Need Help?
- Convex Docs: docs.convex.dev
- Cloudflare Pages Docs: developers.cloudflare.com/pages
- SvelteKit Docs: kit.svelte.dev
- Support: support@dashtray.com