# dhwanibro/imp architecture

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

- Interactive diagram: https://gitdiagram.com/dhwanibro/imp
- Repository: https://github.com/dhwanibro/imp

## Overview

KrishiSetu turns district and crop history into seasonal crop advice: data is prepared into weather and scoring contexts, weather models generate monthly forecasts, crop scorers evaluate crop-by-sowing-window options, and aggregation summarizes results across forecast futures. The web app presents policy tiers and levers or goal-ranked grower advice; the CLI exposes a parallel analysis workflow. The README documents these capabilities, but sampled server code is partial, so dashboard wiring is shown only where documented. Some subsystems, including pilot-data handling, are represented at the directory level because their implementation was not excerpted.

Main entry points: [`krishi/pipeline.py`](https://github.com/dhwanibro/imp/blob/main/krishi/pipeline.py) (Prepare contexts), [`server/app.py`](https://github.com/dhwanibro/imp/blob/main/server/app.py) (Dashboard API), [`krishi/scoring/scorer.py`](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/scorer.py) (Crop options), [`krishi/weather`](https://github.com/dhwanibro/imp/tree/main/krishi/weather) (Weather models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data and configuration"]
  node_ag_data[("District dataset<br/>[data.py]")]
  node_config["Seasons and settings<br/>[config.py]"]
  node_crop_conditions["Crop conditions<br/>[crops.py]"]
  node_msp["MSP mapping<br/>[msp.py]"]
  node_pipeline["Prepare contexts<br/>[pipeline.py]"]
  node_pilot["Pilot data support<br/>[pilot.py]"]
end

subgraph group_forecast["Weather forecasting"]
  node_registry["Model registry<br/>[registry.py]"]
  node_weather_context["Weather context<br/>[forecaster.py]"]
  node_weather_models["Weather models"]
  node_forecast_output["Monthly futures<br/>[forecaster.py]"]
end

subgraph group_scoring["Crop scoring"]
  node_scoring_context["Scoring context<br/>[scorer.py]"]
  node_rule_scorer["Rule-based scorer<br/>[rule_based.py]"]
  node_ml_scorer["Yield model scorer<br/>[ml_yield.py]"]
  node_economic_scorer["Economic scorer<br/>[economic.py]"]
  node_options["Crop options<br/>[scorer.py]"]
  node_aggregate["Feasibility aggregation<br/>[aggregate.py]"]
end

subgraph group_delivery["Advice and interfaces"]
  node_web_app["Dashboard API<br/>[app.py]"]
  node_grow_dashboard["Grower dashboard<br/>[grow.html]"]
  node_policy_dashboard["Policy dashboard<br/>[policy.html]"]
  node_cli["Command-line analysis<br/>[cli.py]"]
end

node_grower(("Grower or policymaker"))

node_pipeline -->|"loads dataset"| node_ag_data
node_pipeline -->|"uses settings"| node_config
node_pipeline -->|"generates conditions"| node_crop_conditions
node_pipeline -->|"loads prices"| node_msp
node_pipeline -->|"builds context"| node_weather_context
node_pipeline -->|"builds context"| node_scoring_context
node_weather_models -->|"registers models"| node_registry
node_weather_models -.->|"fits from context"| node_weather_context
node_weather_models -->|"predicts futures"| node_forecast_output
node_rule_scorer -->|"fits from context"| node_scoring_context
node_ml_scorer -->|"fits from context"| node_scoring_context
node_ml_scorer -->|"uses validation"| node_rule_scorer
node_economic_scorer -->|"uses price data"| node_msp
node_rule_scorer -->|"evaluates forecasts"| node_options
node_ml_scorer -->|"evaluates forecasts"| node_options
node_economic_scorer -.->|"scores options"| node_options
node_forecast_output -.->|"scores each future"| node_options
node_aggregate -->|"summarizes futures"| node_options
node_web_app -->|"prepares data"| node_pipeline
node_web_app -->|"aggregates runs"| node_aggregate
node_web_app -.->|"serves page"| node_grow_dashboard
node_web_app -.->|"serves page"| node_policy_dashboard
node_grower -->|"requests advice"| node_web_app
node_cli -->|"prepares contexts"| node_pipeline
node_cli -->|"aggregates forecasts"| node_aggregate
node_grower -->|"runs analysis"| node_cli

click node_ag_data "https://github.com/dhwanibro/imp/blob/main/krishi/data.py"
click node_config "https://github.com/dhwanibro/imp/blob/main/krishi/config.py"
click node_crop_conditions "https://github.com/dhwanibro/imp/blob/main/krishi/crops.py"
click node_msp "https://github.com/dhwanibro/imp/blob/main/krishi/msp.py"
click node_pipeline "https://github.com/dhwanibro/imp/blob/main/krishi/pipeline.py"
click node_pilot "https://github.com/dhwanibro/imp/blob/main/krishi/pilot.py"
click node_registry "https://github.com/dhwanibro/imp/blob/main/krishi/registry.py"
click node_weather_context "https://github.com/dhwanibro/imp/blob/main/krishi/weather/forecaster.py"
click node_weather_models "https://github.com/dhwanibro/imp/tree/main/krishi/weather"
click node_forecast_output "https://github.com/dhwanibro/imp/blob/main/krishi/weather/forecaster.py"
click node_scoring_context "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/scorer.py"
click node_rule_scorer "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/rule_based.py"
click node_ml_scorer "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/ml_yield.py"
click node_economic_scorer "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/economic.py"
click node_options "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/scorer.py"
click node_aggregate "https://github.com/dhwanibro/imp/blob/main/krishi/scoring/aggregate.py"
click node_web_app "https://github.com/dhwanibro/imp/blob/main/server/app.py"
click node_grow_dashboard "https://github.com/dhwanibro/imp/blob/main/server/static/grow.html"
click node_policy_dashboard "https://github.com/dhwanibro/imp/blob/main/server/static/policy.html"
click node_cli "https://github.com/dhwanibro/imp/blob/main/krishi/cli.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_ag_data,node_config,node_crop_conditions,node_msp,node_pipeline,node_pilot toneBlue
class node_registry,node_weather_context,node_weather_models,node_forecast_output toneAmber
class node_scoring_context,node_rule_scorer,node_ml_scorer,node_economic_scorer,node_options,node_aggregate toneMint
class node_web_app,node_grow_dashboard,node_policy_dashboard,node_cli toneRose
class node_grower toneIndigo
```

## Components

### Data and configuration

- [District dataset](https://github.com/dhwanibro/imp/blob/main/krishi/data.py): `krishi/data.py`
- [Seasons and settings](https://github.com/dhwanibro/imp/blob/main/krishi/config.py): `krishi/config.py`
- [Crop conditions](https://github.com/dhwanibro/imp/blob/main/krishi/crops.py): `krishi/crops.py`
- [MSP mapping](https://github.com/dhwanibro/imp/blob/main/krishi/msp.py): `krishi/msp.py`
- [Prepare contexts](https://github.com/dhwanibro/imp/blob/main/krishi/pipeline.py): `krishi/pipeline.py`
- [Pilot data support](https://github.com/dhwanibro/imp/blob/main/krishi/pilot.py): `krishi/pilot.py`

### Weather forecasting

- [Model registry](https://github.com/dhwanibro/imp/blob/main/krishi/registry.py): `krishi/registry.py`
- [Weather context](https://github.com/dhwanibro/imp/blob/main/krishi/weather/forecaster.py): `krishi/weather/forecaster.py`
- [Weather models](https://github.com/dhwanibro/imp/tree/main/krishi/weather): `krishi/weather`
- [Monthly futures](https://github.com/dhwanibro/imp/blob/main/krishi/weather/forecaster.py): `krishi/weather/forecaster.py`

### Crop scoring

- [Scoring context](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/scorer.py): `krishi/scoring/scorer.py`
- [Rule-based scorer](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/rule_based.py): `krishi/scoring/rule_based.py`
- [Yield model scorer](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/ml_yield.py): `krishi/scoring/ml_yield.py`
- [Economic scorer](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/economic.py): `krishi/scoring/economic.py`
- [Crop options](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/scorer.py): `krishi/scoring/scorer.py`
- [Feasibility aggregation](https://github.com/dhwanibro/imp/blob/main/krishi/scoring/aggregate.py): `krishi/scoring/aggregate.py`

### Advice and interfaces

- [Dashboard API](https://github.com/dhwanibro/imp/blob/main/server/app.py): `server/app.py`
- [Grower dashboard](https://github.com/dhwanibro/imp/blob/main/server/static/grow.html): `server/static/grow.html`
- [Policy dashboard](https://github.com/dhwanibro/imp/blob/main/server/static/policy.html): `server/static/policy.html`
- [Command-line analysis](https://github.com/dhwanibro/imp/blob/main/krishi/cli.py): `krishi/cli.py`

### Other components

- **Grower or policymaker**

## Connections

- Prepare contexts → District dataset: loads dataset (evidence: `krishi/pipeline.py`)
- Prepare contexts → Seasons and settings: uses settings (evidence: `krishi/pipeline.py`)
- Prepare contexts → Crop conditions: generates conditions (evidence: `krishi/pipeline.py`)
- Prepare contexts → MSP mapping: loads prices (evidence: `krishi/pipeline.py`)
- Prepare contexts → Weather context: builds context (evidence: `krishi/pipeline.py`)
- Prepare contexts → Scoring context: builds context (evidence: `krishi/pipeline.py`)
- Weather models → Model registry: registers models (evidence: `krishi/weather/__init__.py`)
- Weather models → Weather context: fits from context (evidence: `krishi/weather/ar_trend.py`)
- Weather models → Monthly futures: predicts futures (evidence: `krishi/weather/forecaster.py`)
- Rule-based scorer → Scoring context: fits from context (evidence: `krishi/scoring/rule_based.py`)
- Yield model scorer → Scoring context: fits from context (evidence: `krishi/scoring/ml_yield.py`)
- Yield model scorer → Rule-based scorer: uses validation (evidence: `krishi/scoring/ml_yield.py`)
- Economic scorer → MSP mapping: uses price data (evidence: `krishi/scoring/economic.py`)
- Rule-based scorer → Crop options: evaluates forecasts (evidence: `krishi/scoring/scorer.py`)
- Yield model scorer → Crop options: evaluates forecasts (evidence: `krishi/scoring/scorer.py`)
- Economic scorer → Crop options: scores options (evidence: `krishi/scoring/economic.py`)
- Monthly futures → Crop options: scores each future
- Feasibility aggregation → Crop options: summarizes futures (evidence: `krishi/scoring/scorer.py`)
- Dashboard API → Prepare contexts: prepares data (evidence: `server/app.py`)
- Dashboard API → Feasibility aggregation: aggregates runs (evidence: `server/app.py`)
- Dashboard API → Grower dashboard: serves page
- Dashboard API → Policy dashboard: serves page
- Grower or policymaker → Dashboard API: requests advice (evidence: `README.md`)
- Command-line analysis → Prepare contexts: prepares contexts (evidence: `krishi/cli.py`)
- Command-line analysis → Feasibility aggregation: aggregates forecasts (evidence: `krishi/cli.py`)
- Grower or policymaker → Command-line analysis: runs analysis (evidence: `README.md`)
