Deployment Architecture
Tesis Rutas consists of two separate applications:Backend
FastAPI application that needs a Python-compatible hosting service
Frontend
React + Vite application that can be deployed to static hosting
Prerequisites
Before deploying, ensure you have:Configuration ready
All environment variables configured (see Configuration guide)
External services active
- MongoDB Atlas cluster running
- Cloudinary account configured
- JWT secret key generated
Backend Deployment
The FastAPI backend can be deployed to various platforms that support Python applications.Deployment Options
- Railway
- Render
- Heroku
- Docker
Railway provides easy deployment for Python applications.
Add environment variables
In the Railway dashboard, add all required environment variables:
MONGO_URIMONGO_DBCLOUDINARY_CLOUD_NAMECLOUDINARY_API_KEYCLOUDINARY_API_SECRETJWT_SECRET_KEYJWT_ALGORITHMJWT_EXPIRE_MINUTES
Railway provides a free tier with 500 hours/month, perfect for small projects.
Verify Backend Deployment
After deployment, test your backend:Frontend Deployment
The React frontend is a static site that can be deployed to various hosting platforms.Update API Base URL
Before building, update the API endpoint in your frontend configuration to point to your deployed backend:Deployment Options
- Vercel (Recommended)
- Netlify
- GitHub Pages
Vercel is optimized for React and Vite applications.Follow the prompts:
Deploy to Vercel
- Set up and deploy? Yes
- Which scope? Select your account
- Link to existing project? No
- Project name: tesis-rutas
- Directory: ./frontend
- Override build settings? No
Vercel automatically detects Vite projects and configures the build settings. The default domain will be
https://tesis-rutas.vercel.app.Post-Deployment Configuration
After deploying both frontend and backend:Update CORS settings
Update the allowed origins in Redeploy the backend after making this change.
src/infrastructure/api/main.py:Test the full application
- Visit your frontend URL
- Test user authentication
- Test route creation and destination management
- Verify image uploads work correctly
Environment-Specific Settings
Monitoring and Maintenance
Health Checks
Monitor your deployment health:Common Issues
CORS errors in production
CORS errors in production
Problem: Frontend can’t connect to backend due to CORS policySolution:
- Verify your frontend URL is added to the
originslist insrc/infrastructure/api/main.py - Ensure you redeploy the backend after updating CORS settings
- Check that the frontend is using HTTPS (not HTTP) if the backend uses HTTPS
Environment variables not loading
Environment variables not loading
Problem: Application can’t find configuration in productionSolution:
- Verify all environment variables are set in your hosting platform’s dashboard
- Check for typos in variable names (they are case-sensitive)
- Restart your application after adding environment variables
Database connection fails
Database connection fails
Problem: Can’t connect to MongoDB Atlas from productionSolution:
- Whitelist your hosting provider’s IP addresses in MongoDB Atlas
- Or allow access from anywhere (0.0.0.0/0) for testing
- Verify the MongoDB URI is correct and includes credentials
Build fails on deployment
Build fails on deployment
Problem: Frontend or backend build fails during deploymentSolution:
- Check build logs for specific errors
- Ensure all dependencies are listed in
requirements.txtorpackage.json - Verify Python/Node.js versions match your local environment
Scaling Considerations
As your application grows:Database indexing
Add indexes to MongoDB collections for better query performance
CDN for media
Cloudinary automatically provides CDN for images
Caching
Implement Redis for session/data caching
Load balancing
Use multiple backend instances with a load balancer
Rollback Strategy
If a deployment fails:Next Steps
Monitor logs
Set up logging and monitoring for your production application
Backup strategy
Implement regular MongoDB backups using Atlas automated backups
CI/CD
Set up automated deployments with GitHub Actions or similar
Performance testing
Use tools like Lighthouse to test frontend performance