AIGreenPath / DEPLOYMENT_GUIDE.md
Zayeemk's picture
Upload 26 files
18935fc verified

A newer version of the Streamlit SDK is available: 1.54.0

Upgrade

πŸš€ 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:

  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

    # Change port in docker-compose.yml or .env
    PORT=8051
    
  2. Database connection failed

    # Check DATABASE_URL in .env
    # Ensure database is running
    
  3. ML model training fails

    # 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! πŸŽ‰