// Expert guidance for deploying, managing, and scaling GabeDA infrastructure on Railway (backend) and Render (frontend). Handles environment configuration, CORS setup, troubleshooting, monitoring, and production optimizations. Use when deploying services, fixing deployment issues, configuring infrastructure, or scaling production systems.
| name | devops |
| description | Expert guidance for deploying, managing, and scaling GabeDA infrastructure on Railway (backend) and Render (frontend). Handles environment configuration, CORS setup, troubleshooting, monitoring, and production optimizations. Use when deploying services, fixing deployment issues, configuring infrastructure, or scaling production systems. |
Provide expert guidance for deploying, managing, and troubleshooting GabeDA's full-stack infrastructure across Railway (backend) and Render (frontend). Handle environment configuration, CORS setup, deployment automation, monitoring, and production optimizations.
Key Capabilities:
Use this skill when:
Input required: Service to deploy (backend/frontend), issue description, or infrastructure task
Backend (Railway):
Frontend (Render):
Repositories:
┌─────────────────────────────────────────────────────────────┐
│ User Browser │
└───────────────────────┬─────────────────────────────────────┘
│ HTTPS
▼
┌─────────────────────────────────────────────────────────────┐
│ Render (Frontend - Static Site) │
│ https://gabedabe-frontend.onrender.com │
│ ├─ React SPA (built with Vite) │
│ ├─ Environment: VITE_API_URL │
│ └─ Auto-deploy on git push │
└───────────────────────┬─────────────────────────────────────┘
│ API Calls (CORS-enabled)
▼
┌─────────────────────────────────────────────────────────────┐
│ Railway (Backend - Web Service) │
│ https://gabedabe-production.up.railway.app │
│ ├─ Django REST API │
│ ├─ Gunicorn (2 workers) │
│ ├─ Environment: DJANGO_SETTINGS_MODULE=production │
│ └─ Auto-deploy on git push │
└───────────┬──────────────────────────┬──────────────────────┘
│ │
▼ ▼
┌───────────────┐ ┌──────────────┐
│ PostgreSQL │ │ Redis │
│ (Railway) │ │ (Railway) │
└───────────────┘ └──────────────┘
npm install -g @railway/cli# 1. Navigate to backend folder
cd C:/Projects/play/gabeda_backend
# 2. Initialize Railway project (first time only)
railway init
# 3. Add PostgreSQL
railway add --plugin postgresql
# 4. Add Redis
railway add --plugin redis
# 5. Set environment variables
railway variables --set DJANGO_SETTINGS_MODULE="config.settings.production"
railway variables --set DEBUG="False"
railway variables --set SECRET_KEY="your-secret-key-here"
railway variables --set ALLOWED_HOSTS="gabedabe-production.up.railway.app"
railway variables --set CORS_ALLOWED_ORIGINS="http://localhost:5173,https://gabedabe-frontend.onrender.com"
# 6. Deploy
railway up
railway.toml:
[build]
builder = "nixpacks"
[deploy]
startCommand = "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn config.wsgi:application --bind 0.0.0.0:$PORT --workers 2 --timeout 120"
runtime.txt:
python-3.11
Procfile:
web: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn config.wsgi:application --bind 0.0.0.0:$PORT --workers 2 --timeout 120
worker: celery -A config worker --loglevel=info --concurrency=2
| Variable | Value | Purpose |
|---|---|---|
DJANGO_SETTINGS_MODULE | config.settings.production | Load production settings |
SECRET_KEY | Random 50-char string | Django secret key |
DEBUG | False | Disable debug mode |
ALLOWED_HOSTS | gabedabe-production.up.railway.app | Allowed hostnames |
DATABASE_URL | Auto-provided by Railway | PostgreSQL connection |
REDIS_URL | Auto-provided by Railway | Redis connection |
CORS_ALLOWED_ORIGINS | http://localhost:5173,https://gabedabe-frontend.onrender.com | CORS whitelist |
Via Render Dashboard:
Brownbull/gabeda_frontendnpm run builddistVITE_API_URLhttps://gabedabe-production.up.railway.app/apirender.yaml (optional, for infrastructure-as-code):
services:
- type: web
name: gabedabe-frontend
env: static
buildCommand: npm run build
staticPublishPath: ./dist
envVars:
- key: VITE_API_URL
value: https://gabedabe-production.up.railway.app/api
public/_redirects (for React Router):
/* /index.html 200
| Variable | Value | Purpose |
|---|---|---|
VITE_API_URL | https://gabedabe-production.up.railway.app/api | Backend API URL |
VITE_APP_NAME | GabeDA | Application name |
Important: Vite injects environment variables at build time, so any changes require a rebuild!
Symptom: Browser console shows "blocked by CORS policy"
Diagnosis:
# Test CORS preflight
curl -v -X OPTIONS https://gabedabe-production.up.railway.app/api/accounts/auth/register/ \
-H "Origin: https://gabedabe-frontend.onrender.com" \
-H "Access-Control-Request-Method: POST"
Expected: Access-Control-Allow-Origin: https://gabedabe-frontend.onrender.com
Fixes:
Check CORS_ALLOWED_ORIGINS:
railway variables
# Should show: CORS_ALLOWED_ORIGINS=http://localhost:5173,https://gabedabe-frontend.onrender.com
Update if incorrect:
railway variables --set CORS_ALLOWED_ORIGINS="http://localhost:5173,https://gabedabe-frontend.onrender.com"
Common mistakes:
https://example.com/)http:// or https://Wait 30 seconds for Railway auto-redeploy after variable change
See: references/cors_troubleshooting.md
Symptom: Railway build fails with errors
Common Causes:
Python version mismatch:
runtime.txt specifies python-3.11requirements.txt for Python 3.12+ incompatibilitiesMissing dependencies:
# Test locally first
pip install -r requirements.txt
python manage.py check
Database migration failures:
python manage.py makemigrationsFix:
# Update requirements
pip freeze > requirements.txt
git add requirements.txt runtime.txt
git commit -m "fix: update dependencies"
git push
Symptom: API returns HTTP 500
Diagnosis:
Common fixes:
python manage.py migrateSymptom: Render build logs show TypeScript or npm errors
Diagnosis:
# Test locally
cd C:/Projects/play/gabeda_frontend
npm run build
Common Causes:
TypeScript errors:
Environment variable issues:
Fix:
# Fix TypeScript errors
npm run build # See errors
# Fix issues in code
git add .
git commit -m "fix: typescript errors"
git push # Render auto-rebuilds
Symptom: Frontend works locally but fails in production
Diagnosis:
Common Causes:
Wrong VITE_API_URL:
/api not /ap or /Needs rebuild:
Fix:
VITE_API_URLSymptom: Direct URL access returns 404
Cause: React Router needs all routes to serve index.html
Fix:
Create public/_redirects:
/* /index.html 200
Commit and push:
git add public/_redirects
git commit -m "fix: add redirects for react router"
git push
Access Logs:
Key Metrics:
Log Filtering:
# Railway CLI log streaming
railway logs --follow
# Filter for errors
railway logs | grep ERROR
# Filter by endpoint
railway logs | grep "/api/accounts"
Access Logs:
Key Metrics:
Chrome DevTools:
Both Railway and Render support auto-deploy on git push:
Developer → git push → GitHub → Webhook → Platform → Deploy
Current Configuration:
mainmainWorkflow:
git commit -m "description"git push origin mainBefore pushing to production:
npm run build for frontend)python manage.py check for backend)After deployment:
Vertical Scaling:
# Upgrade plan for more resources
# Railway Hobby: $5/month base + usage
# Includes: 512MB RAM, shared CPU
Horizontal Scaling:
# Add more Gunicorn workers (in railway.toml)
startCommand = "... gunicorn ... --workers 4" # Increase from 2
Database Optimization:
select_related() and prefetch_related()Caching:
Bundle Size Reduction:
# Analyze bundle
npm run build -- --analyze
# Code splitting
# Use React.lazy() for route-based splitting
Performance Improvements:
✅ Already Implemented:
🔄 TODO:
✅ Already Implemented:
🔄 TODO:
Backend (Railway):
Frontend (Render):
Total: ~$5-10/month
Backend:
Frontend:
Detailed guides in references/ folder:
Quick links:
DevOps operations must meet the DEVOPS_STANDARD.md criteria:
✅ Reliability (25%) - Services deployed successfully with <1% error rate ✅ Security (25%) - Proper secrets management, CORS, HTTPS enabled ✅ Observability (20%) - Logging and monitoring configured ✅ Documentation (15%) - Deployment steps documented and reproducible ✅ Automation (15%) - CI/CD pipelines configured
Minimum score: 8.0/10 before marking deployment complete.
See: DEVOPS_STANDARD.md
Version: 1.0.0 Last Updated: 2025-10-31 Skill Type: Infrastructure & Deployment Management