- Add N8N workflow directory structure for webhook-based agents - Create workflow management scripts (import/export/sync/backup) - Add comprehensive documentation for each agent's workflow setup - Clarify N8N deployment architecture (separate hosting from Django) - Update deployment guides with clear separation warnings - Add workflow deployment automation scripts Architecture clarification: - Django app deploys to Railway - N8N runs separately (N8N Cloud, separate Railway project, or self-hosted) - Communication via HTTP webhook URLs only 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
7.2 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 (External Server URLs)
⚠️ IMPORTANT: These URLs point to your SEPARATE N8N instance, NOT hosted on Railway with Django.
# N8N Webhook URLs - Replace with your actual N8N instance URLs
# Option A: N8N Cloud
N8N_WEBHOOK_DATA_ANALYZER=https://yourworkspace.app.n8n.cloud/webhook/data-analyzer
N8N_WEBHOOK_FIVE_WHYS=https://yourworkspace.app.n8n.cloud/webhook/five-whys
N8N_WEBHOOK_JOB_POSTING=https://yourworkspace.app.n8n.cloud/webhook/job-posting
N8N_WEBHOOK_SOCIAL_ADS=https://yourworkspace.app.n8n.cloud/webhook/social-ads
# Option B: Self-hosted or separate Railway N8N project
# N8N_WEBHOOK_DATA_ANALYZER=https://your-n8n-server.com/webhook/data-analyzer
# N8N_WEBHOOK_FIVE_WHYS=https://your-n8n-server.com/webhook/five-whys
# N8N_WEBHOOK_JOB_POSTING=https://your-n8n-server.com/webhook/job-posting
# N8N_WEBHOOK_SOCIAL_ADS=https://your-n8n-server.com/webhook/social-ads
🌤️ 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 (Separate Server)
⚠️ N8N RUNS SEPARATELY from your Django app. Choose one hosting option:
Option A: N8N Cloud (Easiest)
- Sign up at n8n.cloud
- Import your workflow JSON files from agent directories
- Configure OpenAI API credentials in N8N
- Copy webhook URLs from each workflow
- Add URLs to Railway environment variables
Option B: Separate Railway Project for N8N
- Create a NEW Railway project (different from your Django app)
- Deploy N8N using Railway's template or Docker
- Import workflows and configure credentials
- Copy webhook URLs and add to Django app environment
Option C: Self-Hosted N8N
- Deploy N8N on DigitalOcean, AWS, VPS, or local server
- Ensure server is publicly accessible for webhook calls
- Import workflows and get webhook URLs
- 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! 🚀