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
- Go to railway.app → New Project
- Select Deploy from GitHub repo
- Connect your GitHub account and select the repository
- Railway detects the project type automatically
Step 2 — Add Database Services
Add MongoDB and Redis as Railway plugins:
- In your Railway project → click + New
- Select Database → MongoDB → Deploy
- Click + New again → Database → Redis → Deploy
- 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:
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}}/apiINFO
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:
| Provider | Callback URL |
|---|---|
https://<your-railway-domain>/api/auth/google/callback | |
| Apple | https://<your-railway-domain>/api/auth/apple/callback |
| Microsoft | https://<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:
git push origin mainRailway builds and deploys automatically. Monitor the build logs in the Railway dashboard.
Step 6 — Verify
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:
- Service → Settings → Domains → Custom Domain
- Enter your domain (e.g.,
app.changents.ai) - Add the CNAME record to your DNS:
CNAME: app.changents.ai → your-service.railway.app - Railway automatically provisions SSL
Automatic Deployments
Railway deploys automatically on every push to the connected branch. To configure deployment branches:
- Service → Settings → Source
- Change Branch to your desired branch (e.g.,
mainfor production,stagingfor staging)