# haroon423/plantdiseaseai architecture

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

- Interactive diagram: https://gitdiagram.com/haroon423/plantdiseaseai
- Repository: https://github.com/haroon423/plantdiseaseai

## Overview

##### Project Type and Purpose
- This is a machine‑learning–powered plant‐disease detection tool with both training and real‑time inference capabilities.
- Key use cases:
- Training/fine‑tuning a pretrained CNN on leaf images via notebooks.
- Serving predictions via a lightweight web app (Flask or Streamlit).

##### File Structure
Top‑level items:
- PlantDiseaseAI-kggle-Datasets-links (dataset pointers)
- PlantDiseaseAI_FYP.ipynb & plantdiseaseai-fyp.ipynb (training/exploration notebooks)
- plantdiseaseai_fyp.py (training or reusable module)
- app.py (web‑service entry point)
- README.md (project overview)
No separate frontend folder—UI is embedded in the Flask/Streamlit app.

##### README for Insights
- Frameworks: TensorFlow or PyTorch for model, Flask or Streamlit for UI.
- Features: transfer learning, real‑time prediction, easy deployment.

##### Main Components and Their Interactions
a. Data Ingestion & Preprocessing
- Source: “PlantDiseaseAI-kggle–Datasets-links” → local dataset or cloud bucket.
- Processed in notebooks and plantdiseaseai_fyp.py.
b. Model Training & Storage
- Jupyter notebooks load pretrained CNN (e.g., ResNet, MobileNet).
- Fine‑tune on plant leaf dataset.
- Serialize final model (e.g., .h5 or .pth) to disk or model registry.
c. Inference API / Web App
- app.py launches a Flask/Streamlit server.
- Loads the trained model into memory.
- Exposes a REST endpoint (Flask) or interactive UI (Streamlit) for image upload.
d. Client Interaction
- User uploads leaf image via web UI.
- Image sent to server → preprocessing → model.predict → result displayed.
e. (Optional) Deployment Infrastructure
- Docker container or cloud VM hosting the app.
- GPU instance can be used during training; CPU at inference.

##### Architectural Patterns & Technologies
- Pattern: Separate “Training Pipeline” vs. “Serving Pipeline.”
- Transfer Learning: uses pretrained CNN + custom head.
- Single‑process web server for inference (no microservices).
- Reproducible notebooks for experimentation.

##### Final Checklist
- Clear, concise labels for every node.
- Call out where real‑time prediction happens vs. offline training.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Training Pipeline
    subgraph "Training Pipeline"
        direction TB
        DatasetStorage(("Dataset Storage")):::data
        NB1["PlantDiseaseAI_FYP.ipynb"]:::compute
        NB2["plantdiseaseai-fyp.ipynb"]:::compute
        Module["plantdiseaseai_fyp.py"]:::compute
        ModelArtifacts(("Trained Model Artifacts")):::data
    end

    %% Inference Pipeline
    subgraph "Inference Pipeline"
        direction TB
        Client["Client Browser"]:::serve
        WebApp["Flask/Streamlit App\n(app.py)"]:::serve
    end

    %% Documentation
    subgraph "Documentation"
        README["README.md"]:::infra
    end

    %% Data and Flow
    DatasetStorage --> NB1
    DatasetStorage --> NB2
    DatasetStorage --> Module
    NB1 --> Module
    NB2 --> Module
    Module -->|"save model"| ModelArtifacts

    Client -->|"upload image"| WebApp
    WebApp -->|"load model"| ModelArtifacts
    WebApp -->|"predict result"| Client

    %% Click Events
    click DatasetStorage "https://github.com/haroon423/plantdiseaseai/tree/main/PlantDiseaseAI-kggle-Datasets-links/"
    click NB1 "https://github.com/haroon423/plantdiseaseai/blob/main/PlantDiseaseAI_FYP.ipynb"
    click NB2 "https://github.com/haroon423/plantdiseaseai/blob/main/plantdiseaseai-fyp.ipynb"
    click Module "https://github.com/haroon423/plantdiseaseai/blob/main/plantdiseaseai_fyp.py"
    click WebApp "https://github.com/haroon423/plantdiseaseai/blob/main/app.py"
    click README "https://github.com/haroon423/plantdiseaseai/blob/main/README.md"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef compute fill:#98FB98,stroke:#000,stroke-width:1px
    classDef serve fill:#FFA500,stroke:#000,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px
```
