- Add comprehensive deployment guide with step-by-step instructions - Create environment variables template with security guidelines - Implement production health check endpoint at /health/ - Add Railway-specific production optimizations and database pooling - Create post-deployment verification checklist (10 phases, 100+ checkpoints) - Optimize railway.json with Gunicorn production settings and health checks - Configure automatic SMTP backend switching for production/development - Add custom 404/500 error pages for professional user experience - Enhance environment variable validation for production requirements Deployment Features: • Complete Railway.app integration with zero-config deployment • Production-ready health monitoring and logging • Database connection pooling and performance optimization • Comprehensive security validation and environment checks • Professional error handling and user experience Ready for Production: • All Django security checks pass ✅ • Environment variables properly validated ✅ • Health check endpoint functional ✅ • Railway.json optimized for production ✅ • Complete documentation and verification guides ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6.1 KiB
🔐 Railway Environment Variables Template
Required Environment Variables for Production Deployment
Copy these environment variables to your Railway project settings. Replace placeholder values with your actual production values.
🔒 Core Security Settings
# Django Security
SECRET_KEY=django-insecure-REPLACE-WITH-50-RANDOM-CHARACTERS-FOR-PRODUCTION
DEBUG=False
ALLOWED_HOSTS=your-project-name.railway.app,quantumtaskai.com,www.quantumtaskai.com
CSRF_TRUSTED_ORIGINS=https://your-project-name.railway.app,https://quantumtaskai.com,https://www.quantumtaskai.com
📧 Email Configuration (Gmail Example)
# Email Settings - Use Gmail App Password or SMTP service
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-16-character-app-password
DEFAULT_FROM_EMAIL=Quantum Tasks AI <noreply@quantumtaskai.com>
💳 Stripe Payment Configuration
# Stripe - Use LIVE keys for production
STRIPE_SECRET_KEY=sk_live_your_stripe_secret_key_here
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_endpoint_secret
🤖 N8N AI Agent Webhooks
# N8N Webhook URLs - Replace with your N8N instance
N8N_WEBHOOK_DATA_ANALYZER=https://your-n8n-instance.com/webhook/data-analyzer
N8N_WEBHOOK_FIVE_WHYS=https://your-n8n-instance.com/webhook/five-whys
N8N_WEBHOOK_JOB_POSTING=https://your-n8n-instance.com/webhook/job-posting
N8N_WEBHOOK_SOCIAL_ADS=https://your-n8n-instance.com/webhook/social-ads
N8N_WEBHOOK_FAQ_GENERATOR=https://your-n8n-instance.com/webhook/faq-generator
🌤️ External API Keys
# OpenWeather API for Weather Agent
OPENWEATHER_API_KEY=your_openweather_api_key_here
⚡ Performance & Caching (Optional)
# Redis URL - Automatically set by Railway Redis service
# REDIS_URL=redis://default:password@host:port
🔍 Environment Variable Setup Instructions
Step 1: Generate SECRET_KEY
Use Django to generate a secure secret key:
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
Step 2: Gmail App Password Setup
- Enable 2-Factor Authentication on your Gmail account
- Go to Google Account Settings → Security → App passwords
- Generate an app password for "Django Email"
- Use the 16-character app password (not your regular password)
Step 3: Stripe Configuration
- Login to your Stripe Dashboard
- Go to Developers → API Keys
- Copy your "Secret key" (starts with
sk_live_for production) - Go to Developers → Webhooks
- Create webhook endpoint:
https://your-domain.railway.app/wallet/stripe/webhook/ - Copy the webhook signing secret (starts with
whsec_)
Step 4: N8N Webhook URLs
- Deploy your N8N instance (can use Railway, Heroku, or self-hosted)
- Create workflows for each AI agent
- Copy the webhook URLs from each workflow
- Ensure N8N workflows are active and accessible
Step 5: OpenWeather API
- Sign up at OpenWeatherMap
- Get your free API key
- Add it to the environment variables
🚫 Important Security Notes
Never Include in Git:
- ❌ Real SECRET_KEY values
- ❌ Production API keys
- ❌ Email passwords
- ❌ Stripe live keys
- ❌ Database credentials
Railway Automatic Variables:
Railway automatically provides these - DO NOT SET MANUALLY:
DATABASE_URL(PostgreSQL connection string)PORT(Application port)RAILWAY_*(Railway-specific variables)
Testing Configuration:
Use Railway's "Preview" deployments to test environment variables before going live.
📋 Environment Variable Checklist
Before deploying, verify you have set:
Core Settings ✓
SECRET_KEY(50+ random characters)DEBUG=FalseALLOWED_HOSTS(includes your Railway domain)CSRF_TRUSTED_ORIGINS(HTTPS URLs only)
Email Configuration ✓
EMAIL_HOST_USER(your Gmail address)EMAIL_HOST_PASSWORD(Gmail app password)DEFAULT_FROM_EMAIL(your sender email)
Payment System ✓
STRIPE_SECRET_KEY(live key for production)STRIPE_WEBHOOK_SECRET(webhook endpoint secret)
AI Agents ✓
- All
N8N_WEBHOOK_*URLs are accessible OPENWEATHER_API_KEY(for weather agent)
External Services ✓
- PostgreSQL database added to Railway project
- Redis service added (optional but recommended)
- Custom domain configured (if applicable)
🔧 Advanced Configuration
Production-Ready Gunicorn Settings
The railway.json includes optimized Gunicorn configuration:
- 2 workers (scales with CPU cores)
- 120-second timeout for AI processing
- Request recycling for memory management
- Health check integration
Database Connection Pooling
Railway's PostgreSQL automatically handles connection pooling for optimal performance.
Static Files & CDN
WhiteNoise configuration in your Django settings handles static file serving efficiently.
🎯 Environment Variable Testing
After setting variables in Railway:
- Deploy Application: Railway will automatically deploy with new variables
- Check Health Endpoint:
https://your-domain.railway.app/health/ - Test Authentication: Try user registration and login
- Verify Payments: Test Stripe integration (use test cards)
- Check AI Agents: Test each agent workflow
- Monitor Logs: Watch Railway application logs for errors
🆘 Troubleshooting
Common Issues:
Secret Key Error:
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty
→ Ensure SECRET_KEY is set and not empty
Email Authentication Failed:
SMTPAuthenticationError: Username and Password not accepted
→ Use Gmail App Password, not regular password
Stripe Webhook Verification Failed:
stripe.error.SignatureVerificationError
→ Verify webhook secret matches Stripe dashboard
N8N Webhook Not Responding:
requests.exceptions.ConnectionError
→ Ensure N8N instance is running and accessible
This template ensures your Quantum Tasks AI application runs securely and efficiently on Railway.app! 🚀