Railway Service Setup Guide
Step-by-step guide for creating the backend-docs-api service in Railway
Railway Service Setup for Backend Docs API
You have the Railway project created ("Docs Api"), now let's add the service.
Current Status
✅ Railway project exists: "Docs Api"
⏳ Need to add service: "backend-docs-api"
Step-by-Step Service Creation
Step 1: Add Service in Railway Dashboard
- Open your Railway project: https://railway.com/project/3990549d-4313-47e4-9682-d17b382bdba2
- Click the "+ New" button or "Add a Service" button
- Select "GitHub Repo"
- Select your repository (the one containing this code)
- Click "Add Service"
Step 2: Configure Service Settings
Once the service is created:
Name the service: Click on the service name and rename to "backend-docs-api"
Configure Build Settings:
- Build Command:
yarn install && nx build backend-docs-api --configuration=production - Start Command:
node dist/apis/backend-docs-api/main.js
- Build Command:
Set Root Directory (if asked):
- Leave blank (root of monorepo)
Step 3: Add Environment Variables
Click "Variables" tab and add these:
NODE_ENV=production
PORT=${{PORT}}
RAILWAY_ENVIRONMENT=true
# MongoDB (test-modules cluster)
MONGODB_CONNECTION_STRING_TEST_MODULES=<your-mongodb-uri>
# Shared Authentication (MUST match backend-api)
JWT_SECRET=<copy-from-backend-api-railway-vars>
SYSTEM_TOKEN=<copy-from-backend-api-railway-vars>
# CORS
ALLOWED_ORIGINS=https://gograb.space,http://localhost:5010
# Build optimization
NPM_CONFIG_FETCH_RETRIES=5
NPM_CONFIG_FETCH_TIMEOUT=300000
NPM_CONFIG_NETWORK_TIMEOUT=600000
YARN_NETWORK_TIMEOUT=600000
Important: Copy JWT_SECRET and SYSTEM_TOKEN from your backend-api Railway variables to ensure shared authentication works.
Step 4: Configure Health Check
- Click "Settings" tab
- Scroll to "Health Check"
- Set Health Check Path:
/docs-api/health - Set Health Check Timeout:
30seconds - Click "Save"
Step 5: Deploy
Railway will automatically start deploying. Watch the build logs:
- Click "Deployments" tab
- Click on the active deployment
- Watch the logs
Expected logs:
Building...
Installing dependencies...
Building backend-docs-api...
✅ Build complete
Starting application...
📚 GoGrab Backend Docs API READY on port 8080
Step 6: Generate Domain
- Go to "Settings" tab
- Scroll to "Networking"
- Click "Generate Domain"
- Copy the generated URL (e.g.,
backend-docs-api-production.up.railway.app)
Step 7: Test Deployment
# Replace with your Railway domain
curl https://backend-docs-api-production.up.railway.app/docs-api/health
Expected response:
{
"status": "ok",
"timestamp": "2025-12-21T...",
"service": "backend-docs-api",
"database": "docs-database"
}
✅ Service deployed successfully!
Alternative: Deploy via CLI
If you prefer using Railway CLI:
Step 1: Login to Railway
railway login
Step 2: Link to Project
# Use your project token
export RAILWAY_TOKEN=<your-RAILWAY_DOCS_TOKEN>
# Or link interactively
railway link
# Select: "Docs Api" project
Step 3: Deploy
cd /Users/fguijarro/developer/repos/editor
railway up --service backend-docs-api
Railway will:
- Detect your code
- Build using Nixpacks or Dockerfile
- Start the service
- Generate a URL
Using Our Deployment Script
Once the service exists, you can use our script:
./deployment/deploy-docs-api.sh
Note: The script requires:
RAILWAY_DOCS_TOKENin.env.local- Service already created in Railway project
Troubleshooting
"No services found" Error
Solution: Create the service manually in Railway dashboard first (Step 1 above).
Build Fails
Check:
- Build command is correct
- All environment variables are set
- MongoDB connection string is valid
Logs: View in Railway dashboard → Deployments → Click deployment → View logs
Health Check Fails
Check:
- Health check path is
/docs-api/health - App is actually starting (check logs)
- Port is correct (Railway sets
PORTenv var)
Fix: Make sure main.ts uses process.env.PORT in Railway environment.
Can't Connect to MongoDB
Check:
MONGODB_CONNECTION_STRING_TEST_MODULESis correct- MongoDB Atlas network access allows Railway IPs (use 0.0.0.0/0)
- Database user has read/write permissions
Next Steps After Service is Running
Get Railway URL: Copy from Settings → Networking
Update .env.local:
RAILWAY_DOCS_API_URL=https://your-domain.railway.appRun Initial Sync:
export DOCS_API_URL=https://your-domain.railway.app/docs-api yarn docs:syncUpdate Frontend Environment:
// apps/docs-angular/src/environments/environment.prod.ts docsApiUrl: 'https://your-domain.railway.app/docs-api'Build Frontend:
nx build docs-angular --configuration=productionDeploy Frontend to gograb.space/docs
Railway Project Structure
Your project should look like:
Docs Api (Railway Project)
└── backend-docs-api (Service)
├── Variables (environment vars)
├── Settings (health check, networking)
└── Deployments (build history)
Quick Reference
Railway Dashboard Tabs
- Architecture: Visual view of services
- Observability: Metrics and monitoring
- Logs: Real-time application logs
- Settings: Service configuration
Important URLs
- Dashboard: https://railway.com/project/
- Deployment Logs: Dashboard → Deployments → Click deployment
- Environment Variables: Dashboard → Variables
- Health Check Config: Dashboard → Settings
Support
If you encounter issues:
- Check Railway documentation: https://docs.railway.app
- View deployment logs in Railway dashboard
- Test locally first:
yarn serve:backend-docs - Verify all environment variables are set
Ready to create the service? Follow Step 1 above to add the backend-docs-api service to your Railway project!