Skip to content
Back to the app

Railway Cloud Deployment ​

Railway is the fastest way to deploy CHANGENTS.AI's backend and web frontend to the cloud. It handles infrastructure, SSL, and scaling automatically.


Prerequisites ​

  • Railway account (railway.app)
  • GitHub repository with the CHANGENTS.AI codebase
  • MongoDB Atlas cluster (or Railway's MongoDB plugin)
  • Redis Cloud instance (or Railway's Redis plugin)

Step 1 — Create a Railway Project ​

  1. Go to railway.app → New Project
  2. Select Deploy from GitHub repo
  3. Connect your GitHub account and select the repository
  4. Railway detects the project type automatically

Step 2 — Add Database Services ​

Add MongoDB and Redis as Railway plugins:

  1. In your Railway project → click + New
  2. Select Database → MongoDB → Deploy
  3. Click + New again → Database → Redis → Deploy
  4. Railway creates the services and provides connection strings automatically

Copy the MONGODB_URI and REDIS_URL from each plugin's Variables tab.


Step 3 — Configure Environment Variables ​

In your Railway service → Variables tab, add:

bash
NODE_ENV=production
PORT=8084
BACKEND_PORT=8085

# Database (from Railway plugins)
MONGODB_URI=${{MongoDB.MONGO_URL}}
REDIS_URL=${{Redis.REDIS_URL}}

# Auth
JWT_SECRET=<generate with: openssl rand -hex 32>
SESSION_SECRET=<generate with: openssl rand -hex 64>

# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
EXPO_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id

# Apple Sign-In
APPLE_CLIENT_ID=your-apple-client-id
APPLE_TEAM_ID=your-apple-team-id
APPLE_KEY_ID=your-apple-key-id
APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----"

# Microsoft OAuth
MICROSOFT_CLIENT_ID=your-microsoft-client-id
MICROSOFT_CLIENT_SECRET=your-microsoft-client-secret

# AI
ANTHROPIC_API_KEY=sk-ant-...

# Payments
STRIPE_SECRET_KEY=sk_live_...
EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_...

# Frontend
EXPO_PUBLIC_API_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}/api

INFO

Use ${{Railway.VARIABLE_NAME}} syntax to reference other Railway service variables. Railway resolves these at deploy time.


Step 4 — OAuth Callback URLs ​

Railway provides a stable public domain. Update your OAuth provider callback URLs:

ProviderCallback URL
Googlehttps://<your-railway-domain>/api/auth/google/callback
Applehttps://<your-railway-domain>/api/auth/apple/callback
Microsofthttps://<your-railway-domain>/api/auth/microsoft/callback

Your Railway domain is shown in the service's Settings → Domains tab.


Step 5 — Deploy ​

Push to your connected branch:

bash
git push origin main

Railway builds and deploys automatically. Monitor the build logs in the Railway dashboard.


Step 6 — Verify ​

bash
curl https://your-railway-domain.railway.app/api/health
# Expected: { "status": "healthy", ... }

curl -i https://your-railway-domain.railway.app/health/ready
# 200 with "status": "ready" when the database answers; 503 "not_ready" when it does not

/health answers 200 even when a dependency is down, and /health/ready does not. See Health checks before you point a Railway healthcheck at /health/ready: a failing healthcheck blocks the deploy.


Custom Domain ​

Add a custom domain in Railway:

  1. Service → Settings → Domains → Custom Domain
  2. Enter your domain (e.g., app.changents.ai)
  3. Add the CNAME record to your DNS:
    CNAME: app.changents.ai → your-service.railway.app
  4. Railway automatically provisions SSL

Automatic Deployments ​

Railway deploys automatically on every push to the connected branch. To configure deployment branches:

  1. Service → Settings → Source
  2. Change Branch to your desired branch (e.g., main for production, staging for staging)

What's Next? ​

Served from this deployment. No page view leaves it.