# user-hk-1/cropshield-ai architecture

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

- Interactive diagram: https://gitdiagram.com/user-hk-1/cropshield-ai
- Repository: https://github.com/user-hk-1/cropshield-ai

## Overview

CropShield AI is a Streamlit app for identifying a pesticide from an uploaded image and generating crop-specific guidance. A farmer enters a crop and uploads an image; the interface invokes image classification, then requests an advisory report and can submit follow-up questions. The classifier loads its Keras model and labels at runtime, while both language-model features use Groq. The README is empty, so capabilities and connections here are based on the sampled source; asset behavior is shown only where the classifier references those files.

Main entry points: [`main_app_stm.py`](https://github.com/user-hk-1/cropshield-ai/blob/main/main_app_stm.py) (CropShield Dashboard), [`predict_TM.py`](https://github.com/user-hk-1/cropshield-ai/blob/main/predict_TM.py) (Pesticide Classifier), [`llm_app.py`](https://github.com/user-hk-1/cropshield-ai/blob/main/llm_app.py) (Advisory Report), [`keras_model.h5`](https://github.com/user-hk-1/cropshield-ai/blob/main/keras_model.h5) (Keras Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Farmer Interface"]
  node_app["CropShield Dashboard<br/>[main_app_stm.py]"]
end

subgraph group_vision["Image Classification"]
  node_classifier["Pesticide Classifier<br/>[predict_TM.py]"]
  node_model["Keras Model<br/>[keras_model.h5]"]
  node_labels["Class Labels<br/>[labels.txt]"]
end

subgraph group_advisory["Agricultural Guidance"]
  node_report["Advisory Report<br/>[llm_app.py]"]
  node_qa["Follow-up Answers<br/>[llm_app.py]"]
end

node_farmer(("Farmer"))
node_groq["Groq LLM"]

node_farmer -->|"enters crop, uploads image"| node_app
node_app -->|"requests prediction"| node_classifier
node_classifier -->|"loads model"| node_model
node_classifier -->|"reads labels"| node_labels
node_app -->|"requests report"| node_report
node_app -->|"requests answers"| node_qa
node_report -->|"generates guidance"| node_groq
node_qa -->|"answers questions"| node_groq

click node_app "https://github.com/user-hk-1/cropshield-ai/blob/main/main_app_stm.py"
click node_classifier "https://github.com/user-hk-1/cropshield-ai/blob/main/predict_TM.py"
click node_model "https://github.com/user-hk-1/cropshield-ai/blob/main/keras_model.h5"
click node_labels "https://github.com/user-hk-1/cropshield-ai/blob/main/labels.txt"
click node_report "https://github.com/user-hk-1/cropshield-ai/blob/main/llm_app.py"
click node_qa "https://github.com/user-hk-1/cropshield-ai/blob/main/llm_app.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_app toneBlue
class node_classifier,node_model,node_labels toneAmber
class node_report,node_qa toneMint
class node_farmer,node_groq toneIndigo
```

## Components

### Farmer Interface

- [CropShield Dashboard](https://github.com/user-hk-1/cropshield-ai/blob/main/main_app_stm.py): `main_app_stm.py`

### Image Classification

- [Pesticide Classifier](https://github.com/user-hk-1/cropshield-ai/blob/main/predict_TM.py): `predict_TM.py`
- [Keras Model](https://github.com/user-hk-1/cropshield-ai/blob/main/keras_model.h5): `keras_model.h5`
- [Class Labels](https://github.com/user-hk-1/cropshield-ai/blob/main/labels.txt): `labels.txt`

### Agricultural Guidance

- [Advisory Report](https://github.com/user-hk-1/cropshield-ai/blob/main/llm_app.py): `llm_app.py`
- [Follow-up Answers](https://github.com/user-hk-1/cropshield-ai/blob/main/llm_app.py): `llm_app.py`

### Other components

- **Farmer**
- **Groq LLM**

## Connections

- Farmer → CropShield Dashboard: enters crop, uploads image (evidence: `main_app_stm.py`)
- CropShield Dashboard → Pesticide Classifier: requests prediction (evidence: `main_app_stm.py`)
- Pesticide Classifier → Keras Model: loads model (evidence: `predict_TM.py`)
- Pesticide Classifier → Class Labels: reads labels (evidence: `predict_TM.py`)
- CropShield Dashboard → Advisory Report: requests report (evidence: `main_app_stm.py`)
- CropShield Dashboard → Follow-up Answers: requests answers (evidence: `main_app_stm.py`)
- Advisory Report → Groq LLM: generates guidance (evidence: `llm_app.py`)
- Follow-up Answers → Groq LLM: answers questions (evidence: `llm_app.py`)
