# manaswi-510/jaldharma architecture

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

- Interactive diagram: https://gitdiagram.com/manaswi-510/jaldharma
- Repository: https://github.com/manaswi-510/jaldharma

## Overview

Jal Dharma AI is a water-management decision-support system. Its documented workflow loads village, demand, weather, and infrastructure data; predicts village demand; models the distribution network and reachable supply; then allocates scarce water, measures fairness, and visualizes results. The checked-in runtime code supports data loading, prediction, spatial queries, graph/max-flow analysis, and maps. Optimization, justice metrics, scenario simulation, and a dashboard are documented capabilities but have no identifiable implementation files in this tree. Connections for those stages follow the README; source-level links are limited to excerpted code.

Main entry points: [`src/database/connection.py`](https://github.com/manaswi-510/jaldharma/blob/main/src/database/connection.py) (Database connection), [`src/prediction/predict.py`](https://github.com/manaswi-510/jaldharma/blob/main/src/prediction/predict.py) (Demand prediction), [`src/gis/network_builder.py`](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/network_builder.py) (Network builder), [`src/gis/water_graph.py`](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/water_graph.py) (Graph and max flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data foundation"]
  node_datasets["Water datasets"]
  node_loader["Data loader<br/>[load_data.py]"]
  node_postgres[("PostgreSQL + PostGIS")]
  node_connection["Database connection<br/>[connection.py]"]
end

subgraph group_forecast["Demand forecasting"]
  node_prediction["Demand prediction<br/>[predict.py]"]
end

subgraph group_network["GIS and network"]
  node_spatial["Spatial queries<br/>[spatial_queries.py]"]
  node_network_builder["Network builder<br/>[network_builder.py]"]
  node_graph_flow["Graph and max flow<br/>[water_graph.py]"]
end

subgraph group_decisions["Allocation and justice"]
  node_optimizer["Allocation optimization"]
  node_allocation["Equitable allocation"]
  node_justice["Justice metrics"]
  node_scenarios["Scarcity scenarios"]
end

subgraph group_presentation["Visualization"]
  node_map_visualizer["Network maps"]
  node_decision_dashboard["Decision dashboard"]
end

node_operator(("Decision-maker"))

node_datasets -->|"loads from"| node_loader
node_loader -->|"writes tables"| node_postgres
node_loader -->|"gets engine"| node_connection
node_prediction -->|"reads and stores"| node_postgres
node_prediction -->|"gets engine"| node_connection
node_spatial -->|"queries geometry"| node_postgres
node_spatial -->|"gets engine"| node_connection
node_network_builder -->|"loads network data"| node_postgres
node_network_builder -->|"gets engine"| node_connection
node_graph_flow -->|"loads network data"| node_postgres
node_graph_flow -->|"gets engine"| node_connection
node_operator -.->|"requests forecast"| node_prediction
node_operator -.->|"chooses scenario"| node_scenarios
node_prediction -.->|"provides demand"| node_optimizer
node_graph_flow -.->|"provides reachable supply"| node_optimizer
node_optimizer -.->|"optimizes allocation"| node_allocation
node_allocation -.->|"measures fairness"| node_justice
node_allocation -.->|"visualizes allocation"| node_decision_dashboard
node_justice -.->|"shows metrics"| node_decision_dashboard
node_network_builder -.->|"renders network"| node_map_visualizer
node_map_visualizer -.->|"supports decisions"| node_decision_dashboard
node_scenarios -.->|"compares outcomes"| node_optimizer

click node_datasets "https://github.com/manaswi-510/jaldharma/tree/main/data/synthetic"
click node_loader "https://github.com/manaswi-510/jaldharma/blob/main/src/database/load_data.py"
click node_connection "https://github.com/manaswi-510/jaldharma/blob/main/src/database/connection.py"
click node_prediction "https://github.com/manaswi-510/jaldharma/blob/main/src/prediction/predict.py"
click node_spatial "https://github.com/manaswi-510/jaldharma/blob/main/src/gis/spatial_queries.py"
click node_network_builder "https://github.com/manaswi-510/jaldharma/blob/main/src/gis/network_builder.py"
click node_graph_flow "https://github.com/manaswi-510/jaldharma/blob/main/src/gis/water_graph.py"
click node_map_visualizer "https://github.com/manaswi-510/jaldharma/blob/main/src/gis/visualize_network.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_datasets,node_loader,node_postgres,node_connection toneBlue
class node_prediction toneAmber
class node_spatial,node_network_builder,node_graph_flow toneMint
class node_optimizer,node_allocation,node_justice,node_scenarios toneRose
class node_map_visualizer,node_decision_dashboard,node_operator toneIndigo
```

## Components

### Data foundation

- [Water datasets](https://github.com/manaswi-510/jaldharma/tree/main/data/synthetic): `data/synthetic`
- [Data loader](https://github.com/manaswi-510/jaldharma/blob/main/src/database/load_data.py): `src/database/load_data.py`
- **PostgreSQL + PostGIS**
- [Database connection](https://github.com/manaswi-510/jaldharma/blob/main/src/database/connection.py): `src/database/connection.py`

### Demand forecasting

- [Demand prediction](https://github.com/manaswi-510/jaldharma/blob/main/src/prediction/predict.py): `src/prediction/predict.py`

### GIS and network

- [Spatial queries](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/spatial_queries.py): `src/gis/spatial_queries.py`
- [Network builder](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/network_builder.py): `src/gis/network_builder.py`
- [Graph and max flow](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/water_graph.py): `src/gis/water_graph.py`

### Allocation and justice

- **Allocation optimization**
- **Equitable allocation**
- **Justice metrics**
- **Scarcity scenarios**

### Visualization

- [Network maps](https://github.com/manaswi-510/jaldharma/blob/main/src/gis/visualize_network.py): `src/gis/visualize_network.py`
- **Decision dashboard**

### Other components

- **Decision-maker**

## Connections

- Water datasets → Data loader: loads from (evidence: `src/database/load_data.py`)
- Data loader → PostgreSQL + PostGIS: writes tables (evidence: `src/database/load_data.py`)
- Data loader → Database connection: gets engine (evidence: `src/database/load_data.py`)
- Demand prediction → PostgreSQL + PostGIS: reads and stores (evidence: `src/prediction/predict.py`)
- Demand prediction → Database connection: gets engine (evidence: `src/prediction/predict.py`)
- Spatial queries → PostgreSQL + PostGIS: queries geometry (evidence: `src/gis/spatial_queries.py`)
- Spatial queries → Database connection: gets engine (evidence: `src/gis/spatial_queries.py`)
- Network builder → PostgreSQL + PostGIS: loads network data (evidence: `src/gis/network_builder.py`)
- Network builder → Database connection: gets engine (evidence: `src/gis/network_builder.py`)
- Graph and max flow → PostgreSQL + PostGIS: loads network data (evidence: `src/gis/water_graph.py`)
- Graph and max flow → Database connection: gets engine (evidence: `src/gis/water_graph.py`)
- Decision-maker → Demand prediction: requests forecast (evidence: `README.md`)
- Decision-maker → Scarcity scenarios: chooses scenario (evidence: `README.md`)
- Demand prediction → Allocation optimization: provides demand (evidence: `README.md`)
- Graph and max flow → Allocation optimization: provides reachable supply (evidence: `README.md`)
- Allocation optimization → Equitable allocation: optimizes allocation (evidence: `README.md`)
- Equitable allocation → Justice metrics: measures fairness (evidence: `README.md`)
- Equitable allocation → Decision dashboard: visualizes allocation (evidence: `README.md`)
- Justice metrics → Decision dashboard: shows metrics (evidence: `README.md`)
- Network builder → Network maps: renders network (evidence: `README.md`)
- Network maps → Decision dashboard: supports decisions (evidence: `README.md`)
- Scarcity scenarios → Allocation optimization: compares outcomes (evidence: `README.md`)
