# kunal05052003/plant_disease_detection architecture

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

- Interactive diagram: https://gitdiagram.com/kunal05052003/plant_disease_detection
- Repository: https://github.com/kunal05052003/plant_disease_detection

## Overview

##### Project type and purpose
- GreenFarmMinds (aka Rudraksh) is a full-stack web application for plant disease detection.
- It consists of a Next.js/TailwindCSS frontend that farmers use to upload leaf images, and a Python/Flask backend that runs an ML model to diagnose diseases.

##### File structure
- Top level:
- api/ – the inference microservice
- web/ – the Next.js frontend
- api/src/
- main.py & wsgi.py – Flask entry points (Procfile for Heroku)
- model_files/ – serialized model (model.pth), prediction logic (ml_predict.py), label/data JSON
- web/
- src/app/ – Next.js 13 “app router” pages (home, about, docs)
- src/components/ – reusable UI (navbar, footer, accordions, theme toggle)
- src/lib/ & src/config/ – shared utilities, types, site config
- src/content/docs/ – MDX content for the disease library
- .env.example – frontend API key for external Plant ID service

##### README for additional insights
- Frontend calls the Flask API for image‐based ML inference.
- A “Disease Library” is just static MDX content served by Next.js.
- Uses React Query in the UI for data‐fetching/caching.
- Deployment targets: Vercel (web) and likely Heroku or similar for the API.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Browser["User Browser"]:::frontend
    ExternalPlant["External Plant ID API"]:::thirdparty

    %% Frontend Tier
    subgraph "Frontend Tier (Vercel)"
        NextFrontend["Next.js Frontend"]:::frontend
        subgraph "web/"
            Package["package.json"]:::frontend
            NextConfig["next.config.js"]:::frontend
            EnvExample[".env.example"]:::frontend

            subgraph "src/app"
                AppRouter["App Router Pages"]:::frontend
            end

            subgraph "src/components"
                Accordion["accordion.tsx"]:::frontend
                Button["button.tsx"]:::frontend
                ThemeToggle["theme-toggle.tsx"]:::frontend
                Navbar["navbar.tsx"]:::frontend
                Footer["footer.tsx"]:::frontend
                Result["result.tsx"]:::frontend
            end

            Wrapper["query-wrapper.tsx"]:::frontend

            subgraph "src/content/docs"
                Docs["Disease Library MDX"]:::frontend
            end

            subgraph "src/config"
                SiteConfig["site.ts"]:::frontend
            end

            subgraph "src/lib"
                Utils["utils.ts"]:::frontend
                Types["types.ts"]:::frontend
                SampleData["sample-data.ts"]:::frontend
            end
        end
    end

    %% Backend Tier
    subgraph "Backend Tier (Heroku)"
        FlaskAPI["Flask API Service"]:::backend
        Procfile["Procfile"]:::backend
        MainPy["main.py"]:::backend
        Wsgi["wsgi.py"]:::backend

        subgraph "model_files"
            MLModule["ML Inference Module"]:::model
            MLPredict["ml_predict.py"]:::model
            ModelFile["model.pth"]:::model
            Labels["labels.json"]:::model
            DataJSON["data.json"]:::model
        end
    end

    %% Data Flows
    Browser -->|"HTTPS Request"| NextFrontend
    NextFrontend -->|"Serves Static MDX"| Docs
    NextFrontend -->|"POST /predict"| FlaskAPI
    FlaskAPI -->|"Runs Inference"| MLModule
    FlaskAPI -->|JSON Response| NextFrontend
    NextFrontend -->|"Optional Call"| ExternalPlant

    %% Click Events - Frontend
    click NextFrontend "https://github.com/kunal05052003/plant_disease_detection/tree/main/web/"
    click Package "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/package.json"
    click NextConfig "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/next.config.js"
    click EnvExample "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/.env.example"
    click AppRouter "https://github.com/kunal05052003/plant_disease_detection/tree/main/web/src/app"
    click Accordion "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/ui/accordion.tsx"
    click Button "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/ui/button.tsx"
    click ThemeToggle "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/ui/theme-toggle.tsx"
    click Navbar "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/navbar.tsx"
    click Footer "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/footer.tsx"
    click Result "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/result.tsx"
    click Wrapper "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/components/wrapper/query-wrapper.tsx"
    click Docs "https://github.com/kunal05052003/plant_disease_detection/tree/main/web/src/content/docs/"
    click SiteConfig "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/config/site.ts"
    click Utils "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/lib/utils.ts"
    click Types "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/lib/types.ts"
    click SampleData "https://github.com/kunal05052003/plant_disease_detection/blob/main/web/src/lib/sample-data.ts"

    %% Click Events - Backend
    click FlaskAPI "https://github.com/kunal05052003/plant_disease_detection/tree/main/api/src/"
    click MainPy "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/main.py"
    click Wsgi "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/wsgi.py"
    click Procfile "https://github.com/kunal05052003/plant_disease_detection/tree/main/api/src/Procfile"
    click MLModule "https://github.com/kunal05052003/plant_disease_detection/tree/main/api/src/model_files/"
    click MLPredict "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/model_files/ml_predict.py"
    click ModelFile "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/model_files/model.pth"
    click Labels "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/model_files/labels.json"
    click DataJSON "https://github.com/kunal05052003/plant_disease_detection/blob/main/api/src/model_files/data.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef backend fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef thirdparty fill:#ffe5b4,stroke:#333,stroke-width:1px;
    classDef model fill:#e2e3e5,stroke:#333,stroke-width:1px;
```
