# dineshque/cnn-based-plant-pathology-analysis architecture

> Architecture diagram of the GitHub repository dineshque/cnn-based-plant-pathology-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dineshque/cnn-based-plant-pathology-analysis
- Repository: https://github.com/dineshque/cnn-based-plant-pathology-analysis

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application for CNN-based plant pathology analysis.
- Built in Python, it uses Streamlit to serve a UI, TensorFlow for inference, and common CV libraries for preprocessing.
- In addition, a Jupyter notebook is provided for offline model training and experimentation.

##### File structure
- Top level:
- README.md – project overview and setup instructions
- app.py – Streamlit application script (serves UI, handles uploads, runs inference)
- plant-pathology-dinesh.ipynb – Jupyter notebook used to train or evaluate the CNN model offline
- requirements.txt – Python dependencies

##### README for additional insights
- Confirms a single-page Streamlit UI where users upload leaf images.
- Inference is performed on a pre-trained `plant_model.keras` (placed in the root).
- Key libraries: TensorFlow 2.x, OpenCV, Pillow, NumPy, Plotly.

##### Main components and their relationships
a. User Browser (UI)
- Uploads images and displays results via HTTP (Streamlit’s embedded server)
b. Streamlit Server (app.py)
- Routes upload events to the inference pipeline
- Hosts all UI widgets (file uploader, charts, images)
c. Image Preprocessing Module
- Uses OpenCV / Pillow to resize, normalize, and batch images
d. CNN Inference Engine
- Loads `plant_model.keras` via TensorFlow
- Runs model.predict(...) to get disease probabilities
e. Visualization Module
- Uses Plotly to render probability distributions, bar charts, or annotated images
f. Model Training Notebook (Offline)
- Jupyter notebook for training, evaluation, saving `plant_model.keras`
- Depends on the same libraries but is not part of the live service
g. File System / Storage
- Contains the saved `plant_model.keras`

##### Architectural patterns and design principles
- Monolithic single-process architecture: No microservices, everything runs inside a Streamlit app.
- Separation of concerns within the code: UI layer (Streamlit), preprocessing, model loading/inference, and visualization.
- Offline/online separation: Notebook for training vs. app.py for serving.

- A note or callout that the Jupyter notebook is not part of the production server

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Components
    Browser["User Browser (Client)"]:::ui
    StreamlitServer["Streamlit Server (app.py)\n(Streamlit)"]:::ui

    %% ML Components
    PreprocessingModule["Image Preprocessing Module\n(OpenCV/Pillow)"]:::ml
    InferenceEngine["TensorFlow Inference Engine\n(plant_model.keras)"]:::ml

    %% Utility Components
    VisualizationModule["Visualization Module\n(Plotly)"]:::util

    %% Storage
    LocalFileSystem["Local File System\n(plant_model.keras)"]:::storage

    %% Offline Training
    subgraph "Offline Training"
        JupyterNotebook["Model Training Notebook\n(Jupyter)"]:::offline
    end

    %% Documentation
    README["Project Documentation\n(README.md)"]:::storage
    Requirements["Dependencies Spec\n(requirements.txt)"]:::storage

    %% Data Flows
    Browser -->|"HTTP image upload & UI requests"| StreamlitServer
    StreamlitServer -->|"raw image"| PreprocessingModule
    PreprocessingModule -->|"preprocessed tensor"| InferenceEngine
    InferenceEngine -->|"predictions"| StreamlitServer
    StreamlitServer -->|"data for charts"| VisualizationModule
    VisualizationModule -->|"rendered charts & images"| Browser

    LocalFileSystem -.->|"loads plant_model.keras"| InferenceEngine
    JupyterNotebook <-->|"read/write model file"| LocalFileSystem

    %% Click Events
    click StreamlitServer "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/app.py"
    click PreprocessingModule "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/app.py"
    click InferenceEngine "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/app.py"
    click VisualizationModule "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/app.py"
    click JupyterNotebook "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/plant-pathology-dinesh.ipynb"
    click README "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/README.md"
    click Requirements "https://github.com/dineshque/cnn-based-plant-pathology-analysis/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#e5f9e0,stroke:#2d7f32,stroke-width:2px
    classDef ml fill:#ffe5b4,stroke:#d2691e,stroke-width:2px
    classDef util fill:#e0f0ff,stroke:#1e90ff,stroke-width:2px
    classDef storage fill:#f0f0f0,stroke:#808080,stroke-width:2px
    classDef offline fill:#ffffff,stroke:#000000,stroke-dasharray: 5 5,stroke-width:2px
```
