Spaces:
Sleeping
Sleeping
| # π Deployment Guide | |
| ## AI-Powered Shipment Route Optimization System | |
| **Created by: Zayeem Khateeb** | |
| ## π Deployment Options | |
| ### Option 1: Docker Deployment (Recommended) | |
| #### Prerequisites | |
| - Docker and Docker Compose installed | |
| - 4GB RAM minimum | |
| - 10GB disk space | |
| #### Steps | |
| ```bash | |
| # 1. Build and run with Docker Compose | |
| docker-compose up -d | |
| # 2. Access your application | |
| http://localhost:8050 | |
| # 3. View logs | |
| docker-compose logs -f dashboard | |
| # 4. Stop deployment | |
| docker-compose down | |
| ``` | |
| ### Option 2: Cloud Deployment (Heroku) | |
| #### Prerequisites | |
| - Heroku CLI installed | |
| - Git repository | |
| #### Steps | |
| ```bash | |
| # 1. Login to Heroku | |
| heroku login | |
| # 2. Create Heroku app | |
| heroku create your-shipment-optimizer | |
| # 3. Set environment variables | |
| heroku config:set FLASK_ENV=production | |
| heroku config:set SECRET_KEY=your-secret-key | |
| # 4. Deploy | |
| git add . | |
| git commit -m "Deploy AI Shipment Optimizer" | |
| git push heroku main | |
| # 5. Open your app | |
| heroku open | |
| ``` | |
| ### Option 3: Vercel Deployment | |
| #### Prerequisites | |
| - Vercel CLI or GitHub integration | |
| #### Steps | |
| ```bash | |
| # 1. Install Vercel CLI | |
| npm i -g vercel | |
| # 2. Deploy | |
| vercel | |
| # 3. Follow prompts and get your URL | |
| ``` | |
| ### Option 4: Railway Deployment | |
| #### Steps | |
| ```bash | |
| # 1. Install Railway CLI | |
| npm install -g @railway/cli | |
| # 2. Login | |
| railway login | |
| # 3. Deploy | |
| railway up | |
| # 4. Get your URL | |
| railway domain | |
| ``` | |
| ### Option 5: Local Production Server | |
| #### Steps | |
| ```bash | |
| # 1. Install production server | |
| pip install gunicorn | |
| # 2. Run production server | |
| gunicorn -w 4 -b 0.0.0.0:8050 deploy:app | |
| # 3. Access at http://localhost:8050 | |
| ``` | |
| ## π§ Environment Variables | |
| Create `.env` file with: | |
| ``` | |
| # Database | |
| DATABASE_URL=your_database_url | |
| # API Keys | |
| OPENWEATHER_API_KEY=your_weather_api_key | |
| GOOGLE_MAPS_API_KEY=your_maps_api_key | |
| # Security | |
| SECRET_KEY=your-secret-key-here | |
| # App Config | |
| FLASK_ENV=production | |
| PORT=8050 | |
| ``` | |
| ## π Performance Optimization | |
| ### For Production: | |
| 1. **Enable caching**: Redis configured in docker-compose | |
| 2. **Database optimization**: PostgreSQL with proper indexing | |
| 3. **Load balancing**: Multiple worker processes | |
| 4. **Monitoring**: Built-in health checks | |
| ### Scaling: | |
| - **Horizontal**: Multiple container instances | |
| - **Vertical**: Increase CPU/RAM allocation | |
| - **Database**: Separate database server | |
| ## π Security Checklist | |
| - β Environment variables for secrets | |
| - β Non-root Docker user | |
| - β HTTPS in production (handled by platform) | |
| - β Input validation and sanitization | |
| - β Database connection security | |
| ## π Monitoring | |
| ### Health Check Endpoint: | |
| ``` | |
| GET /health | |
| ``` | |
| ### Metrics Available: | |
| - Total shipments processed | |
| - ML model accuracy | |
| - Response times | |
| - Error rates | |
| ## π Troubleshooting | |
| ### Common Issues: | |
| 1. **Port already in use** | |
| ```bash | |
| # Change port in docker-compose.yml or .env | |
| PORT=8051 | |
| ``` | |
| 2. **Database connection failed** | |
| ```bash | |
| # Check DATABASE_URL in .env | |
| # Ensure database is running | |
| ``` | |
| 3. **ML model training fails** | |
| ```bash | |
| # Check data format | |
| # Increase memory allocation | |
| ``` | |
| ## π Support | |
| For deployment issues: | |
| 1. Check logs: `docker-compose logs dashboard` | |
| 2. Verify environment variables | |
| 3. Ensure all dependencies are installed | |
| 4. Check system requirements | |
| Your AI-Powered Shipment Route Optimization System is ready for production! π | |