Spaces:
Sleeping
Sleeping
A newer version of the Streamlit SDK is available:
1.54.0
π 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
# 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
# 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
# 1. Install Vercel CLI
npm i -g vercel
# 2. Deploy
vercel
# 3. Follow prompts and get your URL
Option 4: Railway Deployment
Steps
# 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
# 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:
- Enable caching: Redis configured in docker-compose
- Database optimization: PostgreSQL with proper indexing
- Load balancing: Multiple worker processes
- 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:
Port already in use
# Change port in docker-compose.yml or .env PORT=8051Database connection failed
# Check DATABASE_URL in .env # Ensure database is runningML model training fails
# Check data format # Increase memory allocation
π Support
For deployment issues:
- Check logs:
docker-compose logs dashboard - Verify environment variables
- Ensure all dependencies are installed
- Check system requirements
Your AI-Powered Shipment Route Optimization System is ready for production! π