# harikamasam/agrismart-ml architecture

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

- Interactive diagram: https://gitdiagram.com/harikamasam/agrismart-ml
- Repository: https://github.com/harikamasam/agrismart-ml

## Overview

This is a terminal-based crop recommendation and model-comparison project. Its main workflow loads and validates agricultural measurements, creates a stratified train/test split, engineers domain features, compares three training-only feature-selection methods across three tree classifiers, selects the best experiment, and accepts seven measurements for a crop recommendation with confidence and cultivation information. The graph includes evaluation and research outputs as a supporting internal layer. README statements and shown call sites support the workflow; unsampled implementation details are not inferred.

Main entry points: [`src/main.py`](https://github.com/harikamasam/agrismart-ml/blob/main/src/main.py) (Experiment runner), [`src/predict.py`](https://github.com/harikamasam/agrismart-ml/blob/main/src/predict.py) (Prediction interface), [`src/feature_selection.py`](https://github.com/harikamasam/agrismart-ml/blob/main/src/feature_selection.py) (Feature selection), [`src/train_models.py`](https://github.com/harikamasam/agrismart-ml/blob/main/src/train_models.py) (Classifier builders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Data pipeline"]
  node_dataset[("Crop dataset<br/>[crop_data.csv]")]
  node_preprocessing["Data preparation"]
  node_engineering["Agricultural features"]
end

subgraph group_experiments["Model experiments"]
  node_runner["Experiment runner<br/>[main.py]"]
  node_selection["Feature selection"]
  node_builders["Classifier builders<br/>[train_models.py]"]
  node_xgb["XGBoost builder<br/>[train_model.py]"]
end

subgraph group_inference["Terminal recommendation"]
  node_best_model[("Best model bundle")]
  node_prediction["Prediction interface<br/>[predict.py]"]
  node_crop_reference["Crop information<br/>[crop_info.py]"]
  node_recommendation["Crop recommendation<br/>[predict.py]"]
end

subgraph group_outputs["Evaluation outputs"]
  node_evaluation["Metrics and reports<br/>[evaluate_model.py]"]
  node_research["Research figures"]
  node_experiment_results["Experiment artifacts"]
  node_comparison["Model comparison"]
end

node_farmer(("Terminal user"))

node_farmer -->|"starts workflow"| node_runner
node_dataset -->|"loads and validates"| node_preprocessing
node_runner -->|"prepares split"| node_preprocessing
node_runner -->|"engineers features"| node_engineering
node_runner -->|"selects features"| node_selection
node_runner -->|"trains classifiers"| node_builders
node_builders -->|"uses XGBoost builder"| node_xgb
node_selection -->|"uses shared seed"| node_xgb
node_runner -->|"evaluates models"| node_evaluation
node_runner -->|"generates figures"| node_research
node_runner -->|"saves reports"| node_experiment_results
node_runner -->|"writes comparison"| node_comparison
node_runner -->|"saves best bundle"| node_best_model
node_farmer -->|"enters measurements"| node_prediction
node_runner -->|"collects and predicts"| node_prediction
node_prediction -->|"engineers inputs"| node_engineering
node_prediction -->|"gets probabilities"| node_evaluation
node_prediction -->|"looks up crop details"| node_crop_reference
node_prediction -->|"displays result"| node_recommendation

click node_dataset "https://github.com/harikamasam/agrismart-ml/blob/main/data/crop_data.csv"
click node_preprocessing "https://github.com/harikamasam/agrismart-ml/blob/main/src/data_preprocessing.py"
click node_engineering "https://github.com/harikamasam/agrismart-ml/blob/main/src/feature_engineering.py"
click node_runner "https://github.com/harikamasam/agrismart-ml/blob/main/src/main.py"
click node_selection "https://github.com/harikamasam/agrismart-ml/blob/main/src/feature_selection.py"
click node_builders "https://github.com/harikamasam/agrismart-ml/blob/main/src/train_models.py"
click node_xgb "https://github.com/harikamasam/agrismart-ml/blob/main/src/train_model.py"
click node_evaluation "https://github.com/harikamasam/agrismart-ml/blob/main/src/evaluate_model.py"
click node_research "https://github.com/harikamasam/agrismart-ml/blob/main/src/research_figures.py"
click node_experiment_results "https://github.com/harikamasam/agrismart-ml/tree/main/results"
click node_comparison "https://github.com/harikamasam/agrismart-ml/blob/main/results/model_comparison.csv"
click node_best_model "https://github.com/harikamasam/agrismart-ml/blob/main/models/best_crop_model.pkl"
click node_prediction "https://github.com/harikamasam/agrismart-ml/blob/main/src/predict.py"
click node_crop_reference "https://github.com/harikamasam/agrismart-ml/blob/main/src/crop_info.py"
click node_recommendation "https://github.com/harikamasam/agrismart-ml/blob/main/src/predict.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_dataset,node_preprocessing,node_engineering,node_farmer toneBlue
class node_runner,node_selection,node_builders,node_xgb toneAmber
class node_best_model,node_prediction,node_crop_reference,node_recommendation toneMint
class node_evaluation,node_research,node_experiment_results,node_comparison toneRose
```

## Components

### Data pipeline

- [Crop dataset](https://github.com/harikamasam/agrismart-ml/blob/main/data/crop_data.csv): `data/crop_data.csv`
- [Data preparation](https://github.com/harikamasam/agrismart-ml/blob/main/src/data_preprocessing.py): `src/data_preprocessing.py`
- [Agricultural features](https://github.com/harikamasam/agrismart-ml/blob/main/src/feature_engineering.py): `src/feature_engineering.py`

### Model experiments

- [Experiment runner](https://github.com/harikamasam/agrismart-ml/blob/main/src/main.py): `src/main.py`
- [Feature selection](https://github.com/harikamasam/agrismart-ml/blob/main/src/feature_selection.py): `src/feature_selection.py`
- [Classifier builders](https://github.com/harikamasam/agrismart-ml/blob/main/src/train_models.py): `src/train_models.py`
- [XGBoost builder](https://github.com/harikamasam/agrismart-ml/blob/main/src/train_model.py): `src/train_model.py`

### Terminal recommendation

- [Best model bundle](https://github.com/harikamasam/agrismart-ml/blob/main/models/best_crop_model.pkl): `models/best_crop_model.pkl`
- [Prediction interface](https://github.com/harikamasam/agrismart-ml/blob/main/src/predict.py): `src/predict.py`
- [Crop information](https://github.com/harikamasam/agrismart-ml/blob/main/src/crop_info.py): `src/crop_info.py`
- [Crop recommendation](https://github.com/harikamasam/agrismart-ml/blob/main/src/predict.py): `src/predict.py`

### Evaluation outputs

- [Metrics and reports](https://github.com/harikamasam/agrismart-ml/blob/main/src/evaluate_model.py): `src/evaluate_model.py`
- [Research figures](https://github.com/harikamasam/agrismart-ml/blob/main/src/research_figures.py): `src/research_figures.py`
- [Experiment artifacts](https://github.com/harikamasam/agrismart-ml/tree/main/results): `results`
- [Model comparison](https://github.com/harikamasam/agrismart-ml/blob/main/results/model_comparison.csv): `results/model_comparison.csv`

### Other components

- **Terminal user**

## Connections

- Terminal user → Experiment runner: starts workflow (evidence: `README.md`)
- Crop dataset → Data preparation: loads and validates (evidence: `src/data_preprocessing.py`)
- Experiment runner → Data preparation: prepares split (evidence: `src/main.py`)
- Experiment runner → Agricultural features: engineers features (evidence: `README.md`)
- Experiment runner → Feature selection: selects features (evidence: `src/main.py`)
- Experiment runner → Classifier builders: trains classifiers (evidence: `src/main.py`)
- Classifier builders → XGBoost builder: uses XGBoost builder (evidence: `src/train_models.py`)
- Feature selection → XGBoost builder: uses shared seed (evidence: `src/feature_selection.py`)
- Experiment runner → Metrics and reports: evaluates models (evidence: `src/main.py`)
- Experiment runner → Research figures: generates figures (evidence: `src/main.py`)
- Experiment runner → Experiment artifacts: saves reports (evidence: `src/main.py`)
- Experiment runner → Model comparison: writes comparison (evidence: `src/main.py`)
- Experiment runner → Best model bundle: saves best bundle (evidence: `README.md`)
- Terminal user → Prediction interface: enters measurements (evidence: `README.md`)
- Experiment runner → Prediction interface: collects and predicts (evidence: `src/main.py`)
- Prediction interface → Agricultural features: engineers inputs (evidence: `src/predict.py`)
- Prediction interface → Metrics and reports: gets probabilities (evidence: `src/predict.py`)
- Prediction interface → Crop information: looks up crop details (evidence: `src/predict.py`)
- Prediction interface → Crop recommendation: displays result (evidence: `src/predict.py`)
