# akshat12bhardwaj/mandi-insights architecture

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

- Interactive diagram: https://gitdiagram.com/akshat12bhardwaj/mandi-insights
- Repository: https://github.com/akshat12bhardwaj/mandi-insights

## Overview

Mandi Insights turns mandi reports into published price outlooks and trading plans: traders compare eligible markets and scenarios, review route and storage economics, and explore the results in a dashboard. The graph preserves the documented daily refresh and publication workflow, forecasting, strategy and discovery capabilities, plus routing and weather support. Some links are documented in the README or SOURCE INDEX rather than shown in excerpts; uncertain runtime wiring is dashed where appropriate.

Main entry points: [`Code/api/daily.py`](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/daily.py) (Daily price API), [`frontend/src/App.tsx`](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/App.tsx) (Dashboard application), [`Code/intelligence/storage_decisions.py`](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/storage_decisions.py) (Trade scenarios), [`Code/api/logistics.py`](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/logistics.py) (Logistics API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and publication"]
  node_refresh["Daily refresh<br/>[refresh.py]"]
  node_ingestion["Report ingestion<br/>[ingestion.py]"]
  node_dailydata[("Daily dataset<br/>[dataset.py]")]
  node_publish["Publication pipeline<br/>[pipeline.py]"]
end

subgraph group_forecast["Price forecasting"]
  node_dailyapi["Daily price API<br/>[daily.py]"]
  node_policy["Eligibility policy<br/>[policy.py]"]
  node_forecasting["Persistence forecast<br/>[forecast.py]"]
end

subgraph group_trade["Trade intelligence"]
  node_intapi["Intelligence API<br/>[intelligence.py]"]
  node_intservice["Market intelligence<br/>[service.py]"]
  node_decision["Trade scenarios"]
  node_explain["Decision explanations<br/>[explanations.py]"]
end

subgraph group_logistics["Logistics and context"]
  node_logapi["Logistics API<br/>[logistics.py]"]
  node_routing["Road routing<br/>[pipeline.py]"]
  node_warehouses[("Warehouse data<br/>[storage.py]")]
  node_weather["Weather forecasts<br/>[forecast.py]"]
end

subgraph group_ui["Dashboard"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_frontend["Dashboard application<br/>[App.tsx]"]
  node_strategies["Strategy explorer<br/>[Strategies.tsx]"]
  node_markets["Market explorer<br/>[Markets.tsx]"]
  node_routes["Route planner<br/>[Routes.tsx]"]
end

node_trader(("Trader"))

node_trader -->|"uses"| node_frontend
node_frontend -->|"renders"| node_strategies
node_frontend -->|"renders"| node_markets
node_frontend -->|"renders"| node_routes
node_frontend -.->|"requests data"| node_backend
node_backend -->|"registers routes"| node_dailyapi
node_backend -->|"registers routes"| node_intapi
node_backend -->|"registers routes"| node_logapi
node_refresh -.->|"refreshes reports"| node_ingestion
node_ingestion -->|"builds dataset"| node_dailydata
node_refresh -->|"publishes batch"| node_publish
node_publish -.->|"publishes prices"| node_dailyapi
node_dailyapi -->|"serves snapshots"| node_dailydata
node_dailyapi -->|"applies eligibility"| node_policy
node_dailyapi -.->|"serves outlook"| node_forecasting
node_intapi -->|"serves intelligence"| node_intservice
node_intapi -->|"reads price data"| node_dailyapi
node_intservice -.->|"calculates scenarios"| node_decision
node_decision -->|"explains outcomes"| node_explain
node_logapi -->|"serves routes"| node_routing
node_logapi -->|"serves facilities"| node_warehouses
node_logapi -->|"serves weather"| node_weather
node_decision -.->|"uses transport costs"| node_routing
node_decision -->|"evaluates storage"| node_warehouses

click node_refresh "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/refresh.py"
click node_ingestion "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/ingestion.py"
click node_dailydata "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/dataset.py"
click node_publish "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/pipeline.py"
click node_dailyapi "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/daily.py"
click node_policy "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/policy.py"
click node_forecasting "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/forecast.py"
click node_intapi "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/intelligence.py"
click node_intservice "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/service.py"
click node_decision "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/storage_decisions.py"
click node_explain "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/explanations.py"
click node_logapi "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/logistics.py"
click node_routing "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/routing/pipeline.py"
click node_warehouses "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/routing/storage.py"
click node_weather "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/weather/forecast.py"
click node_backend "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/main.py"
click node_frontend "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/App.tsx"
click node_strategies "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Strategies.tsx"
click node_markets "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Markets.tsx"
click node_routes "https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Routes.tsx"

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_refresh,node_ingestion,node_dailydata,node_publish toneBlue
class node_dailyapi,node_policy,node_forecasting toneAmber
class node_intapi,node_intservice,node_decision,node_explain toneMint
class node_logapi,node_routing,node_warehouses,node_weather toneRose
class node_backend,node_frontend,node_strategies,node_markets,node_routes,node_trader toneIndigo
```

## Components

### Data and publication

- [Daily refresh](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/refresh.py): `Code/daily/refresh.py`
- [Report ingestion](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/ingestion.py): `Code/intelligence/ingestion.py`
- [Daily dataset](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/dataset.py): `Code/daily/dataset.py`
- [Publication pipeline](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/pipeline.py): `Code/intelligence/pipeline.py`

### Price forecasting

- [Daily price API](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/daily.py): `Code/api/daily.py`
- [Eligibility policy](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/policy.py): `Code/daily/policy.py`
- [Persistence forecast](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/daily/forecast.py): `Code/daily/forecast.py`

### Trade intelligence

- [Intelligence API](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/intelligence.py): `Code/api/intelligence.py`
- [Market intelligence](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/service.py): `Code/intelligence/service.py`
- [Trade scenarios](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/storage_decisions.py): `Code/intelligence/storage_decisions.py`
- [Decision explanations](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/intelligence/explanations.py): `Code/intelligence/explanations.py`

### Logistics and context

- [Logistics API](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/logistics.py): `Code/api/logistics.py`
- [Road routing](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/routing/pipeline.py): `Code/routing/pipeline.py`
- [Warehouse data](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/routing/storage.py): `Code/routing/storage.py`
- [Weather forecasts](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/weather/forecast.py): `Code/weather/forecast.py`

### Dashboard

- [FastAPI application](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/Code/api/main.py): `Code/api/main.py`
- [Dashboard application](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Strategy explorer](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Strategies.tsx): `frontend/src/pages/Strategies.tsx`
- [Market explorer](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Markets.tsx): `frontend/src/pages/Markets.tsx`
- [Route planner](https://github.com/akshat12bhardwaj/mandi-insights/blob/main/frontend/src/pages/Routes.tsx): `frontend/src/pages/Routes.tsx`

### Other components

- **Trader**

## Connections

- Trader → Dashboard application: uses (evidence: `README.md`)
- Dashboard application → Strategy explorer: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Market explorer: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Route planner: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → FastAPI application: requests data
- FastAPI application → Daily price API: registers routes (evidence: `Code/api/main.py`)
- FastAPI application → Intelligence API: registers routes (evidence: `Code/api/main.py`)
- FastAPI application → Logistics API: registers routes (evidence: `Code/api/main.py`)
- Daily refresh → Report ingestion: refreshes reports (evidence: `Code/intelligence/ingestion.py`)
- Report ingestion → Daily dataset: builds dataset (evidence: `Code/intelligence/ingestion.py`)
- Daily refresh → Publication pipeline: publishes batch (evidence: `README.md`)
- Publication pipeline → Daily price API: publishes prices (evidence: `Code/intelligence/pipeline.py`)
- Daily price API → Daily dataset: serves snapshots (evidence: `Code/api/daily.py`)
- Daily price API → Eligibility policy: applies eligibility (evidence: `Code/api/daily.py`)
- Daily price API → Persistence forecast: serves outlook
- Intelligence API → Market intelligence: serves intelligence (evidence: `Code/api/intelligence.py`)
- Intelligence API → Daily price API: reads price data (evidence: `Code/api/intelligence.py`)
- Market intelligence → Trade scenarios: calculates scenarios (evidence: `Code/intelligence/storage_decisions.py`)
- Trade scenarios → Decision explanations: explains outcomes (evidence: `Code/intelligence/storage_decisions.py`)
- Logistics API → Road routing: serves routes (evidence: `Code/api/logistics.py`)
- Logistics API → Warehouse data: serves facilities (evidence: `Code/api/logistics.py`)
- Logistics API → Weather forecasts: serves weather (evidence: `Code/api/logistics.py`)
- Trade scenarios → Road routing: uses transport costs
- Trade scenarios → Warehouse data: evaluates storage (evidence: `Code/intelligence/storage_decisions.py`)
