# hp7690/predictive_logistics architecture

> Architecture diagram of the GitHub repository hp7690/predictive_logistics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hp7690/predictive_logistics
- Repository: https://github.com/hp7690/predictive_logistics

## Overview

ASTRA-LOG is a predictive logistics command application: users sign in to role-specific dashboards, monitor stock and forecasts, raise SOS or requests, and planners generate and manage multimode convoy plans. The backend coordinates forecasting, shortage alerts, route risk and optimization, with inventory and operational records in the database; MQTT edge readings and weather updates provide live inputs. The frontend exposes planning, transport, depot, post and administration workflows, including maps, what-if controls, KPIs and retraining. Relationships reflect explicit imports, calls or README descriptions; unsampled subsystems are included where documented, with uncertain links omitted.

Main entry points: [`backend/app/main.py`](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/main.py) (HTTP And WS API), [`frontend/src/App.jsx`](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/App.jsx) (Role App), [`frontend/src/components/Panels.jsx`](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/components/Panels.jsx) (Data Panels), [`backend/app/services/planner.py`](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/planner.py) (Convoy Planning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Role Dashboards"]
  node_app["Role App<br/>[App.jsx]"]
  node_plannerui["Planner Dashboard<br/>[Planner.jsx]"]
  node_transportui["Transport Dashboard<br/>[Transport.jsx]"]
  node_depotui["Depot Dashboard<br/>[Depot.jsx]"]
  node_postui["Post Dashboard<br/>[Post.jsx]"]
  node_adminui["Admin Dashboard<br/>[Admin.jsx]"]
  node_map["GIS Map<br/>[MapView.jsx]"]
  node_panels["Data Panels<br/>[Panels.jsx]"]
  node_api_client["API Client<br/>[api.js]"]
  node_hooks["Live Data Hooks<br/>[hooks.js]"]
end

subgraph group_api["Command API"]
  node_backend["HTTP And WS API<br/>[main.py]"]
  node_auth["Access Control<br/>[auth.py]"]
  node_records["Operational Records<br/>[models.py]"]
  node_database[("PostgreSQL Store<br/>[db.py]")]
  node_websocket["Live Event Hub<br/>[ws.py]"]
end

subgraph group_planning["Demand And Routing"]
  node_alerts["Shortfall Alerts<br/>[alerts.py]"]
  node_forecast["Demand Forecast<br/>[forecast.py]"]
  node_planner["Convoy Planning<br/>[planner.py]"]
  node_risk["Route Risk<br/>[risk.py]"]
  node_vrp["Vehicle Routing<br/>[vrp.py]"]
  node_geography["Pilot Geography<br/>[india.py]"]
end

subgraph group_inputs["Field Inputs"]
  node_mqtt["MQTT Bridge<br/>[mqtt_bridge.py]"]
  node_edge["Edge Simulator<br/>[edge_sim.py]"]
  node_weather["Weather Feed<br/>[weather_live.py]"]
end

node_user(("Command Users"))
node_weather_service(("Open-Meteo"))

node_user -->|"uses"| node_app
node_app -->|"logs in"| node_api_client
node_app -->|"routes to"| node_plannerui
node_app -->|"routes to"| node_transportui
node_app -->|"routes to"| node_depotui
node_app -->|"routes to"| node_postui
node_app -->|"routes to"| node_adminui
node_app -->|"opens WebSocket"| node_api_client
node_plannerui -->|"requests data"| node_api_client
node_plannerui -->|"renders panels"| node_panels
node_plannerui -->|"renders map"| node_map
node_transportui -->|"renders map"| node_map
node_transportui -->|"renders panels"| node_panels
node_depotui -->|"renders panels"| node_panels
node_postui -->|"renders panels"| node_panels
node_adminui -->|"renders panels"| node_panels
node_panels -->|"loads data"| node_api_client
node_panels -->|"uses loaders"| node_hooks
node_api_client -->|"sends HTTP"| node_backend
node_backend -->|"checks access"| node_auth
node_backend -->|"queries records"| node_records
node_backend -->|"opens sessions"| node_database
node_records -->|"uses base"| node_database
node_backend -->|"refreshes alerts"| node_alerts
node_alerts -->|"forecasts demand"| node_forecast
node_backend -->|"calls planner"| node_planner
node_planner -->|"reads alerts"| node_alerts
node_planner -->|"scores routes"| node_risk
node_planner -->|"solves allocation"| node_vrp
node_planner -->|"uses geography"| node_geography
node_backend -->|"controls bridge"| node_mqtt
node_edge -->|"publishes readings"| node_mqtt
node_mqtt -->|"stores stock"| node_records
node_mqtt -->|"pushes events"| node_websocket
node_backend -->|"emits events"| node_websocket
node_backend -->|"syncs weather"| node_weather
node_weather -.->|"fetches forecast"| node_weather_service
node_weather -->|"persists weather"| node_records
node_backend -->|"retrain action"| node_forecast
node_forecast -->|"reads consumption"| node_database

click node_app "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/App.jsx"
click node_plannerui "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Planner.jsx"
click node_transportui "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Transport.jsx"
click node_depotui "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Depot.jsx"
click node_postui "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Post.jsx"
click node_adminui "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Admin.jsx"
click node_map "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/components/MapView.jsx"
click node_panels "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/components/Panels.jsx"
click node_api_client "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/api.js"
click node_hooks "https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/hooks.js"
click node_backend "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/main.py"
click node_auth "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/auth.py"
click node_records "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/models.py"
click node_database "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/db.py"
click node_alerts "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/alerts.py"
click node_forecast "https://github.com/hp7690/predictive_logistics/blob/main/ml/forecast.py"
click node_planner "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/planner.py"
click node_risk "https://github.com/hp7690/predictive_logistics/blob/main/optimizer/risk.py"
click node_vrp "https://github.com/hp7690/predictive_logistics/blob/main/optimizer/vrp.py"
click node_geography "https://github.com/hp7690/predictive_logistics/blob/main/ml/india.py"
click node_mqtt "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/mqtt_bridge.py"
click node_edge "https://github.com/hp7690/predictive_logistics/blob/main/iot_sim/edge_sim.py"
click node_weather "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/weather_live.py"
click node_websocket "https://github.com/hp7690/predictive_logistics/blob/main/backend/app/ws.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_plannerui,node_transportui,node_depotui,node_postui,node_adminui,node_map,node_panels,node_api_client,node_hooks,node_user toneBlue
class node_backend,node_auth,node_records,node_database,node_websocket toneAmber
class node_alerts,node_forecast,node_planner,node_risk,node_vrp,node_geography toneMint
class node_mqtt,node_edge,node_weather toneRose
class node_weather_service toneIndigo
```

## Components

### Role Dashboards

- [Role App](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Planner Dashboard](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Planner.jsx): `frontend/src/pages/Planner.jsx`
- [Transport Dashboard](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Transport.jsx): `frontend/src/pages/Transport.jsx`
- [Depot Dashboard](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Depot.jsx): `frontend/src/pages/Depot.jsx`
- [Post Dashboard](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Post.jsx): `frontend/src/pages/Post.jsx`
- [Admin Dashboard](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/pages/Admin.jsx): `frontend/src/pages/Admin.jsx`
- [GIS Map](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/components/MapView.jsx): `frontend/src/components/MapView.jsx`
- [Data Panels](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/components/Panels.jsx): `frontend/src/components/Panels.jsx`
- [API Client](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Live Data Hooks](https://github.com/hp7690/predictive_logistics/blob/main/frontend/src/hooks.js): `frontend/src/hooks.js`

### Command API

- [HTTP And WS API](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/main.py): `backend/app/main.py`
- [Access Control](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Operational Records](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/models.py): `backend/app/models.py`
- [PostgreSQL Store](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/db.py): `backend/app/db.py`
- [Live Event Hub](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/ws.py): `backend/app/ws.py`

### Demand And Routing

- [Shortfall Alerts](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/alerts.py): `backend/app/services/alerts.py`
- [Demand Forecast](https://github.com/hp7690/predictive_logistics/blob/main/ml/forecast.py): `ml/forecast.py`
- [Convoy Planning](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/planner.py): `backend/app/services/planner.py`
- [Route Risk](https://github.com/hp7690/predictive_logistics/blob/main/optimizer/risk.py): `optimizer/risk.py`
- [Vehicle Routing](https://github.com/hp7690/predictive_logistics/blob/main/optimizer/vrp.py): `optimizer/vrp.py`
- [Pilot Geography](https://github.com/hp7690/predictive_logistics/blob/main/ml/india.py): `ml/india.py`

### Field Inputs

- [MQTT Bridge](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/mqtt_bridge.py): `backend/app/mqtt_bridge.py`
- [Edge Simulator](https://github.com/hp7690/predictive_logistics/blob/main/iot_sim/edge_sim.py): `iot_sim/edge_sim.py`
- [Weather Feed](https://github.com/hp7690/predictive_logistics/blob/main/backend/app/services/weather_live.py): `backend/app/services/weather_live.py`

### Other components

- **Command Users**
- **Open-Meteo**

## Connections

- Command Users → Role App: uses
- Role App → API Client: logs in (evidence: `frontend/src/App.jsx`)
- Role App → Planner Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Role App → Transport Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Role App → Depot Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Role App → Post Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Role App → Admin Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Role App → API Client: opens WebSocket (evidence: `frontend/src/App.jsx`)
- Planner Dashboard → API Client: requests data (evidence: `frontend/src/pages/Planner.jsx`)
- Planner Dashboard → Data Panels: renders panels (evidence: `frontend/src/pages/Planner.jsx`)
- Planner Dashboard → GIS Map: renders map (evidence: `frontend/src/pages/Planner.jsx`)
- Transport Dashboard → GIS Map: renders map (evidence: `frontend/src/pages/Transport.jsx`)
- Transport Dashboard → Data Panels: renders panels (evidence: `frontend/src/pages/Transport.jsx`)
- Depot Dashboard → Data Panels: renders panels (evidence: `frontend/src/pages/Depot.jsx`)
- Post Dashboard → Data Panels: renders panels (evidence: `frontend/src/pages/Post.jsx`)
- Admin Dashboard → Data Panels: renders panels (evidence: `frontend/src/pages/Admin.jsx`)
- Data Panels → API Client: loads data (evidence: `frontend/src/components/Panels.jsx`)
- Data Panels → Live Data Hooks: uses loaders (evidence: `frontend/src/components/Panels.jsx`)
- API Client → HTTP And WS API: sends HTTP (evidence: `frontend/src/api.js`)
- HTTP And WS API → Access Control: checks access (evidence: `backend/app/main.py`)
- HTTP And WS API → Operational Records: queries records (evidence: `backend/app/main.py`)
- HTTP And WS API → PostgreSQL Store: opens sessions (evidence: `backend/app/main.py`)
- Operational Records → PostgreSQL Store: uses base (evidence: `backend/app/models.py`)
- HTTP And WS API → Shortfall Alerts: refreshes alerts (evidence: `backend/app/main.py`)
- Shortfall Alerts → Demand Forecast: forecasts demand (evidence: `backend/app/services/alerts.py`)
- HTTP And WS API → Convoy Planning: calls planner (evidence: `backend/app/main.py`)
- Convoy Planning → Shortfall Alerts: reads alerts (evidence: `backend/app/services/planner.py`)
- Convoy Planning → Route Risk: scores routes (evidence: `backend/app/services/planner.py`)
- Convoy Planning → Vehicle Routing: solves allocation (evidence: `backend/app/services/planner.py`)
- Convoy Planning → Pilot Geography: uses geography (evidence: `backend/app/services/planner.py`)
- HTTP And WS API → MQTT Bridge: controls bridge (evidence: `backend/app/main.py`)
- Edge Simulator → MQTT Bridge: publishes readings
- MQTT Bridge → Operational Records: stores stock (evidence: `backend/app/mqtt_bridge.py`)
- MQTT Bridge → Live Event Hub: pushes events (evidence: `backend/app/mqtt_bridge.py`)
- HTTP And WS API → Live Event Hub: emits events (evidence: `backend/app/main.py`)
- HTTP And WS API → Weather Feed: syncs weather (evidence: `backend/app/main.py`)
- Weather Feed → Open-Meteo: fetches forecast
- Weather Feed → Operational Records: persists weather (evidence: `backend/app/services/weather_live.py`)
- HTTP And WS API → Demand Forecast: retrain action (evidence: `backend/app/main.py`)
- Demand Forecast → PostgreSQL Store: reads consumption (evidence: `ml/forecast.py`)
