# dhecaptain/uasingishu-cropstudy architecture

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

- Interactive diagram: https://gitdiagram.com/dhecaptain/uasingishu-cropstudy
- Repository: https://github.com/dhecaptain/uasingishu-cropstudy

## Overview

This is an applied-statistics project studying climate variability and maize yield in Uasin Gishu, Kenya. Its workflow cleans station and yield data, engineers climate features and an annual panel, evaluates yield models, then presents the study through an interactive Streamlit dashboard. The README also documents descriptive, trend, correlation, group-comparison, and hypothesis-testing analyses. The cleaning, training, and dashboard excerpts support the principal data and model flows; dashboard page wiring beyond the sampled code is represented conservatively.

Main entry points: [`app.py`](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py) (Streamlit dashboard), [`01_data_cleaning.py`](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/01_data_cleaning.py) (Clean and engineer), [`02_model_training.py`](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/02_model_training.py) (Model training), [`data/cleaned/panel_annual_clean.csv`](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/cleaned/panel_annual_clean.csv) (Annual analysis panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_rawclimate[("Raw climate data")]
  node_rawyield[("Raw yield data<br/>[maize_yield.csv]")]
  node_cleaning["Clean and engineer"]
  node_cleanclimate[("Clean climate data")]
  node_cleanyield[("Clean yield data")]
  node_panel[("Annual analysis panel")]
end

subgraph group_analysis["Statistical analysis"]
  node_descriptive["Descriptive analysis<br/>[app.py]"]
  node_climatetrends["Climate trends<br/>[app.py]"]
  node_yieldeda["Yield and correlations<br/>[app.py]"]
  node_hypothesis["Hypothesis tests<br/>[app.py]"]
end

subgraph group_modeling["Yield modeling"]
  node_prediction["Yield prediction<br/>[app.py]"]
  node_training["Model training"]
  node_modelstore[("Saved models")]
  node_metrics[("Model metrics")]
end

subgraph group_dashboard["Interactive dashboard"]
  node_dashboardapp["Streamlit dashboard<br/>[app.py]"]
end

node_user(("Dashboard user"))

node_rawclimate -->|"loads"| node_cleaning
node_rawyield -->|"loads"| node_cleaning
node_cleaning -->|"writes"| node_cleanclimate
node_cleaning -->|"writes"| node_cleanyield
node_cleaning -->|"rebuilds"| node_panel
node_user -->|"uses"| node_dashboardapp
node_dashboardapp -->|"reads"| node_cleanclimate
node_dashboardapp -->|"reads"| node_cleanyield
node_dashboardapp -->|"reads"| node_panel
node_dashboardapp -->|"renders"| node_descriptive
node_dashboardapp -->|"renders"| node_climatetrends
node_dashboardapp -->|"renders"| node_yieldeda
node_dashboardapp -->|"renders"| node_hypothesis
node_dashboardapp -->|"renders"| node_prediction
node_panel -->|"provides data"| node_training
node_training -->|"saves models"| node_modelstore
node_training -->|"writes metrics"| node_metrics
node_dashboardapp -->|"loads model"| node_modelstore
node_dashboardapp -->|"reads metrics"| node_metrics

click node_rawclimate "https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/data"
click node_rawyield "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/maize_yield.csv"
click node_cleaning "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/01_data_cleaning.py"
click node_cleanclimate "https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/data/cleaned"
click node_cleanyield "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/cleaned/maize_yield_clean.csv"
click node_panel "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/cleaned/panel_annual_clean.csv"
click node_dashboardapp "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_descriptive "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_climatetrends "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_yieldeda "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_hypothesis "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_prediction "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py"
click node_training "https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/02_model_training.py"
click node_modelstore "https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/models"
click node_metrics "https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/models/metrics"

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_rawclimate,node_rawyield,node_cleaning,node_cleanclimate,node_cleanyield,node_panel,node_user toneBlue
class node_descriptive,node_climatetrends,node_yieldeda,node_hypothesis toneAmber
class node_prediction,node_training,node_modelstore,node_metrics toneMint
class node_dashboardapp toneRose
```

## Components

### Data preparation

- [Raw climate data](https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/data): `data`
- [Raw yield data](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/maize_yield.csv): `data/maize_yield.csv`
- [Clean and engineer](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/01_data_cleaning.py): `01_data_cleaning.py`
- [Clean climate data](https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/data/cleaned): `data/cleaned`
- [Clean yield data](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/cleaned/maize_yield_clean.csv): `data/cleaned/maize_yield_clean.csv`
- [Annual analysis panel](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/data/cleaned/panel_annual_clean.csv): `data/cleaned/panel_annual_clean.csv`

### Statistical analysis

- [Descriptive analysis](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`
- [Climate trends](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`
- [Yield and correlations](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`
- [Hypothesis tests](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`

### Yield modeling

- [Yield prediction](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`
- [Model training](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/02_model_training.py): `02_model_training.py`
- [Saved models](https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/models): `models`
- [Model metrics](https://github.com/dhecaptain/uasingishu-cropstudy/tree/main/models/metrics): `models/metrics`

### Interactive dashboard

- [Streamlit dashboard](https://github.com/dhecaptain/uasingishu-cropstudy/blob/main/app.py): `app.py`

### Other components

- **Dashboard user**

## Connections

- Raw climate data → Clean and engineer: loads
- Raw yield data → Clean and engineer: loads
- Clean and engineer → Clean climate data: writes
- Clean and engineer → Clean yield data: writes
- Clean and engineer → Annual analysis panel: rebuilds
- Dashboard user → Streamlit dashboard: uses
- Streamlit dashboard → Clean climate data: reads
- Streamlit dashboard → Clean yield data: reads
- Streamlit dashboard → Annual analysis panel: reads
- Streamlit dashboard → Descriptive analysis: renders
- Streamlit dashboard → Climate trends: renders
- Streamlit dashboard → Yield and correlations: renders
- Streamlit dashboard → Hypothesis tests: renders
- Streamlit dashboard → Yield prediction: renders
- Annual analysis panel → Model training: provides data
- Model training → Saved models: saves models
- Model training → Model metrics: writes metrics
- Streamlit dashboard → Saved models: loads model
- Streamlit dashboard → Model metrics: reads metrics
