Affinity Design
Agency Guide

Deployment & Infrastructure

Deploying and maintaining your agency platform

  • Hosting: Railway (or any Docker-capable host)
  • Database: MongoDB (Railway plugin or Atlas)
  • CDN/DNS: Cloudflare
  • Storage: Cloudflare R2 or AWS S3

Deploying to Railway

Deploy the app as a Docker service on Railway, with the required environment variables below configured in the service settings.

Environment Variables

Required

VariableDescription
SERVER_SECRET64-char random string
MONGODB_URIMongoDB connection string
GEMINI_API_KEYGoogle AI Studio key
CORS_ORIGINAllowed frontend origins
REDIRECT_URLPublic API URL

Auto-injected by Railway

VariableNotes
PORTAuto-assigned
MONGODB_URIAuto-set if using Railway MongoDB plugin

Custom Domains

  1. Generate a Railway domain for the service
  2. Add your custom domain (e.g., api.youragency.com)
  3. Create a CNAME record in your DNS pointing to the Railway domain
  4. If using Cloudflare proxy, SSL is handled automatically

Scaling

  • The app is stateless (all state in MongoDB) — scale horizontally
  • Increase Railway service resources as needed
  • For high call volume, consider separate services for voice and API

Monitoring

  • Healthcheck: GET /status
  • Railway provides built-in metrics and logging
  • Configure GITHUB_ISSUE_TOKEN for automatic error reporting to GitHub Issues

On this page