Deployment Overview
Deploy HiveForge to production with Netlify and Railway.
Architecture
┌─────────────────┐
│ Netlify CDN │ Frontend (Next.js)
└────────┬────────┘
│
┌────▼────┐
│ Railway │ Backend (FastAPI)
└────┬────┘
│
┌────▼────┐
│Supabase │ Database + Auth
└─────────┘Quick Deploy
One-Click Deployment
Frontend to Netlify
Backend to Railway
Environment Variables
Before deploying, prepare these environment variables:
Required:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYSTRIPE_SECRET_KEYRESEND_API_KEY
Optional:
OPENAI_API_KEYSENTRY_DSN
See Environment Variables for complete list.
Manual Deployment
1. Deploy Database (Supabase)
# Create Supabase project
supabase projects create hiveforge
# Link to project
supabase link --project-ref your-project-ref
# Push migrations
supabase db push2. Deploy Backend (Railway)
# Install Railway CLI
npm install -g @railway/cli
# Login
railway login
# Create project
railway init
# Deploy
railway up
# Set environment variables
railway variables set SUPABASE_URL=...
railway variables set SUPABASE_SERVICE_ROLE_KEY=...3. Deploy Frontend (Netlify)
# Install Netlify CLI
npm install -g netlify-cli
# Login
netlify login
# Deploy
cd apps/web
netlify deploy --prod
# Set environment variables in Netlify UIPost-Deployment
1. Configure Domains
Frontend
# Netlify Dashboard > Domain Settings
app.yourdomain.com → Netlify siteBackend
# Railway > Settings > Domains
api.yourdomain.com → Railway service2. Set Up Webhooks
Configure webhooks for external services:
Stripe:
Webhook URL: https://api.yourdomain.com/api/webhooks/stripe
Events: subscription.created, subscription.updated, invoice.paidSupabase:
Database Webhooks for real-time updates3. Configure OAuth
Update OAuth redirect URLs:
Supabase Dashboard:
Authentication > URL Configuration
Site URL: https://app.yourdomain.com
Redirect URLs:
- https://app.yourdomain.com/auth/callback
- http://localhost:3000/auth/callback (for development)Google OAuth:
Authorized redirect URIs:
- https://your-project.supabase.co/auth/v1/callback4. Test Deployment
# Health check
curl https://api.yourdomain.com/health
# Frontend
open https://app.yourdomain.com
# Test authentication
# Test API endpoints
# Test webhooksMonitoring
Set Up Monitoring
- Netlify Analytics: Automatically enabled
- Railway Metrics: View in dashboard
- Supabase Monitoring: Database performance
Error Tracking
Configure Sentry:
# Set environment variables
NEXT_PUBLIC_SENTRY_DSN=your-dsn
SENTRY_AUTH_TOKEN=your-tokenUptime Monitoring
Use services like:
- UptimeRobot
- Pingdom
- StatusCake
Continuous Deployment
GitHub Actions
Deployments trigger automatically on push to main:
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pnpm install
- run: pnpm build:web
- uses: netlify/actions/cli@master
with:
args: deploy --prod
deploy-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: railway/deploy-action@v1Scaling
Frontend Scaling
Netlify automatically scales based on traffic.
Backend Scaling
Railway auto-scales. Or configure:
# Increase resources
railway up --replicas 3 --memory 2GBDatabase Scaling
Upgrade Supabase plan for:
- More connections
- Increased storage
- Better performance
Backup Strategy
Database Backups
# Automatic backups (Supabase)
# Daily backups retained for 7 days
# Manual backup
supabase db dump > backup.sqlConfiguration Backups
- Environment variables in 1Password/Vault
- Infrastructure as code in git
- Regular exports of Stripe products
Security Checklist
- HTTPS enabled on all domains
- Environment variables secured
- Secrets rotated
- CORS configured
- Rate limiting enabled
- WAF configured (optional)
- DDoS protection (Netlify/Railway)
- Security headers set
Cost Estimation
Typical Monthly Costs
Starter (< 1000 users):
- Netlify: $0 (free tier)
- Railway: $5-20
- Supabase: $25
- Total: ~$30-45/month
Growth (1000-10000 users):
- Netlify: $19 (Pro)
- Railway: $50-100
- Supabase: $25
- Total: ~$94-144/month
Scale (10000+ users):
- Netlify: $19-99
- Railway: $200+
- Supabase: $599+
- Total: ~$818+/month
Troubleshooting
Build Failures
Check:
- Node version
- Environment variables
- Dependency issues
Runtime Errors
Check:
- Logs in Netlify/Railway
- Sentry for exceptions
- Database connections
Performance Issues
- Enable caching
- Optimize database queries
- Use CDN for assets
- Implement rate limiting