Skip to content

Latest commit

Β 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

⚑ OptiGuide β€” Logistics Intelligence Platform

AI-powered supply-chain optimization and what-if scenario analysis for coffee distribution across India.

OptiGuide is a full-stack logistics optimization system that combines Gurobi's industrial-grade LP/MIP solver with OpenAI-powered natural-language what-if analysis to help supply chain managers find the least-cost distribution strategy β€” and instantly see how it changes under various disruption scenarios.


πŸ“Έ Overview

Feature Description
πŸ—ΊοΈ Interactive Route Map Real-time visualization of optimized supply routes on a dark-themed Leaflet map centered on India
πŸ“Š Cost Breakdown Charts Doughnut chart segmentation of shipping, roasting, and management costs
πŸ§ͺ What-If Scenarios AI-driven scenario simulation β€” ask natural language questions like "What if Supplier 1 capacity increases by 50%?"
πŸ“ Point-to-Point Routing Calculate logistics cost for specific originβ†’destination lanes
βš™οΈ Parameter Tuning Sliders for supplier capacity, cafe demand, and cost multipliers
πŸ”– Quick Presets One-click scenario presets (Baseline, High Demand, Cost Shock, Cap Cut)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND (Static)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Leaflet  β”‚  β”‚ Chart.js β”‚  β”‚  Lucide   β”‚  β”‚  Vanilla  β”‚  β”‚
β”‚  β”‚   Map    β”‚  β”‚ Doughnut β”‚  β”‚  Icons    β”‚  β”‚  CSS/JS   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚              index.html Β· app.js Β· style.css                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚  HTTP (JSON) β€” port 8000
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  BACKEND (FastAPI)                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  main.py β€” REST API                                  β”‚   β”‚
β”‚  β”‚  β”œβ”€β”€ POST /optimize   β†’ run optimization query       β”‚   β”‚
β”‚  β”‚  β”œβ”€β”€ GET  /health     β†’ backend status               β”‚   β”‚
β”‚  β”‚  β”œβ”€β”€ GET  /api-check  β†’ OpenAI key validation        β”‚   β”‚
β”‚  β”‚  └── GET  /services   β†’ available service list       β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  optiguide_service.py β€” Core Logic                   β”‚   β”‚
β”‚  β”‚  β”œβ”€β”€ Gurobi LP Model (coffee distribution)           β”‚   β”‚
β”‚  β”‚  β”œβ”€β”€ OptiGuide Agent (AutoGen + OpenAI)              β”‚   β”‚
β”‚  β”‚  └── Mock Mode (offline testing)                     β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🌐 Supply Chain Network

The system models a 3-tier coffee supply chain across Indian cities:

Tier Nodes Cities
Suppliers 3 Delhi, Mumbai, Kolkata
Roasteries 2 Bengaluru, Hyderabad
Cafes 3 Chennai, Pune, Ahmedabad

The optimizer finds the minimum-cost flow from suppliers β†’ roasteries β†’ cafes while respecting capacity constraints and demand requirements for both light and dark coffee variants.


πŸš€ Getting Started

Prerequisites

  • Python 3.10+
  • Gurobi Optimizer (with a valid license β€” free academic licenses available at gurobi.com)
  • OpenAI API Key (for AI-powered what-if analysis; optional if using Mock Mode)

1. Clone the Repository

git clone https://github.com/<your-username>/logistic-optimization-system.git
cd logistic-optimization-system

2. Set Up the Backend

cd backend

# Create and activate virtual environment
python -m venv venv

# Windows
venv\Scripts\activate
# Linux/macOS
source venv/bin/activate

# Install dependencies
pip install fastapi uvicorn python-dotenv openai pydantic gurobipy pyautogen

3. Configure Environment Variables

Create a .env file in the backend/ directory:

OPENAI_API_KEY=sk-your-openai-api-key-here
MOCK_MODE=false

Tip

Set MOCK_MODE=true to run the system without an OpenAI API key or Gurobi license. The backend will return realistic pre-computed scenarios for testing and demonstration.

4. Start the Server

cd backend
uvicorn main:app --reload --host 0.0.0.0 --port 8000

5. Open the Dashboard

Navigate to http://localhost:8000 in your browser. The frontend is served as static files by the FastAPI backend β€” no separate build step required.


πŸ“‚ Project Structure

logistic-optimization-system/
β”‚
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                     # FastAPI application & API routes
β”‚   β”œβ”€β”€ .env                        # Environment variables (API keys, mode)
β”‚   β”œβ”€β”€ test_optimize.py            # Quick API test script
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── optiguide_service.py    # Core optimization logic & mock engine
β”‚   β”œβ”€β”€ optiguide/                  # OptiGuide library (AutoGen agent)
β”‚   β”‚   └── what-if/                # What-if scenario analysis module
β”‚   └── venv/                       # Python virtual environment
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html                  # Main dashboard UI
β”‚   β”œβ”€β”€ style.css                   # Full design system (glassmorphism, dark theme)
β”‚   β”œβ”€β”€ app.js                      # Application logic (map, charts, API calls)
β”‚   └── components.js               # Reusable UI component templates
β”‚
└── README.md                       # This file

πŸ”Œ API Reference

POST /optimize

Run an optimization query with optional parameter overrides.

Request Body:

{
  "question": "What if Supplier 1 capacity increases by 50%?",
  "params": {
    "capacity": { "supplier1": 225, "supplier2": 50, "supplier3": 100 },
    "demand": {
      "cafe1": { "light": 20, "dark": 20 },
      "cafe2": { "light": 30, "dark": 20 },
      "cafe3": { "light": 40, "dark": 100 }
    },
    "multipliers": { "shipping": 1.0, "roasting": 1.0 }
  }
}

Response:

{
  "cost": 685.2,
  "breakdown": { "shipping": 342.6, "roasting": 205.6, "management": 137.0 },
  "routes": [
    { "from": "supplier1", "to": "roastery1", "volume": 90, "cost": 450 },
    { "from": "roastery2", "to": "cafe3", "volume": 110, "cost": 220 }
  ],
  "explanation": "Expanding Supplier 1 capacity enables higher Bengaluru throughput...",
  "mode": "mock"
}

GET /health

Returns backend status and engine info.

{ "status": "ok", "mode": "mock", "engine": "OptiGuide + Gurobi", "version": "2.0.0" }

GET /api-check

Validates the configured OpenAI API key.

{ "valid": true, "mode": "production", "model_count": 42 }

GET /services

Lists all available optimization services.

{
  "mode": "mock",
  "services": [
    { "id": "route_opt", "name": "Route Optimization", "description": "Find least-cost shipping paths", "available": true },
    { "id": "what_if", "name": "What-If Analysis", "description": "AI-powered scenario simulation", "available": true }
  ]
}

πŸ§ͺ Running Tests

cd backend

# Quick endpoint test
python test_optimize.py

Ensure the server is running on localhost:8000 before executing the test script.


βš™οΈ Operating Modes

Mode MOCK_MODE Requirements Description
Production false OpenAI API key + Gurobi license Full AI-powered optimization with real Gurobi solver
Mock true None Pre-computed scenario responses for demo/testing

πŸ› οΈ Tech Stack

Layer Technology Purpose
Backend Framework FastAPI High-performance REST API
Optimization Solver Gurobi (gurobipy) Linear/Mixed-Integer Programming
AI Agent AutoGen + OpenAI GPT Natural-language what-if queries
Map Visualization Leaflet.js Interactive route map
Charts Chart.js Cost breakdown doughnut chart
Icons Lucide Consistent, lightweight SVG icons
Typography Inter + Outfit Modern, clean UI fonts
Styling Vanilla CSS Glassmorphism dark theme with custom animations

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is built on top of the OptiGuide framework by Microsoft Research, licensed under the MIT License.


Built with ❀️ using FastAPI, Gurobi, and OpenAI

Releases

Packages

Contributors

Languages