# ramakrish21/plant-disease-predictor architecture

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

- Interactive diagram: https://gitdiagram.com/ramakrish21/plant-disease-predictor
- Repository: https://github.com/ramakrish21/plant-disease-predictor

## Overview

This repository is a potato-leaf disease classifier. In the sampled runtime, a user uploads an image to a Streamlit app, which preprocesses it, loads a TensorFlow model, predicts a class and confidence, and displays class-based recommendations. A separate script labels training images by lesion severity. The README describes a FastAPI web application, but the sampled runtime is Streamlit; frontend and backend source was not sampled, so their runtime connections are left out. The app’s configured model filename also differs from the model file present in the tree.

Main entry points: [`ai-service/app.py`](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py) (Streamlit app), [`ai-service/ai-model/scripts/label_severity.py`](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/scripts/label_severity.py) (Severity labeling), [`ai-service/data/raw`](https://github.com/ramakrish21/plant-disease-predictor/tree/main/ai-service/data/raw) (Raw leaf images), [`ai-service/ai-model/Model/potatoes_trained_model.h5`](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/Model/potatoes_trained_model.h5) (Trained model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Diagnosis runtime"]
  node_streamlit_app["Streamlit app<br/>[app.py]"]
  node_image_prep["Image preprocessing<br/>[app.py]"]
  node_classifier["CNN classifier<br/>[app.py]"]
  node_trained_model["Trained model"]
  node_diagnosis["Class and confidence<br/>[app.py]"]
  node_recommendation["Action guidance<br/>[app.py]"]
end

subgraph group_training["Training data"]
  node_raw_images["Raw leaf images"]
  node_severity_labeler["Severity labeling<br/>[label_severity.py]"]
  node_processed_images["Labeled images"]
end

subgraph group_interface["Web interface"]
  node_web_frontend["React frontend"]
  node_backend_code["Backend source"]
end

node_farmer(("Image uploader"))

node_farmer -->|"uploads image"| node_streamlit_app
node_streamlit_app -->|"preprocesses"| node_image_prep
node_streamlit_app -->|"predicts with"| node_classifier
node_classifier -->|"loads model"| node_trained_model
node_classifier -->|"returns prediction"| node_diagnosis
node_streamlit_app -->|"shows guidance"| node_recommendation
node_raw_images -->|"labels severity"| node_severity_labeler
node_severity_labeler -->|"writes labels"| node_processed_images

click node_streamlit_app "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py"
click node_image_prep "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py"
click node_classifier "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py"
click node_trained_model "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/Model/potatoes_trained_model.h5"
click node_diagnosis "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py"
click node_recommendation "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py"
click node_raw_images "https://github.com/ramakrish21/plant-disease-predictor/tree/main/ai-service/data/raw"
click node_severity_labeler "https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/scripts/label_severity.py"
click node_processed_images "https://github.com/ramakrish21/plant-disease-predictor/tree/main/ai-service/data/processed"
click node_web_frontend "https://github.com/ramakrish21/plant-disease-predictor/tree/main/frontend/src"
click node_backend_code "https://github.com/ramakrish21/plant-disease-predictor/tree/main/backend/src"

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_streamlit_app,node_image_prep,node_classifier,node_trained_model,node_diagnosis,node_recommendation toneBlue
class node_raw_images,node_severity_labeler,node_processed_images toneAmber
class node_web_frontend,node_backend_code toneMint
class node_farmer toneIndigo
```

## Components

### Diagnosis runtime

- [Streamlit app](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py): `ai-service/app.py`
- [Image preprocessing](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py): `ai-service/app.py`
- [CNN classifier](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py): `ai-service/app.py`
- [Trained model](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/Model/potatoes_trained_model.h5): `ai-service/ai-model/Model/potatoes_trained_model.h5`
- [Class and confidence](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py): `ai-service/app.py`
- [Action guidance](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/app.py): `ai-service/app.py`

### Training data

- [Raw leaf images](https://github.com/ramakrish21/plant-disease-predictor/tree/main/ai-service/data/raw): `ai-service/data/raw`
- [Severity labeling](https://github.com/ramakrish21/plant-disease-predictor/blob/main/ai-service/ai-model/scripts/label_severity.py): `ai-service/ai-model/scripts/label_severity.py`
- [Labeled images](https://github.com/ramakrish21/plant-disease-predictor/tree/main/ai-service/data/processed): `ai-service/data/processed`

### Web interface

- [React frontend](https://github.com/ramakrish21/plant-disease-predictor/tree/main/frontend/src): `frontend/src`
- [Backend source](https://github.com/ramakrish21/plant-disease-predictor/tree/main/backend/src): `backend/src`

### Other components

- **Image uploader**

## Connections

- Image uploader → Streamlit app: uploads image (evidence: `ai-service/app.py`)
- Streamlit app → Image preprocessing: preprocesses (evidence: `ai-service/app.py`)
- Streamlit app → CNN classifier: predicts with (evidence: `ai-service/app.py`)
- CNN classifier → Trained model: loads model (evidence: `ai-service/app.py`)
- CNN classifier → Class and confidence: returns prediction (evidence: `ai-service/app.py`)
- Streamlit app → Action guidance: shows guidance (evidence: `ai-service/app.py`)
- Raw leaf images → Severity labeling: labels severity (evidence: `ai-service/ai-model/scripts/label_severity.py`)
- Severity labeling → Labeled images: writes labels (evidence: `ai-service/ai-model/scripts/label_severity.py`)
