File size: 28,650 Bytes
2960a99 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 0076060 fcf8749 2960a99 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | ---
tags:
- ml-intern
---
<p align="center">
<img src="https://img.shields.io/badge/Challenge-%235_AI_Load_Consolidation-f97316?style=for-the-badge" alt="Challenge #5" />
<img src="https://img.shields.io/badge/LogisticsNow-Hackathon_2026-3b82f6?style=for-the-badge" alt="LogisticsNow" />
<img src="https://img.shields.io/badge/Team-FairRelay-10b981?style=for-the-badge" alt="Team FairRelay" />
</p>
<h1 align="center">FairRelay</h1>
<p align="center">
<strong>AI-Powered Load Consolidation Engine · Fairness-Aware Route Allocation · Multi-Agent Intelligence</strong>
</p>
<p align="center">
<a href="#-the-problem">Problem</a> •
<a href="#-our-solution">Solution</a> •
<a href="#-5-agent-consolidation-pipeline">Consolidation Pipeline</a> •
<a href="#-fair-dispatch-pipeline">Fair Dispatch</a> •
<a href="#-architecture">Architecture</a> •
<a href="#-dashboards--visualization">Dashboards</a> •
<a href="#-quick-start">Quick Start</a> •
<a href="#-api-reference">API Reference</a>
</p>
---
## The Problem
> Logistics networks transport shipments with **partially filled vehicles** due to poor load planning. There is **no AI-driven system** for automatic load consolidation that intelligently groups shipments, maximizes vehicle capacity, simulates strategies, and learns continuously.
>
> At the same time, **15M+ gig delivery workers** in India face systemic dispatch bias β traditional systems assign **3x more deliveries** to some drivers (Gini = 0.85) while others earn near nothing.
**FairRelay solves both.**
---
## Our Solution
FairRelay is a **full-stack AI logistics platform** with two core engines:
| Engine | What It Does | Agents |
|--------|-------------|--------|
| **Load Consolidation Engine** | Groups shipments by geography + time windows, bin-packs into trucks using OR-Tools CP-SAT solver, scores confidence, and learns via Q-Learning | 5 agents |
| **Fair Dispatch Engine** | Allocates routes to drivers using fairness-aware AI with Gini coefficient optimization, wellness tracking, EV-aware routing, and LLM explanations | 8+ agents |
Both engines are orchestrated via **LangGraph** multi-agent workflows, exposed as single API endpoints, and come with live visualization dashboards.
### Hackathon Deliverables Mapping
| Expected Deliverable | Our Implementation |
|---------------------|-------------------|
| **Consolidation Engine Prototype** | 5-agent LangGraph pipeline β KMeans geo-clustering + OR-Tools CP-SAT bin-packing |
| **Visualization Dashboard** | Interactive dark-themed dashboard with Leaflet maps, Chart.js analytics, agent pipeline viz, heatmaps |
| **Performance Simulation** | Multi-scenario simulator comparing Tight/Balanced/Aggressive strategies with full KPI comparison |
| **Continuous Optimization** | Tabular Q-Learning agent with file-based experience store, reward function, and policy recommendation |
---
## 5-Agent Consolidation Pipeline
```
POST /api/v1/consolidate β One API call. Five agents. Optimized loads.
```
```
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β AGENT 1 β β AGENT 2 β β AGENT 3 β
β Geo-Clustering ββββ>β Time-Window ββββ>β Capacity β
β (KMeans + β β Filtering β β Optimization β
β Silhouette) β β (Overlap check) β β (OR-Tools SAT) β
ββββββββββββββββββββ ββββββββββββββββββββ ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ ββββββββββββββββββββ
β AGENT 5 β β AGENT 4 β
β Continuous β<ββββ Scoring & β
β Learning β β Confidence β
β (Q-Learning) β β (Composite AI) β
ββββββββββββββββββββ ββββββββββββββββββββ
```
### Agent Breakdown
| # | Agent | Algorithm | What It Does |
|---|-------|-----------|-------------|
| 1 | **Geo-Clustering** | scikit-learn KMeans + Silhouette scoring | Groups shipments by pickup/drop proximity. Auto-selects optimal K (2β10). Splits oversized clusters via greedy radius fallback. |
| 2 | **Time-Window** | Interval overlap analysis | Filters clusters by delivery time compatibility. Configurable tolerance (default 120 min). Splits time-incompatible shipments into separate groups. |
| 3 | **Capacity Optimization** | Google OR-Tools CP-SAT Integer Programming | Bin-packs shipments into trucks respecting weight + volume. Minimizes trucks used. Falls back to First-Fit-Decreasing heuristic if solver unavailable. 3-second solver timeout. |
| 4 | **Scoring & Confidence** | Weighted composite scoring | Per-group confidence = `capFitΓ0.4 + geoScoreΓ0.35 + timeScoreΓ0.25`. Global optimization score factors in utilization, trip reduction, and improvement gain. Computes all KPIs vs naive baseline. |
| 5 | **Continuous Learning** | Tabular Q-Learning (RL) | Stores experience in `data/rl_experience.json` (max 500 episodes). Reward = f(utilization, trips, carbon, score). Updates Q-table to recommend optimal (radius, tolerance) parameters. Detects policy convergence/degradation trends. |
### Consolidation KPIs Produced
| KPI | Description |
|-----|-------------|
| Vehicle Utilization (Before/After) | Percentage improvement from naive to consolidated |
| Trips Reduced | Absolute count + percentage of eliminated trips |
| Distance Saved (km) | Haversine-calculated route distance reduction |
| CO2 Saved (kg) | `distanceSaved Γ 0.21 kg/km` |
| Carbon Credit Value (USD) | `carbonSaved / 1000 Γ $25/ton` |
| Fuel Saved (INR) | `distanceSaved Γ Rs.22.5/km` |
| Cost Reduction (%) | Direct cost savings from trip elimination |
| Optimization Score (0β100) | Weighted composite with letter grade (A+/A/B/C/D) |
| Avg AI Confidence (0β100) | Mean per-group confidence across all bins |
### Scenario Simulation
```
POST /api/v1/consolidate/simulate
```
Run multiple consolidation strategies in parallel and get the best recommendation:
| Scenario | Radius | Time Tolerance | Use Case |
|----------|--------|---------------|----------|
| **Tight Clustering** | 15 km | 60 min | Dense urban, strict deadlines |
| **Balanced** | 30 km | 120 min | General purpose |
| **Aggressive Merge** | 60 km | 240 min | Inter-city, flexible windows |
The system runs all scenarios, compares optimization scores, and recommends the best strategy.
---
## Fair Dispatch Pipeline
```
POST /api/v1/allocate/langgraph β Fairness-aware route allocation
```
```
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Initialize β β β Clustering β β β ML Effort β
β Node β β Agent (KMeans) β β Agent (XGBoost)β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β EV Recovery β β β Fairness β β β Route Planner β
β Node β β Manager β β (Hungarian) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ (if Gini > 0.25)
βββββββββββββββββββ βββββββββββββββββββ
β Driver Liaison β β Reoptimize β
β Agent β β Loop β
βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Learning β β β LLM Explain β β β Finalize β
β Agent β β (Gemini) β β Node β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
```
| Agent | Purpose | Key Algorithm |
|-------|---------|---------------|
| **Initialize Node** | Validates inputs, sets up allocation state | Schema validation |
| **Clustering Agent** | Groups packages by geography | K-Means |
| **ML Effort Agent** | Scores driver-route effort pairs | XGBoost |
| **Route Planner** | Solves optimal driver-route assignment | Hungarian Algorithm |
| **Fairness Manager** | Evaluates workload inequality | Gini Index (threshold: 0.25) |
| **EV Recovery Node** | Handles electric vehicle battery constraints | Charging station insertion |
| **Driver Liaison** | Processes driver negotiations/appeals | Rule-based + AI |
| **Learning Agent** | Improves future allocations from feedback | Feedback loop |
| **LLM Explain Node** | Generates natural language explanations | Google Gemini |
### Fairness Algorithms
**Workload Score:**
```
workload = a Γ num_packages + b Γ total_weight_kg + c Γ route_difficulty + d Γ estimated_time
```
**Gini Index** (0 = perfect equality, 1 = maximum inequality):
```
G = (2 Γ Ξ£(i Γ x_i)) / (n Γ Ξ£x_i) β (n + 1) / n
```
**Individual Fairness Score:**
```
fairness_score = 1 β |workload β avg_workload| / max(avg_workload, 1)
```
Key Result: **Gini reduced from 0.85 β 0.12** (Grade A fairness)
---
## Architecture
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FAIRRELAY PLATFORM β
ββββββββββββββββ¬βββββββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββββββ€
β Landing β AI Supply β Flutter β Streamlit β
β Page β Chain β Mobile β Women β
β (React) β Dashboard β App β Empowerment Hub β
β Vercel β (React) β (Android) β (Python) β
β β Vercel β β β
ββββββββββββββββ΄βββββββ¬ββββββββ΄βββββββββββββββ΄βββββββββββββββββββββββββ€
β β β
β Backend-DM (Node.js/Express) β
β JWT Auth Β· Prisma ORM Β· Socket.IO β
β Driver Relay Β· Absorption Handshake Β· e-Way Bills β
β Render β
β β β
β β BRAIN_URL proxy β
β βΌ β
β Brain (Python/FastAPI) β
β LangGraph Multi-Agent Orchestration β
β 5-Agent Consolidation + 8-Agent Fair Dispatch β
β OR-Tools Β· XGBoost Β· KMeans Β· Q-Learning Β· Gemini β
β Render β
β β β
β PostgreSQL (Neon) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Tech Stack
| Layer | Technology |
|-------|-----------|
| **AI Engine (Brain)** | Python 3.11, FastAPI, LangGraph, scikit-learn, XGBoost, Google OR-Tools CP-SAT, Gemini API |
| **Operations Backend** | Node.js, Express 5, Prisma ORM, PostgreSQL, Socket.IO, Puppeteer, JWT/RBAC |
| **Dashboard** | React 19, TypeScript, Vite, Redux Toolkit, TailwindCSS, Leaflet, Recharts |
| **Mobile** | Flutter, Dart, Google Maps, Provider, Dio |
| **Landing Page** | React, TypeScript, Vite |
| **Visualization** | Leaflet maps, Chart.js, custom agent pipeline UI, heatmaps |
| **Database** | PostgreSQL 14+ (Neon serverless), SQLAlchemy async |
| **Deployment** | Render (backends), Vercel (frontends), Gunicorn |
---
## Dashboards & Visualization
### Load Consolidation Dashboard (`/demo/consolidation`)
- **5-Agent Pipeline Visualization** β Each agent lights up in sequence with execution time and output metrics
- **AI Optimization Score Ring** β Doughnut chart with letter grade (A+/A/B/C/D)
- **8 KPI Cards** β Utilization, trips reduced, distance saved, CO2, fuel savings, confidence, groups, cost reduction
- **Interactive Route Map** β Three views: Optimized (color-coded), Before (naive gray), Compare (overlay)
- **Consolidated Groups Table** β Truck assignment, weight/volume utilization bars, AI confidence badges
- **Analytics Charts** β Utilization before vs after, Group confidence radar, Weight distribution doughnut
- **Shipment Compatibility Heatmap** β N x N pairwise compatibility matrix (geo + time)
- **Scenario Comparison Panel** β Side-by-side results for Tight/Balanced/Aggressive with recommendation badge
- **AI Learning Insights** β Pattern detection, corridor identification, Q-Learning convergence status
- **Agent Decision Logs** β Terminal-style log viewer for full pipeline transparency
### Fair Dispatch Visualization (`/demo/visualization`)
- **8-Agent Pipeline Visualization** β Real-time agent status with animated transitions
- **Live Map** β Route visualization on Leaflet with driver assignments
- **Fairness Metrics** β Gini index, individual scores, equity analysis
- **Agent Activity Feed** β Decision logs from every agent in the pipeline
### Operations Dashboard (React)
- **Real-time Driver Tracking** β Live map with Socket.IO updates
- **Dispatch Management** β Assign missions, view driver profiles, experience-based routing
- **Absorption Handshake** β Peer-to-peer goods exchange with QR codes
- **e-Way Bill Generation** β Professional government-format PDFs via Puppeteer
- **Analytics** β Fleet KPIs, delivery stats, driver performance
---
## Key Features
### AI Load Consolidation
- **Intelligent Shipment Grouping** β KMeans geo-clustering with silhouette optimization + time window filtering
- **Capacity Optimization** β OR-Tools CP-SAT integer programming to minimize trucks, maximize utilization
- **Scenario Simulation** β Multi-strategy comparison with automated recommendation
- **Continuous Optimization** β Q-Learning RL agent that improves radius/tolerance parameters over time
- **Shipment Compatibility Analysis** β Pairwise heatmap scoring (60% geo + 40% time)
### Fairness-Aware Dispatch
- **Gini Coefficient Optimization** β Measurably fair workload distribution (Gini <= 0.15 guaranteed)
- **Driver Wellness Engine** β Hours worked, rest tracking, illness flags, burnout prevention
- **Night Safety Routing** β Automatic safety filtering for women drivers on night routes
- **EV-Aware Routing** β Battery constraints and charging station integration
- **Explainable Decisions** β 100% of allocations come with Gemini-generated natural language explanations
### Operations Platform
- **Driver Relay System** β Multi-zone handoffs at virtual hubs for long-haul optimization
- **Absorption Handshake** β Offline-capable cryptographic QR verification for goods exchange
- **Dynamic e-Way Bills** β Government-format PDF generation via Puppeteer, no external APIs
- **Real-time Tracking** β Socket.IO powered live driver and delivery status updates
---
## SDG Impact
| SDG | Target | Our Contribution |
|-----|--------|-----------------|
| **SDG 8** β Decent Work | Fair income distribution | Gini 0.85 β 0.12 across all drivers |
| **SDG 10** β Reduced Inequalities | Equal opportunity | Wellness-aware, gender-safe dispatch |
| **SDG 13** β Climate Action | Reduce emissions | 14.2 kg CO2 saved per allocation run, EV-first routing |
---
## Quick Start
### Prerequisites
- Python 3.11+
- Node.js 18+
- PostgreSQL 14+ (or SQLite for development)
- Git
### 1. Brain (AI Engine)
```bash
cd brain
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/macOS
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your DATABASE_URL, GOOGLE_API_KEY etc.
# Run database migrations
alembic upgrade head
# Start the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
```
**Access Points:**
| Page | URL |
|------|-----|
| API Docs (Swagger) | http://localhost:8000/docs |
| ReDoc | http://localhost:8000/redoc |
| Consolidation Dashboard | http://localhost:8000/demo/consolidation |
| Fair Dispatch Demo | http://localhost:8000/demo/allocate |
| Agent Visualization | http://localhost:8000/demo/visualization |
### 2. Backend-DM (Operations Server)
```bash
cd ops/backend-dm
npm install
cp .env.example .env
# Edit .env: DATABASE_URL, JWT_SECRET, BRAIN_URL=http://localhost:8000
npx prisma generate
npx prisma db push
node index.js
# Runs on http://localhost:3000
```
### 3. AI Supply Chain Dashboard
```bash
cd ops/AIsupplychain/aisupply
npm install
# Create .env
echo "VITE_API_URL=http://localhost:3000" > .env
npm run dev
# Runs on http://localhost:5173
```
### 4. Landing Page
```bash
cd landing
npm install
npm run dev
# Runs on http://localhost:5174
```
---
## API Reference
### Load Consolidation
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/consolidate` | Run 5-agent consolidation pipeline (LangGraph) |
| `POST` | `/api/v1/consolidate/sync` | Run consolidation (sync fallback, no LangGraph) |
| `POST` | `/api/v1/consolidate/simulate` | Multi-scenario simulation with recommendation |
#### Consolidation Request
```json
{
"shipments": [
{
"id": "SH-001",
"pickupLat": 19.076, "pickupLng": 72.877,
"dropLat": 18.520, "dropLng": 73.856,
"pickupLocation": "Mumbai", "dropLocation": "Pune",
"weight": 450, "volume": 2.1,
"timeWindowStart": "2026-03-10T08:00:00",
"timeWindowEnd": "2026-03-10T18:00:00",
"priority": "HIGH"
}
],
"trucks": [
{
"id": "TRK-001",
"name": "Tata Ace Gold",
"maxWeight": 2000, "maxVolume": 8.0,
"co2PerKm": 0.21
}
],
"options": {
"maxGroupRadiusKm": 30,
"timeWindowToleranceMinutes": 120
}
}
```
#### Consolidation Response
```json
{
"groups": [
{
"groupId": 0,
"truckId": "TRK-001",
"truckName": "Tata Ace Gold",
"shipmentCount": 4,
"shipments": [{ "id": "SH-001", "pickupLocation": "Mumbai", "dropLocation": "Pune", "weight": 450, "volume": 2.1 }],
"totalWeight": 1680, "totalVolume": 6.8,
"utilizationWeight": 84.0, "utilizationVolume": 85.0,
"confidence": 87
}
],
"metrics": {
"utilizationBefore": 38.2,
"utilizationAfter": 78.5,
"utilizationImprovement": 40.3,
"tripsReduced": 6,
"tripReductionPercent": 60.0,
"distanceSavedKm": 487.3,
"carbonSavedKg": 102.3,
"carbonCreditUSD": 2.56,
"fuelSavedINR": 10964.25,
"optimizationScore": 82,
"avgConfidence": 85
},
"insights": [
{ "type": "pattern", "text": "High-density corridor: Mumbai-Pune (4 shipments)", "impact": "high" },
{ "type": "learning", "text": "Q-table updated. Reward: 76.4. Best action: radius=30km, tolerance=120min", "impact": "medium" }
],
"agentSteps": [
{ "agent": "GeoClusteringAgent", "action": "completed", "method": "kmeans", "clusters": 3, "duration_ms": 45 }
]
}
```
### Fair Dispatch
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/allocate/langgraph` | Run 8-agent fair dispatch pipeline |
| `GET` | `/api/v1/drivers/{id}` | Get driver details and stats |
| `GET` | `/api/v1/routes/{id}` | Get route details and packages |
| `POST` | `/api/v1/feedback` | Submit driver feedback for learning |
#### Fair Dispatch Request
```json
{
"date": "2026-03-10",
"warehouse": { "lat": 12.9716, "lng": 77.5946 },
"packages": [
{
"id": "pkg_001",
"weight_kg": 2.5,
"address": "123 Main St, Bangalore",
"latitude": 12.97, "longitude": 77.60,
"priority": "NORMAL"
}
],
"drivers": [
{
"id": "driver_001",
"name": "Raju",
"vehicle_capacity_kg": 150,
"vehicle_type": "PETROL"
}
]
}
```
#### Fair Dispatch Response
```json
{
"status": "SUCCESS",
"global_fairness": {
"gini_index": 0.12,
"avg_workload": 63.2,
"std_dev": 5.4
},
"assignments": [
{
"driver_id": "driver_001",
"fairness_score": 0.92,
"route_summary": { "num_packages": 22, "total_weight_kg": 48.5, "estimated_time_minutes": 145 },
"explanation": "Your route covers the Koramangala area with 22 packages. Expected completion: 2.5 hours."
}
]
}
```
### Operations (Backend-DM)
| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/dashboard/stats` | Dashboard KPIs |
| `GET` | `/api/drivers` | List all drivers |
| `POST` | `/api/dispatch/assign` | Assign mission to driver |
| `POST` | `/api/absorption/initiate` | Initiate goods handover |
| `POST` | `/api/absorption/verify` | Verify QR handshake |
| `GET` | `/api/ewaybill/generate/:id` | Generate e-Way Bill PDF |
| `GET` | `/api/hubs` | List virtual relay hubs |
---
## Project Structure
```
fairrelay/
βββ brain/ # AI Engine (Python/FastAPI)
β βββ app/
β β βββ api/
β β β βββ consolidation.py # Load consolidation endpoints
β β β βββ allocation_langgraph.py # Fair dispatch endpoints
β β β βββ admin.py
β β β βββ drivers.py
β β β βββ feedback.py
β β βββ services/
β β β βββ consolidation_engine.py # 5 consolidation agents
β β β βββ consolidation_workflow.py # LangGraph consolidation flow
β β β βββ langgraph_workflow.py # LangGraph dispatch flow
β β β βββ langgraph_nodes.py # Dispatch agent implementations
β β β βββ ml_effort_agent.py # XGBoost scoring
β β β βββ fairness_manager_agent.py # Gini evaluation
β β β βββ route_planner_agent.py # Hungarian algorithm
β β β βββ gemini_explain_node.py # LLM explanations
β β βββ schemas/
β β β βββ consolidation.py # Consolidation Pydantic models
β β β βββ allocation.py # Dispatch Pydantic models
β β βββ models/ # SQLAlchemy ORM models
β β βββ config.py
β β βββ database.py
β β βββ main.py
β βββ frontend/
β β βββ consolidation.html # Consolidation dashboard
β β βββ visualization.html # Agent visualization
β β βββ demo.html # API demo page
β βββ data/
β β βββ rl_experience.json # Q-Learning experience store
β βββ alembic/ # Database migrations
β βββ requirements.txt
β βββ Dockerfile
β βββ gunicorn.conf.py
β βββ render.yaml
β
βββ ops/ # Operations Platform
β βββ backend-dm/ # Node.js backend
β β βββ controllers/
β β β βββ routeController.js # Relay logic & assignment
β β β βββ ewayBillController.js # PDF generation
β β β βββ dispatchController.js # Brain proxy
β β βββ services/
β β β βββ dispatch.js # Brain API integration
β β β βββ puppeteer.service.js # PDF rendering
β β β βββ qr.service.js # QR code generation
β β βββ prisma/schema.prisma
β β βββ render.yaml
β β βββ index.js
β β
β βββ AIsupplychain/aisupply/ # React Dashboard (Vite)
β β βββ src/
β β β βββ pages/ # Dashboard, Drivers, Routes, Bills, Tracking
β β β βββ store/ # Redux slices
β β β βββ components/
β β βββ vercel.json
β β
β βββ logistic_flutter/
β βββ orchastra_ps4/ecology/ # Flutter Mobile App
β βββ streamlit/ # Women Empowerment Hub
β
βββ landing/ # Marketing Website (React/Vite)
βββ src/components/
β βββ Hero.tsx # Problem statement + stats
β βββ Features.tsx # 6 feature cards
β βββ LiveDemo.tsx # Interactive allocation demo
β βββ HowItWorks.tsx # 3-step integration guide
βββ vercel.json
```
---
## Deployment
| Component | Platform | URL Pattern |
|-----------|----------|-------------|
| Brain (AI Engine) | Render | `brain-api.onrender.com` |
| Backend-DM | Render | `backend-dm.onrender.com` |
| Dashboard | Vercel | `dashboard.fairrelay.io` |
| Landing Page | Vercel | `fairrelay.io` |
Both backend services include `render.yaml` for one-click Render deployment. Frontend apps include `vercel.json` with API rewrites configured.
---
## Performance Results
| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| Vehicle Utilization | ~38% | ~78% | **+40 percentage points** |
| Trips Required | 10 | 4 | **60% reduction** |
| Distance Traveled | 2,847 km | 1,523 km | **46% less** |
| CO2 Emissions | β | -102 kg saved | **Carbon negative** |
| Fuel Cost | β | -Rs. 10,964 saved | **Per consolidation run** |
| Workload Gini Index | 0.85 | 0.12 | **Grade A fairness** |
| Decision Explainability | 0% | 100% | **Full transparency** |
---
<p align="center">
<strong>Fair routes. Optimized loads. Explainable by default.</strong>
<br/>
Built for <a href="#">LogisticsNow Hackathon 2026</a> · Challenge #5: AI Load Consolidation
</p>
<!-- ml-intern-provenance -->
## Generated by ML Intern
This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
- Try ML Intern: https://smolagents-ml-intern.hf.space
- Source code: https://github.com/huggingface/ml-intern
## Usage
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = 'MouleeswaranM/FairRelay'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
```
For non-causal architectures, replace `AutoModelForCausalLM` with the appropriate `AutoModel` class.
|