Deployment Architecture

WhatsApp Team Inbox consists of three main components that need to be deployed:

Components

Frontend

Next.js 14 application served via Vercel, Netlify, or self-hosted

Backend

Express.js API server on Railway, Heroku, or VPS

Database

PostgreSQL database on Railway, AWS RDS, or managed service

Deployment Options

1

Frontend on Vercel

  • Zero configuration deployment
  • Automatic HTTPS
  • Global CDN
  • Cost: Free tier available
2

Backend on Railway

  • Easy deployment from GitHub
  • Automatic scaling
  • Built-in PostgreSQL
  • Cost: ~$5-25/month
3

Database on Railway

  • Managed PostgreSQL
  • Automatic backups
  • Connection pooling
  • Included with backend

Option 2: Cloud Provider (AWS/GCP/Azure)

1

Frontend

  • AWS Amplify / Google Cloud Run / Azure Static Web Apps
  • Full control over configuration
  • Cost: Pay-as-you-go
2

Backend

  • AWS ECS / Google Cloud Run / Azure Container Apps
  • Container-based deployment
  • Cost: ~$20-100/month
3

Database

  • AWS RDS / Cloud SQL / Azure Database
  • Fully managed
  • Cost: ~$15-50/month

Option 3: Self-Hosted (VPS)

1

VPS Provider

DigitalOcean, Linode, or Vultr
  • Full control
  • Cost: ~$10-40/month
2

Setup

  • Install Node.js, PostgreSQL, Nginx
  • Configure reverse proxy
  • Setup SSL with Let’s Encrypt

Pre-Deployment Checklist

Database created and accessible
Environment variables configured
WhatsApp Business API account created
Email service (Resend) account created
Domain name registered
SSL certificate obtained
DNS configured
Webhook URLs ready

External Services Required

Environment Variables

You’ll need to configure these for production:
# Application
NODE_ENV=production
PORT=4000
FRONTEND_URL=https://your-domain.com

# Database
DATABASE_URL=postgresql://...

# Authentication
JWT_SECRET=...
SESSION_SECRET=...

# WhatsApp
WHATSAPP_ACCESS_TOKEN=...
WHATSAPP_PHONE_NUMBER_ID=...
WHATSAPP_VERIFY_TOKEN=...

# Push Notifications
VAPID_PUBLIC_KEY=...
VAPID_PRIVATE_KEY=...
VAPID_SUBJECT=mailto:support@...

# Email
RESEND_API_KEY=...
EMAIL_FROM=noreply@...
See Environment Variables Guide for complete list
# API Endpoints
NEXT_PUBLIC_API_URL=https://api.your-domain.com
NEXT_PUBLIC_WS_URL=wss://api.your-domain.com

# App Configuration
NEXT_PUBLIC_APP_URL=https://your-domain.com
NEXT_PUBLIC_ENV=production

Security Considerations

Never commit .env files to version control. Use your hosting provider’s secret management.

HTTPS Only

All traffic must use HTTPS in production

Secure Cookies

Set COOKIE_SECURE=true in production

CORS Configuration

Whitelist only your frontend domain

Rate Limiting

Configure appropriate limits for your use case

Deployment Steps

1

Setup External Services

  • Configure WhatsApp Business API
  • Setup Resend for emails
  • Create PostgreSQL database
2

Configure Environment Variables

  • Add all required env vars to hosting provider
  • Generate secrets (JWT, VAPID keys)
  • Test database connection
3

Deploy Backend

  • Push to GitHub/GitLab
  • Connect to Railway/Heroku
  • Run database migrations
  • Verify API health endpoint
4

Deploy Frontend

  • Configure env vars in Vercel
  • Connect GitHub repository
  • Deploy and verify build
5

Configure Webhooks

  • Set WhatsApp webhook URL
  • Verify webhook connection
  • Test message reception
6

Testing

  • Send test WhatsApp message
  • Test push notifications
  • Verify email sending
  • Check all features work

Post-Deployment

Monitoring

Setup monitoring and alerting

Backups

Configure automated database backups

SSL Renewal

Ensure auto-renewal is configured

Scaling

Plan for horizontal scaling if needed

Cost Estimates

Monthly costs for a small team (100 conversations/day):
ServiceProviderCost
FrontendVercel$0 (free tier)
BackendRailway$5-20
DatabaseRailwayIncluded
WhatsApp APIMeta$50-200
EmailResend$0 (free tier)
DomainNamecheap$10/year
SSLLet’s EncryptFree
Total~$60-230/month

Next Steps