Deployment
Deployment Overview

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

Deploy to Netlify (opens in a new tab)

Backend to Railway

Deploy on Railway (opens in a new tab)

Environment Variables

Before deploying, prepare these environment variables:

Required:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_ANON_KEY
  • SUPABASE_SERVICE_ROLE_KEY
  • STRIPE_SECRET_KEY
  • RESEND_API_KEY

Optional:

  • OPENAI_API_KEY
  • SENTRY_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 push

2. 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 UI

Post-Deployment

1. Configure Domains

Frontend

# Netlify Dashboard > Domain Settings
app.yourdomain.com → Netlify site

Backend

# Railway > Settings > Domains
api.yourdomain.com → Railway service

2. Set Up Webhooks

Configure webhooks for external services:

Stripe:

Webhook URL: https://api.yourdomain.com/api/webhooks/stripe
Events: subscription.created, subscription.updated, invoice.paid

Supabase:

Database Webhooks for real-time updates

3. 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/callback

4. Test Deployment

# Health check
curl https://api.yourdomain.com/health
 
# Frontend
open https://app.yourdomain.com
 
# Test authentication
# Test API endpoints
# Test webhooks

Monitoring

Set Up Monitoring

  1. Netlify Analytics: Automatically enabled
  2. Railway Metrics: View in dashboard
  3. Supabase Monitoring: Database performance

Error Tracking

Configure Sentry:

# Set environment variables
NEXT_PUBLIC_SENTRY_DSN=your-dsn
SENTRY_AUTH_TOKEN=your-token

Uptime 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@v1

Scaling

Frontend Scaling

Netlify automatically scales based on traffic.

Backend Scaling

Railway auto-scales. Or configure:

# Increase resources
railway up --replicas 3 --memory 2GB

Database 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.sql

Configuration 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

Next Steps