# sohammondal29/plantguard.ai architecture

> Architecture diagram of the GitHub repository sohammondal29/plantguard.ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sohammondal29/plantguard.ai
- Repository: https://github.com/sohammondal29/plantguard.ai

## Overview

PlantGuard AI is a plant-health platform whose main workflow runs from dashboard image or chat input through the FastAPI backend to diagnosis and, when relevant, monitoring, agricultural research, weather context, and treatment advice. It also supports tracked plants, progression analytics, and PDF reports. The graph includes the documented agent and legacy capabilities; several route and agent implementations were not sampled, so those connections rely on README statements rather than inspected call sites.

Main entry points: [`backend/api/routes`](https://github.com/sohammondal29/plantguard.ai/tree/main/backend/api/routes) (HTTP routes), [`backend/services/diagnosis_service.py`](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/diagnosis_service.py) (Diagnosis service), [`backend/agents`](https://github.com/sohammondal29/plantguard.ai/tree/main/backend/agents) (Specialist agents), [`backend/database/repositories.py`](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/database/repositories.py) (Domain repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_web["React dashboard<br/>[App.jsx]"]
  node_webapi["Frontend API client<br/>[api.js]"]
  node_legacy["Streamlit interface<br/>[plantdisease.py]"]
end

subgraph group_api["HTTP API"]
  node_server["FastAPI application<br/>[main.py]"]
  node_routes["HTTP routes"]
end

subgraph group_diagnosis["Diagnosis and monitoring"]
  node_diagnosis_service["Diagnosis service"]
  node_classifier["Disease classifier"]
  node_validator["Leaf validator<br/>[leaf_validator.py]"]
  node_severity["Severity estimator"]
  node_progression["Progression analysis"]
  node_weather["Weather advisory<br/>[weather_service.py]"]
  node_report["PDF reports<br/>[report_service.py]"]
end

subgraph group_intelligence["Agents and knowledge"]
  node_graph["Agent workflow graph<br/>[graph.py]"]
  node_orchestrator["Request orchestrator<br/>[orchestrator.py]"]
  node_agent_state["Conversation state<br/>[state.py]"]
  node_specialists["Specialist agents"]
  node_rag["Agricultural retrieval<br/>[rag.py]"]
  node_embeddings["Gemini embeddings<br/>[embeddings.py]"]
  node_llm["Gemini chat model<br/>[llm.py]"]
end

subgraph group_platform["State and integrations"]
  node_repositories["Domain repositories<br/>[repositories.py]"]
  node_sqlite[("SQLite database<br/>[connection.py]")]
  node_config["Runtime settings<br/>[config.py]"]
end

node_user(("Plant health user"))
node_weather_provider{{"Weather provider"}}
node_gemini{{"Google Gemini"}}
node_faiss[("FAISS vector index")]

node_user -->|"uses"| node_web
node_web -->|"requests data"| node_webapi
node_webapi -->|"calls REST API"| node_routes
node_user -.->|"uses"| node_legacy
node_server -->|"mounts routers"| node_routes
node_routes -.->|"delegates diagnosis"| node_diagnosis_service
node_routes -->|"invokes chat workflow"| node_graph
node_diagnosis_service -->|"validates leaf"| node_validator
node_diagnosis_service -->|"classifies image"| node_classifier
node_diagnosis_service -->|"estimates severity"| node_severity
node_diagnosis_service -->|"records diagnosis"| node_repositories
node_diagnosis_service -->|"retrieves context"| node_rag
node_routes -.->|"requests trends"| node_progression
node_routes -.->|"requests advisory"| node_weather
node_routes -.->|"generates reports"| node_report
node_graph -->|"routes workflow"| node_orchestrator
node_graph -->|"tracks state"| node_agent_state
node_orchestrator -->|"dispatches agents"| node_specialists
node_orchestrator -->|"loads diagnosis context"| node_repositories
node_specialists -->|"retrieves evidence"| node_rag
node_specialists -.->|"uses risk indicators"| node_weather
node_specialists -.->|"can generate report"| node_report
node_specialists -.->|"synthesizes advice"| node_llm
node_rag -->|"embeds documents"| node_embeddings
node_rag -->|"searches index"| node_faiss
node_embeddings -.->|"requests embeddings"| node_gemini
node_llm -->|"requests chat"| node_gemini
node_weather -.->|"fetches conditions"| node_weather_provider
node_progression -->|"reads diagnosis history"| node_repositories
node_report -->|"stores report record"| node_repositories
node_repositories -->|"reads and writes"| node_sqlite
node_server -->|"loads settings"| node_config
node_legacy -->|"uses classifier"| node_classifier
node_legacy -->|"uses report service"| node_report

click node_web "https://github.com/sohammondal29/plantguard.ai/blob/main/frontend/src/App.jsx"
click node_webapi "https://github.com/sohammondal29/plantguard.ai/blob/main/frontend/src/services/api.js"
click node_legacy "https://github.com/sohammondal29/plantguard.ai/blob/main/plantdisease.py"
click node_server "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/main.py"
click node_routes "https://github.com/sohammondal29/plantguard.ai/tree/main/backend/api/routes"
click node_diagnosis_service "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/diagnosis_service.py"
click node_classifier "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/disease_classifier.py"
click node_validator "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/leaf_validator.py"
click node_severity "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/severity_estimator.py"
click node_progression "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/progression_service.py"
click node_weather "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/weather_service.py"
click node_report "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/report_service.py"
click node_graph "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/graph.py"
click node_orchestrator "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/orchestrator.py"
click node_agent_state "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/state.py"
click node_specialists "https://github.com/sohammondal29/plantguard.ai/tree/main/backend/agents"
click node_rag "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/rag.py"
click node_embeddings "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/embeddings.py"
click node_llm "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/llm.py"
click node_repositories "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/database/repositories.py"
click node_sqlite "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/database/connection.py"
click node_config "https://github.com/sohammondal29/plantguard.ai/blob/main/backend/core/config.py"

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_web,node_webapi,node_legacy,node_user toneBlue
class node_server,node_routes,node_faiss toneAmber
class node_diagnosis_service,node_classifier,node_validator,node_severity,node_progression,node_weather,node_report toneMint
class node_graph,node_orchestrator,node_agent_state,node_specialists,node_rag,node_embeddings,node_llm toneRose
class node_repositories,node_sqlite,node_config,node_weather_provider,node_gemini toneIndigo
```

## Components

### User interfaces

- [React dashboard](https://github.com/sohammondal29/plantguard.ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Frontend API client](https://github.com/sohammondal29/plantguard.ai/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Streamlit interface](https://github.com/sohammondal29/plantguard.ai/blob/main/plantdisease.py): `plantdisease.py`

### HTTP API

- [FastAPI application](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/main.py): `backend/main.py`
- [HTTP routes](https://github.com/sohammondal29/plantguard.ai/tree/main/backend/api/routes): `backend/api/routes`

### Diagnosis and monitoring

- [Diagnosis service](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/diagnosis_service.py): `backend/services/diagnosis_service.py`
- [Disease classifier](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/disease_classifier.py): `backend/vision/disease_classifier.py`
- [Leaf validator](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/leaf_validator.py): `backend/vision/leaf_validator.py`
- [Severity estimator](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/vision/severity_estimator.py): `backend/vision/severity_estimator.py`
- [Progression analysis](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/progression_service.py): `backend/services/progression_service.py`
- [Weather advisory](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/weather_service.py): `backend/services/weather_service.py`
- [PDF reports](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/services/report_service.py): `backend/services/report_service.py`

### Agents and knowledge

- [Agent workflow graph](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/graph.py): `backend/agents/graph.py`
- [Request orchestrator](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/orchestrator.py): `backend/agents/orchestrator.py`
- [Conversation state](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/agents/state.py): `backend/agents/state.py`
- [Specialist agents](https://github.com/sohammondal29/plantguard.ai/tree/main/backend/agents): `backend/agents`
- [Agricultural retrieval](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/rag.py): `backend/genai/rag.py`
- [Gemini embeddings](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/embeddings.py): `backend/genai/embeddings.py`
- [Gemini chat model](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/genai/llm.py): `backend/genai/llm.py`

### State and integrations

- [Domain repositories](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/database/repositories.py): `backend/database/repositories.py`
- [SQLite database](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/database/connection.py): `backend/database/connection.py`
- [Runtime settings](https://github.com/sohammondal29/plantguard.ai/blob/main/backend/core/config.py): `backend/core/config.py`

### Other components

- **Plant health user**
- **Weather provider**
- **Google Gemini**
- **FAISS vector index**

## Connections

- Plant health user → React dashboard: uses
- React dashboard → Frontend API client: requests data
- Frontend API client → HTTP routes: calls REST API (evidence: `frontend/src/services/api.js`)
- Plant health user → Streamlit interface: uses
- FastAPI application → HTTP routes: mounts routers (evidence: `backend/main.py`)
- HTTP routes → Diagnosis service: delegates diagnosis
- HTTP routes → Agent workflow graph: invokes chat workflow (evidence: `backend/api/routes/assistant.py`)
- Diagnosis service → Leaf validator: validates leaf (evidence: `backend/services/diagnosis_service.py`)
- Diagnosis service → Disease classifier: classifies image (evidence: `backend/services/diagnosis_service.py`)
- Diagnosis service → Severity estimator: estimates severity (evidence: `backend/services/diagnosis_service.py`)
- Diagnosis service → Domain repositories: records diagnosis (evidence: `backend/services/diagnosis_service.py`)
- Diagnosis service → Agricultural retrieval: retrieves context (evidence: `backend/services/diagnosis_service.py`)
- HTTP routes → Progression analysis: requests trends
- HTTP routes → Weather advisory: requests advisory
- HTTP routes → PDF reports: generates reports
- Agent workflow graph → Request orchestrator: routes workflow (evidence: `backend/agents/graph.py`)
- Agent workflow graph → Conversation state: tracks state (evidence: `backend/agents/graph.py`)
- Request orchestrator → Specialist agents: dispatches agents (evidence: `backend/agents/orchestrator.py`)
- Request orchestrator → Domain repositories: loads diagnosis context (evidence: `backend/agents/orchestrator.py`)
- Specialist agents → Agricultural retrieval: retrieves evidence
- Specialist agents → Weather advisory: uses risk indicators
- Specialist agents → PDF reports: can generate report
- Specialist agents → Gemini chat model: synthesizes advice (evidence: `backend/agents/orchestrator.py`)
- Agricultural retrieval → Gemini embeddings: embeds documents (evidence: `backend/genai/rag.py`)
- Agricultural retrieval → FAISS vector index: searches index
- Gemini embeddings → Google Gemini: requests embeddings
- Gemini chat model → Google Gemini: requests chat (evidence: `backend/genai/llm.py`)
- Weather advisory → Weather provider: fetches conditions
- Progression analysis → Domain repositories: reads diagnosis history (evidence: `backend/services/progression_service.py`)
- PDF reports → Domain repositories: stores report record (evidence: `backend/services/report_service.py`)
- Domain repositories → SQLite database: reads and writes (evidence: `backend/database/repositories.py`)
- FastAPI application → Runtime settings: loads settings (evidence: `backend/main.py`)
- Streamlit interface → Disease classifier: uses classifier (evidence: `plantdisease.py`)
- Streamlit interface → PDF reports: uses report service (evidence: `plantdisease.py`)
