mirror of
https://github.com/thecyberlearn/quantum-ai-v3.git
synced 2026-08-18 14:52:58 +00:00
- 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.9 KiB
6.9 KiB
🚀 Railway.app Deployment Guide for Quantum Tasks AI
Overview
This guide will help you deploy your Quantum Tasks AI Django application to Railway.app. Your application is already optimized for Railway deployment with the existing railway.json configuration.
📋 Pre-Deployment Checklist
Required Accounts & Services
- GitHub account with your repository
- Railway.app account (free signup)
- Stripe account for payments (test/live keys)
- Gmail or SMTP service for emails
- N8N instance for AI agent webhooks
Code Verification
- Latest code pushed to GitHub
- All migrations created and committed
railway.jsonfile present in root directory- Environment variables documented in
.env.example
🔧 Step-by-Step Deployment
Step 1: Connect to Railway
- Visit railway.app and sign up/login
- Click "New Project" → "Deploy from GitHub repo"
- Select your
quantum_airepository - Railway will automatically detect Django and start building
Step 2: Configure Environment Variables
Navigate to your project settings and add these environment variables:
🔐 Security Settings
SECRET_KEY=your-50-character-secret-key-here
DEBUG=False
ALLOWED_HOSTS=your-domain.railway.app,quantumtaskai.com
CSRF_TRUSTED_ORIGINS=https://your-domain.railway.app,https://quantumtaskai.com
📧 Email Configuration
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-app-password
DEFAULT_FROM_EMAIL=Quantum Tasks AI <noreply@quantumtaskai.com>
💳 Stripe Configuration
STRIPE_SECRET_KEY=sk_live_your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
🤖 N8N Webhook URLs
N8N_WEBHOOK_DATA_ANALYZER=https://your-n8n.com/webhook/data-analyzer
N8N_WEBHOOK_FIVE_WHYS=https://your-n8n.com/webhook/five-whys
N8N_WEBHOOK_JOB_POSTING=https://your-n8n.com/webhook/job-posting
N8N_WEBHOOK_SOCIAL_ADS=https://your-n8n.com/webhook/social-ads
N8N_WEBHOOK_FAQ_GENERATOR=https://your-n8n.com/webhook/faq-generator
🗄️ Database Configuration
Railway automatically provides DATABASE_URL - no manual configuration needed!
⚡ Redis Configuration (Optional but Recommended)
REDIS_URL=redis://your-redis-url:6379
Step 3: Add PostgreSQL Database
- In your Railway project dashboard
- Click "New" → "Database" → "Add PostgreSQL"
- Railway automatically sets the
DATABASE_URLenvironment variable
Step 4: Add Redis (Recommended)
- Click "New" → "Database" → "Add Redis"
- Railway automatically sets the
REDIS_URLenvironment variable
Step 5: Custom Domain (Optional)
- Go to project Settings → Domains
- Add your custom domain (e.g.,
quantumtaskai.com) - Update DNS records as instructed by Railway
- Update
ALLOWED_HOSTSandCSRF_TRUSTED_ORIGINSenvironment variables
🔍 Post-Deployment Verification
Health Check
Visit your deployed application health endpoint:
https://your-domain.railway.app/health/
Expected response:
{
"status": "healthy",
"timestamp": 1234567890,
"version": "1.0",
"checks": {
"database": {"status": "healthy", "response_time_ms": 2.5},
"agents": {"status": "healthy", "active_count": 7}
},
"response_time_ms": 5.2
}
Application Testing
- Homepage loads correctly (
/) - User registration works (
/auth/register/) - Login functionality (
/auth/login/) - Marketplace displays agents (
/marketplace/) - Payment system functional (Stripe webhooks)
- Contact form submits successfully (
/contact/) - Admin panel accessible (
/admin/)
Monitoring Setup
- Application Logs: Available in Railway dashboard
- Health Monitoring: Set up external monitoring to ping
/health/ - Error Tracking: Monitor Railway application logs
- Database Performance: Use Railway's built-in database metrics
🚨 Troubleshooting
Common Issues & Solutions
Migration Errors
# If you see migration conflicts, check Railway logs
# Your railway.json already handles complex migrations
Static Files Not Loading
# Already handled by WhiteNoise configuration
# Verify STATIC_URL and STATIC_ROOT in settings
Environment Variable Issues
# Check Railway project settings
# Ensure all required variables are set
# Restart deployment after adding variables
Database Connection Issues
# Verify PostgreSQL service is running in Railway
# Check DATABASE_URL is automatically set
# Review connection logs in Railway dashboard
📊 Cost Estimation
Railway.app Pricing (Monthly)
- Web Service: $5/month (scales with usage)
- PostgreSQL: $5/month (1GB storage, scales up)
- Redis: $5/month (256MB, scales up)
- Bandwidth: $0.10/GB (generous free tier)
Total Estimated Cost: $15-25/month for production usage
Scaling Thresholds
- Free Tier: Good for development and testing
- Scale Up: When you hit 1000+ daily active users
- Database: Scales automatically with your data growth
🔒 Security Best Practices
Environment Variables
- Never commit real environment variables to Git
- Use Railway's environment variable encryption
- Rotate API keys regularly (Stripe, email, N8N)
Domain Security
- Always use HTTPS (Railway provides SSL automatically)
- Configure proper CORS settings
- Monitor your
/health/endpoint for unauthorized access
Database Security
- Railway PostgreSQL is automatically encrypted
- Enable database backups (Railway provides automatic backups)
- Monitor database performance and queries
📈 Performance Optimization
Railway-Specific Optimizations
- Region Selection: Choose region closest to your users
- Resource Allocation: Monitor CPU/memory usage in dashboard
- Caching: Redis is automatically configured for session caching
- Static Files: WhiteNoise serves static files efficiently
Monitoring & Alerts
- Set up monitoring for your
/health/endpoint - Configure alerts for high error rates
- Monitor database performance metrics
- Track user registration and payment success rates
🎉 Success!
Once deployed successfully, your Quantum Tasks AI application will be live at:
- Production URL:
https://your-domain.railway.app - Custom Domain:
https://quantumtaskai.com(if configured) - Health Check:
https://your-domain.railway.app/health/ - Admin Panel:
https://your-domain.railway.app/admin/
Your AI agent marketplace is now ready to serve users worldwide! 🌍
📞 Support
If you encounter issues:
- Check Railway application logs first
- Verify all environment variables are set correctly
- Test the
/health/endpoint for system status - Review this deployment guide for common solutions
Railway.app provides excellent documentation and support for Django applications.