Skip to content
Technomancers-GDGPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

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

Repository files navigation

Resilient Essential Goods Coordinator

Python FastAPI React License CI codecov Google Cloud Run Deployed

FastAPI + React application for disruption-aware essential-goods logistics simulation across India.

Live demo: https://logisight.app | API docs: https://logisight.app/docs


πŸ† Hackathon Submission β€” Round 2

Disruption-aware logistics coordination platform featuring AI/ML decision engines, real-time simulation, driver mobile loop, and Google Cloud integration.

One-liner pitch: "A disruption-aware logistics brain for India. We simulate real supply chains, ingest weather/news data, and use an AI decision engine to reroute vehicles before stockouts happen β€” all visible on a live map with a driver mobile loop."


Why This Matters for India

India loses 4–8% of cereals and 5–15% of fruits & vegetables between harvest and the consumer (NABCONS, 2022 study commissioned by the Ministry of Food Processing Industries). The FSSAI reports that 1/3 of all food produced in India spoils before it is eaten β€” amounting to ~78.2 million tonnes of food waste annually (UNEP Food Waste Index, 2024). That quantity could feed 377 million people.

The primary cause is supply chain disruption β€” not scarcity. Inefficient routing, weather-related road closures (cyclones, monsoon flooding, fog), and lack of real-time rerouting lead to inventory piling up at origin facilities while destination warehouses stock out. The problem is accelerating: India experiences 5–6 cyclonic storms annually, extreme weather events are increasing in frequency, and the logistics cold-chain market relies on temperature-sensitive transport that cannot tolerate delays.

Logisight addresses this at the operational decision layer. Rather than building new infrastructure, it optimises the existing fleet β€” detecting disruptions early, rerouting vehicles before stockouts occur, and providing a live operations dashboard + driver mobile loop for ground-level execution. The result: fewer stockouts, less spoilage, lower COβ‚‚ emissions from empty return trips, and a logistics system that adapts in minutes, not days.


✨ Current Feature Set (Verified)

  • Network management: facilities, ports, port links, vehicles, drivers, and objectives
  • Simulation controls: start, pause, resume, reset, and speed multiplier (up to 5000x)
  • AI Decision Engine: dispatch scoring, RL-based rerouting (DQN with PyTorch), NSGA-II multi-objective optimization
  • RL agent convergence: DQN trained offline (500 epochs, loss 1.83 β†’ 0.55, epsilon 1.0 β†’ 0.05) β€” see docs/rl_training_curve.png
  • Route planning: OSRM first, automatic estimated-route fallback when OSRM is unavailable
  • Disruption management: weather/news ingestion from workbooks + manual driver incident injection + auto-demo disruption
  • Scenario comparison: baseline vs AI-optimized with trigger presets
  • Driver mobile loop: pending instructions, accept/ignore decisions, incident reporting, AI chat assistant
  • SDG-style metrics: stockouts prevented, critical deliveries saved, CO2 reduction
  • Real-time WebSocket stream at /ws/operations
  • Multi-tenant architecture: isolated simulation engines per client
  • Cryptographic audit trail: tamper-evident SHA-256 hash-chain ledger
  • Bilingual UI: English + Hindi (i18n)
  • PWA support with offline caching

πŸš€ Deployment

Endpoint URL Platform
Admin Dashboard https://logisight.app Cloud Run + Firebase Hosting
API & WebSocket https://api.logisight.app Google Cloud Run
Driver Mobile App https://driver.logisight.app Firebase Hosting
Swagger Docs https://logisight.app/docs Cloud Run

Logisight Dashboard Preview


🧠 Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Admin Dashboard (React/Vite)              β”‚
β”‚  Map Β· Live Ops Β· Scenarios Β· Events Β· Impact Β· Analytics    β”‚
└─────────────────────────┬────────────────────────────────── β”˜
                          β”‚ HTTP / WS
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   FastAPI Backend (Python 3.11)              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚Simulation   β”‚ β”‚AI/ML     β”‚ β”‚Google Cloud Integration β”‚   β”‚
β”‚  β”‚Engine       β”‚ β”‚Engine    β”‚ β”‚Firebase Β· Pub/Sub       β”‚   β”‚
β”‚  β”‚(1905 lines) β”‚ β”‚DQN RL    β”‚ β”‚Vertex AI Β· BigQuery     β”‚   β”‚
β”‚  β”‚             β”‚ β”‚NSGA-II   β”‚ β”‚Cloud Messaging Β· CloudSQLβ”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
 β”‚  β”‚Route Plannerβ”‚ β”‚Event     β”‚ β”‚Cryptographic Audit     β”‚   β”‚
 β”‚  β”‚OSRM + Fallb.β”‚ β”‚Ingestion β”‚ β”‚SHA-256 Hash-chain      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚ HTTP / WS
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Driver Mobile App (React/PWA)               β”‚
β”‚  Instructions Β· Incident Report Β· AI Chat Β· Real-time Map    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Tech Stack

Layer Technology
Backend Python 3.11+, FastAPI 0.115, Uvicorn
Database PostgreSQL (prod) / SQLite (dev), SQLAlchemy 2.0, Alembic
Frontend React 18, Vite 6, React Router 7, Leaflet, Recharts, Framer Motion
AI/ML PyTorch (DQN RL), scikit-learn, Google Gemini, Groq (LLM)
Infrastructure Docker, Google Cloud Run, Firebase Hosting, Cloud SQL, Pub/Sub, Vertex AI, BigQuery
Real-time WebSocket (FastAPI native)
Mobile Driver PWA (React + Vite)
i18n English, Hindi

πŸ“Š Tests & CI

Category Status Coverage
Backend pytest βœ… 7 test suites 20%+ target
Frontend Vitest βœ… 3 test suites (formatters, validators, dashboard utils) 30+ unit tests
Driver App Vitest βœ… Real unit tests Added
CI Pipeline βœ… GitHub Actions (lint β†’ test β†’ build β†’ Docker) View runs
Code Coverage βœ… pytest-cov with .coveragerc View on Codecov
# Run all backend tests
python -m pytest tests/ -v --cov=. --cov-report=term

# Run frontend tests
cd frontend && npx vitest run

# Run driver app tests
cd driver-app-main && npx vitest run

πŸ—ΊοΈ Database Migrations

Migrations managed via Alembic (replaces legacy auto-ALTER TABLE):

# Create a new migration
alembic revision --autogenerate -m "description"

# Apply migrations
alembic upgrade head

# Rollback one step
alembic downgrade -1

The initial migration (0001_initial_schema.py) captures the full schema at project inception. All new columns should be added via Alembic revisions.


🏁 Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 20+
  • PostgreSQL (optional, SQLite used by default)

Backend

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m uvicorn main:app --reload

Frontend

cd frontend
npm install
npm run dev       # β†’ http://localhost:5173

Driver App

cd driver-app-main
npm install
npm run dev       # β†’ http://localhost:5174

Docker (Full Stack)

docker build -t logisight .
docker run -p 8000:8000 logisight

βš™οΈ Configuration

Key environment variables β€” see config.py for the full list.

Variable Default Purpose
DATABASE_URL postgresql://postgres:postgres@localhost:5432/supply_chain Production database
GCP_PROJECT_ID logisight-prod Google Cloud project
GCP_REGION asia-south1 GCP region (Mumbai)
GEMINI_API_KEY β€” Google Gemini for AI chat
GROQ_API_KEY β€” Groq fallback for AI chat
FIREBASE_ENABLED true Firebase Realtime DB + Auth
PUBSUB_ENABLED true Cloud Pub/Sub event streaming
VERTEX_AI_ENABLED true Vertex AI model hosting
BIGQUERY_ENABLED true BigQuery analytics
FCM_ENABLED true Firebase Cloud Messaging
SIMULATION_SPEED 5000.0 Default speed multiplier
DEMO_MODE true Auto-start + auto-disruptions

πŸ“ Project Layout

logisight/
β”œβ”€β”€ main.py                        # FastAPI entry point
β”œβ”€β”€ config.py                      # Settings with env validation
β”œβ”€β”€ database.py                    # SQLAlchemy + Alembic migrations
β”œβ”€β”€ models.py                      # ORM models (20+ tables)
β”œβ”€β”€ requirements.txt               # Python dependencies
β”œβ”€β”€ alembic.ini / alembic/         # Database migrations
β”œβ”€β”€ .github/workflows/ci.yml       # CI/CD pipeline
β”œβ”€β”€ .coveragerc                    # Code coverage config
β”œβ”€β”€ firebase-service-account.json.template  # GCP credentials template
β”œβ”€β”€ gcp_config.yaml.template       # GCP configuration template
β”œβ”€β”€ Dockerfile                     # Multi-stage Docker build
β”œβ”€β”€ render.yaml                    # Render Blueprint config
β”œβ”€β”€ routes/                        # API route modules (12 files)
β”œβ”€β”€ services/                      # Business logic services (25 modules)
β”‚   β”œβ”€β”€ simulation/engine.py       # Core simulation engine (1905 lines)
β”‚   β”œβ”€β”€ rl_decision_engine.py      # DQN-based RL agent
β”‚   β”œβ”€β”€ multi_objective_optimizer.py  # NSGA-II optimizer
β”‚   β”œβ”€β”€ blockchain_audit.py        # Tamper-evident SHA-256 hash-chain audit ledger
β”‚   β”œβ”€β”€ google_cloud_integration.py  # GCP services (Firebase, Pub/Sub, Vertex AI, BigQuery, FCM)
β”‚   └── ...
β”œβ”€β”€ schemas/                       # Pydantic schemas (17 files)
β”œβ”€β”€ middleware/                     # Auth middleware (API key, Firebase)
β”œβ”€β”€ frontend/                      # Admin dashboard (React + Vite)
β”‚   β”œβ”€β”€ src/components/views/      # 23 view components
β”‚   └── src/i18n/                  # Bilingual translations
β”œβ”€β”€ driver-app-main/               # Driver mobile app (React + Vite)
└── tests/                         # Backend tests (pytest)

πŸ“– Documentation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages