# akhilpm156/tomato_leaf_disease_classification-with-streamlit architecture

> Architecture diagram of the GitHub repository akhilpm156/tomato_leaf_disease_classification-with-streamlit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit
- Repository: https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit

## Overview

##### Project type and purpose
- This is a single‐page web application (full‐stack, though very light on the “stack”) built with Streamlit.
- Its sole purpose is: accept a tomato leaf image, run it through a pre‐trained Keras model (`tomato_model.h5`), and display one of six disease/health predictions.

##### File structure
- Top level
- `.devcontainer/`: VS Code development container configuration (defines your dev environment).
- `.gitignore`, `README.md`
- `app.py`: Streamlit entry point (combines frontend & backend logic).
- `requirements.txt`: Python dependencies (TensorFlow/Keras, Streamlit, etc.).
- `tomato_model.h5`: Serialized ML model.
- `tomato_plant_leaf_disease_classification.ipynb`: exploratory notebook (data preprocessing & model training).
- `test_image/`: sample images used in testing or demos.

##### README for additional insights
- Confirms Streamlit web app, local launch (`streamlit run app.py`), use of Kaggle “Plant Village” dataset, live deployment on Streamlit Cloud.

a. Main components
1. User’s Browser (client)
2. Streamlit Server (`app.py`) – handles HTTP, UI rendering, file upload widget.
3. Prediction Service – code within `app.py` that loads `tomato_model.h5` via Keras/TensorFlow.
4. Model Store – the `.h5` file residing on disk.
5. Dev Container (optional) – Docker‐based environment defined in `.devcontainer/devcontainer.json`.
6. External Dataset (Kaggle) – for context/training (optional, outside runtime).

b. Relationships and interactions
- Client → Streamlit Server: user uploads image, clicks “Predict.”
- Streamlit Server → Prediction Service: passes image array to model.
- Prediction Service → Model Store: loads weights from `tomato_model.h5`.
- Prediction Service → Streamlit Server: returns class probabilities/labels.
- Streamlit Server → Client: renders prediction result in browser.

c. Architectural patterns/design principles
- Single‐process web server (UI + business logic together).
- Model‐driven classification pipeline.
- Dev container for environment reproducibility (Infrastructure as Code).

d. Key technologies/frameworks
- Streamlit (UI & web server)
- Python 3.x, Keras/TensorFlow (model inference)
- Docker/Dev Container (developer environment)
- Requirements: listed in `requirements.txt`

##### Detail and essential elements
- Technology (e.g., “Streamlit (app.py)”).
- If including the Jupyter notebook, mark it as separate “Training/Research” component, not in the runtime path.

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["User Browser"]:::ui

    subgraph "Dev Container"
        direction TB
        DevConfig[".devcontainer/devcontainer.json"]:::dev
        Server["Streamlit Server\n(app.py)"]:::ui
        Inference["Prediction Service\n(app.py)"]:::inference
        Model["Model Store\n(tomato_model.h5)"]:::storage
        Req["Requirements\n(requirements.txt)"]:::dev
    end

    Notebook["Training/Research Notebook\n(tomato_plant_leaf_disease_classification.ipynb)"]:::external
    Samples["Sample Images\n(test_image/)"]:::external

    Browser -->|"Uploads image"| Server
    Server -->|"Invoke inference"| Inference
    Inference -->|"Load weights"| Model
    Inference -->|"Return prediction"| Server
    Server -->|"Render result"| Browser

    Notebook -.->|"Offline training only"| Model
    Samples -.->|"Demo input"| Server

    click Server "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/app.py"
    click Inference "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/app.py"
    click Model "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/tomato_model.h5"
    click DevConfig "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/.devcontainer/devcontainer.json"
    click Req "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/requirements.txt"
    click Notebook "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/blob/main/tomato_plant_leaf_disease_classification.ipynb"
    click Samples "https://github.com/akhilpm156/tomato_leaf_disease_classification-with-streamlit/tree/main/test_image/"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef inference fill:#90EE90,stroke:#333,stroke-width:1px
    classDef storage fill:#FFD580,stroke:#333,stroke-width:1px
    classDef dev fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#EEEEEE,stroke:#333,stroke-width:1px
```
