# anis29017/crop-yieldmlops architecture

> Architecture diagram of the GitHub repository anis29017/crop-yieldmlops, 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/anis29017/crop-yieldmlops
- Repository: https://github.com/anis29017/crop-yieldmlops

## Overview

This repository is a district-level crop-yield prediction service designed to stay current as new official yield and climate data arrive. Its main workflow collects source data, validates and prepares it into a model table, trains a versioned model, and serves predictions and operational status. Separate capabilities monitor climate drift, support retraining, and manage checked blue-green releases. The map follows documented flows and source-index references; some internal API and integration wiring was not shown, so uncertain links are omitted or marked unverified.

Main entry points: [`src/quality.py`](https://github.com/anis29017/crop-yieldmlops/blob/main/src/quality.py) (Quality gates and quarantine), [`data/silver`](https://github.com/anis29017/crop-yieldmlops/tree/main/data/silver) (Silver data tables), [`src/dataops/fetch.py`](https://github.com/anis29017/crop-yieldmlops/blob/main/src/dataops/fetch.py) (Yield book fetcher), [`src/train.py`](https://github.com/anis29017/crop-yieldmlops/blob/main/src/train.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Data collection"]
  node_fetcher["Yield book fetcher<br/>[fetch.py]"]
  node_source_rules["Source recognition<br/>[sources.py]"]
  node_yield_readers["Yield book readers"]
  node_climate_fetch["Climate data fetchers<br/>[fetch_chirps.py]"]
  node_climate_update["Climate feature update<br/>[update_climate.py]"]
end

subgraph group_data["Data preparation"]
  node_bronze[("Bronze source archive")]
  node_layers["Layer and integrity rules<br/>[layers.py]"]
  node_silver[("Silver data tables")]
  node_yield_labels["Yield label builder"]
  node_master["Master table builder<br/>[build_master.py]"]
  node_contracts["Table contracts<br/>[contracts.py]"]
  node_quality["Quality gates and quarantine<br/>[quality.py]"]
  node_prepare["Gold data preparation<br/>[prepare_data.py]"]
  node_gold[("Gold model table<br/>[processed.csv]")]
end

subgraph group_ml["Model lifecycle"]
  node_version["Data versioning<br/>[data_version.py]"]
  node_training["Model training<br/>[train.py]"]
  node_model["Prediction model<br/>[model.py]"]
  node_drift["Climate drift detection<br/>[drift.py]"]
  node_retrain["Retraining workflow<br/>[retrain.py]"]
end

subgraph group_service["Prediction service"]
  node_api["Prediction API<br/>[app.py]"]
  node_explain["Prediction explanations<br/>[explain.py]"]
end

subgraph group_release["Operations and release"]
  node_bluegreen["Blue-green release checks<br/>[blue_green.py]"]
  node_router["Traffic router<br/>[router.py]"]
  node_admin["Operations console<br/>[admin.py]"]
  node_audit["Audit trail<br/>[audit.py]"]
end

node_official(("Official yield publishers"))
node_climate_sources(("Climate and soil providers"))
node_client(("Prediction client"))

node_official -->|"provides books"| node_fetcher
node_fetcher -->|"applies rules"| node_source_rules
node_fetcher -->|"archives downloads"| node_bronze
node_fetcher -->|"pulls and reads"| node_yield_readers
node_climate_sources -->|"provides seasons"| node_climate_fetch
node_climate_fetch -.->|"archives inputs"| node_bronze
node_climate_update -->|"runs fetchers"| node_climate_fetch
node_climate_update -->|"updates features"| node_silver
node_layers -->|"checks integrity"| node_bronze
node_yield_readers -->|"builds yield rows"| node_silver
node_yield_labels -->|"writes labels"| node_silver
node_yield_labels -->|"gates labels"| node_quality
node_master -->|"reads inputs"| node_silver
node_master -->|"gates master"| node_quality
node_prepare -->|"reads master"| node_silver
node_prepare -->|"gates gold"| node_quality
node_quality -->|"checks contracts"| node_contracts
node_quality -->|"permits output"| node_gold
node_prepare -->|"writes table"| node_gold
node_training -->|"trains on"| node_gold
node_training -->|"wraps estimator"| node_model
node_training -->|"records data version"| node_version
node_drift -->|"checks climate data"| node_gold
node_retrain -->|"checks drift"| node_drift
node_retrain -->|"runs training"| node_training
node_client -->|"requests prediction"| node_api
node_api -.->|"predicts with"| node_model
node_api -->|"uses explanations"| node_explain
node_bluegreen -->|"switches traffic"| node_router
node_admin -->|"checks releases"| node_bluegreen
node_admin -->|"records actions"| node_audit
node_router -->|"records switches"| node_audit

click node_fetcher "https://github.com/anis29017/crop-yieldmlops/blob/main/src/dataops/fetch.py"
click node_source_rules "https://github.com/anis29017/crop-yieldmlops/blob/main/src/dataops/sources.py"
click node_yield_readers "https://github.com/anis29017/crop-yieldmlops/tree/main/src/dataops"
click node_climate_fetch "https://github.com/anis29017/crop-yieldmlops/blob/main/src/fetch_chirps.py"
click node_climate_update "https://github.com/anis29017/crop-yieldmlops/blob/main/src/update_climate.py"
click node_bronze "https://github.com/anis29017/crop-yieldmlops/tree/main/data/bronze"
click node_layers "https://github.com/anis29017/crop-yieldmlops/blob/main/src/layers.py"
click node_silver "https://github.com/anis29017/crop-yieldmlops/tree/main/data/silver"
click node_yield_labels "https://github.com/anis29017/crop-yieldmlops/blob/main/src/build_yield_labels.py"
click node_master "https://github.com/anis29017/crop-yieldmlops/blob/main/src/build_master.py"
click node_contracts "https://github.com/anis29017/crop-yieldmlops/blob/main/src/contracts.py"
click node_quality "https://github.com/anis29017/crop-yieldmlops/blob/main/src/quality.py"
click node_prepare "https://github.com/anis29017/crop-yieldmlops/blob/main/src/prepare_data.py"
click node_gold "https://github.com/anis29017/crop-yieldmlops/blob/main/data/gold/processed.csv"
click node_version "https://github.com/anis29017/crop-yieldmlops/blob/main/src/data_version.py"
click node_training "https://github.com/anis29017/crop-yieldmlops/blob/main/src/train.py"
click node_model "https://github.com/anis29017/crop-yieldmlops/blob/main/src/model.py"
click node_drift "https://github.com/anis29017/crop-yieldmlops/blob/main/src/drift.py"
click node_retrain "https://github.com/anis29017/crop-yieldmlops/blob/main/src/retrain.py"
click node_api "https://github.com/anis29017/crop-yieldmlops/blob/main/src/app.py"
click node_explain "https://github.com/anis29017/crop-yieldmlops/blob/main/src/explain.py"
click node_bluegreen "https://github.com/anis29017/crop-yieldmlops/blob/main/src/blue_green.py"
click node_router "https://github.com/anis29017/crop-yieldmlops/blob/main/src/router.py"
click node_admin "https://github.com/anis29017/crop-yieldmlops/blob/main/src/admin.py"
click node_audit "https://github.com/anis29017/crop-yieldmlops/blob/main/src/audit.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_fetcher,node_source_rules,node_yield_readers,node_climate_fetch,node_climate_update,node_client toneBlue
class node_bronze,node_layers,node_silver,node_yield_labels,node_master,node_contracts,node_quality,node_prepare,node_gold toneAmber
class node_version,node_training,node_model,node_drift,node_retrain toneMint
class node_api,node_explain toneRose
class node_bluegreen,node_router,node_admin,node_audit,node_official,node_climate_sources toneIndigo
```

## Components

### Data collection

- [Yield book fetcher](https://github.com/anis29017/crop-yieldmlops/blob/main/src/dataops/fetch.py): `src/dataops/fetch.py`
- [Source recognition](https://github.com/anis29017/crop-yieldmlops/blob/main/src/dataops/sources.py): `src/dataops/sources.py`
- [Yield book readers](https://github.com/anis29017/crop-yieldmlops/tree/main/src/dataops): `src/dataops`
- [Climate data fetchers](https://github.com/anis29017/crop-yieldmlops/blob/main/src/fetch_chirps.py): `src/fetch_chirps.py`
- [Climate feature update](https://github.com/anis29017/crop-yieldmlops/blob/main/src/update_climate.py): `src/update_climate.py`

### Data preparation

- [Bronze source archive](https://github.com/anis29017/crop-yieldmlops/tree/main/data/bronze): `data/bronze`
- [Layer and integrity rules](https://github.com/anis29017/crop-yieldmlops/blob/main/src/layers.py): `src/layers.py`
- [Silver data tables](https://github.com/anis29017/crop-yieldmlops/tree/main/data/silver): `data/silver`
- [Yield label builder](https://github.com/anis29017/crop-yieldmlops/blob/main/src/build_yield_labels.py): `src/build_yield_labels.py`
- [Master table builder](https://github.com/anis29017/crop-yieldmlops/blob/main/src/build_master.py): `src/build_master.py`
- [Table contracts](https://github.com/anis29017/crop-yieldmlops/blob/main/src/contracts.py): `src/contracts.py`
- [Quality gates and quarantine](https://github.com/anis29017/crop-yieldmlops/blob/main/src/quality.py): `src/quality.py`
- [Gold data preparation](https://github.com/anis29017/crop-yieldmlops/blob/main/src/prepare_data.py): `src/prepare_data.py`
- [Gold model table](https://github.com/anis29017/crop-yieldmlops/blob/main/data/gold/processed.csv): `data/gold/processed.csv`

### Model lifecycle

- [Data versioning](https://github.com/anis29017/crop-yieldmlops/blob/main/src/data_version.py): `src/data_version.py`
- [Model training](https://github.com/anis29017/crop-yieldmlops/blob/main/src/train.py): `src/train.py`
- [Prediction model](https://github.com/anis29017/crop-yieldmlops/blob/main/src/model.py): `src/model.py`
- [Climate drift detection](https://github.com/anis29017/crop-yieldmlops/blob/main/src/drift.py): `src/drift.py`
- [Retraining workflow](https://github.com/anis29017/crop-yieldmlops/blob/main/src/retrain.py): `src/retrain.py`

### Prediction service

- [Prediction API](https://github.com/anis29017/crop-yieldmlops/blob/main/src/app.py): `src/app.py`
- [Prediction explanations](https://github.com/anis29017/crop-yieldmlops/blob/main/src/explain.py): `src/explain.py`

### Operations and release

- [Blue-green release checks](https://github.com/anis29017/crop-yieldmlops/blob/main/src/blue_green.py): `src/blue_green.py`
- [Traffic router](https://github.com/anis29017/crop-yieldmlops/blob/main/src/router.py): `src/router.py`
- [Operations console](https://github.com/anis29017/crop-yieldmlops/blob/main/src/admin.py): `src/admin.py`
- [Audit trail](https://github.com/anis29017/crop-yieldmlops/blob/main/src/audit.py): `src/audit.py`

### Other components

- **Official yield publishers**
- **Climate and soil providers**
- **Prediction client**

## Connections

- Official yield publishers → Yield book fetcher: provides books (evidence: `README.md`)
- Yield book fetcher → Source recognition: applies rules (evidence: `src/dataops/fetch.py`)
- Yield book fetcher → Bronze source archive: archives downloads (evidence: `README.md`)
- Yield book fetcher → Yield book readers: pulls and reads (evidence: `README.md`)
- Climate and soil providers → Climate data fetchers: provides seasons (evidence: `README.md`)
- Climate data fetchers → Bronze source archive: archives inputs
- Climate feature update → Climate data fetchers: runs fetchers (evidence: `src/update_climate.py`)
- Climate feature update → Silver data tables: updates features (evidence: `README.md`)
- Layer and integrity rules → Bronze source archive: checks integrity (evidence: `README.md`)
- Yield book readers → Silver data tables: builds yield rows (evidence: `README.md`)
- Yield label builder → Silver data tables: writes labels (evidence: `src/build_yield_labels.py`)
- Yield label builder → Quality gates and quarantine: gates labels (evidence: `src/build_yield_labels.py`)
- Master table builder → Silver data tables: reads inputs (evidence: `README.md`)
- Master table builder → Quality gates and quarantine: gates master (evidence: `src/build_master.py`)
- Gold data preparation → Silver data tables: reads master (evidence: `src/prepare_data.py`)
- Gold data preparation → Quality gates and quarantine: gates gold (evidence: `src/prepare_data.py`)
- Quality gates and quarantine → Table contracts: checks contracts (evidence: `src/quality.py`)
- Quality gates and quarantine → Gold model table: permits output
- Gold data preparation → Gold model table: writes table (evidence: `src/prepare_data.py`)
- Model training → Gold model table: trains on (evidence: `README.md`)
- Model training → Prediction model: wraps estimator (evidence: `src/train.py`)
- Model training → Data versioning: records data version (evidence: `src/train.py`)
- Climate drift detection → Gold model table: checks climate data (evidence: `src/drift.py`)
- Retraining workflow → Climate drift detection: checks drift (evidence: `src/retrain.py`)
- Retraining workflow → Model training: runs training (evidence: `src/retrain.py`)
- Prediction client → Prediction API: requests prediction (evidence: `README.md`)
- Prediction API → Prediction model: predicts with
- Prediction API → Prediction explanations: uses explanations (evidence: `src/app.py`)
- Blue-green release checks → Traffic router: switches traffic (evidence: `src/router.py`)
- Operations console → Blue-green release checks: checks releases (evidence: `src/admin.py`)
- Operations console → Audit trail: records actions (evidence: `src/admin.py`)
- Traffic router → Audit trail: records switches (evidence: `src/router.py`)
