# jeevan-shah/plant-mind architecture

> Architecture diagram of the GitHub repository jeevan-shah/plant-mind, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jeevan-shah/plant-mind
- Repository: https://github.com/jeevan-shah/plant-mind

## Overview

PlantMind is an explainable, per-plant care decision-support app. Users manage plant profiles and care history, submit an image and optional symptom text, then receive a personalized analysis with evidence, recommendations and limitations; they can also review history, explore the knowledge graph and ask the chat assistant questions. The documented analysis pipeline fuses image signals and plant context, retrieves graph and document evidence, applies optional LLM or deterministic reasoning, and persists the result. Connections for unsampled subsystems are included only where the README documents the capability; source excerpts and index establish the implementation links.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/lib/api.ts) (Typed API client), [`frontend/src/App.tsx`](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/App.tsx) (App router), [`backend/app/services/analysis_service.py`](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/analysis_service.py) (Analysis orchestration), [`backend/app/services/chat_service.py`](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/chat_service.py) (Chat reasoning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["PlantMind UI"]
  node_app["App router<br/>[App.tsx]"]
  node_plant_ui["Plant profiles<br/>[Plants.tsx]"]
  node_analyze_ui["Analysis submission<br/>[AnalyzePage.tsx]"]
  node_report_ui["Analysis report<br/>[AnalysisReport.tsx]"]
  node_history_ui["Analysis history<br/>[HistoryPage.tsx]"]
  node_knowledge_ui["Knowledge explorer"]
  node_chat_ui["Care chat<br/>[ChatAssistant.tsx]"]
  node_api_client["Typed API client<br/>[api.ts]"]
end

subgraph group_api["Application API"]
  node_plants_api["Plant endpoints<br/>[routes_plants.py]"]
  node_analysis_api["Analysis endpoints<br/>[routes_analyses.py]"]
  node_knowledge_api["Knowledge endpoints"]
  node_chat_api["Chat endpoint<br/>[routes_chat.py]"]
  node_meta_api["Dashboard and health<br/>[routes_meta.py]"]
  node_plant_service["Plant serialization<br/>[plant_service.py]"]
end

subgraph group_analysis["Plant Analysis"]
  node_analysis_orchestrator["Analysis orchestration"]
  node_vision["Demo vision<br/>[vision_service.py]"]
  node_plant_state["Plant state fusion"]
end

subgraph group_knowledge["Knowledge And Reasoning"]
  node_graphrag["GraphRAG retrieval"]
  node_knowledge_service["Knowledge graph access"]
  node_reasoner["Deterministic reasoning"]
  node_llm["Optional LLM<br/>[llm_service.py]"]
  node_chat_service["Chat reasoning<br/>[chat_service.py]"]
end

subgraph group_storage["Persistence"]
  node_database["Database session<br/>[database.py]"]
  node_models[("Plant and graph records<br/>[models.py]")]
end

node_gardener(("Plant caregiver"))

node_gardener -->|"uses"| node_app
node_app -->|"routes to"| node_plant_ui
node_app -->|"routes to"| node_analyze_ui
node_app -->|"routes to"| node_history_ui
node_app -->|"routes to"| node_knowledge_ui
node_analyze_ui -->|"submits through"| node_api_client
node_plant_ui -->|"requests through"| node_api_client
node_history_ui -.->|"requests through"| node_api_client
node_knowledge_ui -->|"searches through"| node_api_client
node_report_ui -->|"renders"| node_chat_ui
node_chat_ui -->|"sends questions"| node_api_client
node_api_client -->|"calls REST"| node_plants_api
node_api_client -->|"calls REST"| node_knowledge_api
node_api_client -.->|"calls REST"| node_chat_api
node_plants_api -->|"invokes"| node_analysis_orchestrator
node_plants_api -->|"serializes with"| node_plant_service
node_analysis_api -->|"serializes with"| node_plant_service
node_chat_api -->|"delegates to"| node_chat_service
node_knowledge_api -->|"queries"| node_knowledge_service
node_analysis_orchestrator -->|"analyzes image"| node_vision
node_analysis_orchestrator -->|"builds state"| node_plant_state
node_analysis_orchestrator -->|"retrieves evidence"| node_graphrag
node_graphrag -->|"expands graph"| node_knowledge_service
node_graphrag -->|"falls back to"| node_reasoner
node_graphrag -.->|"uses optionally"| node_llm
node_chat_service -->|"retrieves evidence"| node_graphrag
node_chat_service -->|"queries"| node_knowledge_service
node_chat_service -.->|"uses optionally"| node_llm
node_chat_service -->|"formats plant context"| node_plant_service
node_plants_api -->|"uses session"| node_database
node_knowledge_api -->|"uses session"| node_database
node_chat_api -->|"uses session"| node_database
node_database -->|"defines ORM base"| node_models
node_meta_api -->|"computes health"| node_plant_service
node_meta_api -->|"uses session"| node_database
node_analysis_orchestrator -->|"uses analysis records"| node_models

click node_app "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/App.tsx"
click node_plant_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/Plants.tsx"
click node_analyze_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/AnalyzePage.tsx"
click node_report_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/components/AnalysisReport.tsx"
click node_history_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/HistoryPage.tsx"
click node_knowledge_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/KnowledgeExplorer.tsx"
click node_chat_ui "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/components/ChatAssistant.tsx"
click node_api_client "https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/lib/api.ts"
click node_plants_api "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_plants.py"
click node_analysis_api "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_analyses.py"
click node_knowledge_api "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_knowledge.py"
click node_chat_api "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_chat.py"
click node_meta_api "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_meta.py"
click node_analysis_orchestrator "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/analysis_service.py"
click node_vision "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/vision_service.py"
click node_plant_state "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/plant_state_service.py"
click node_graphrag "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/graphrag_service.py"
click node_knowledge_service "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/knowledge_service.py"
click node_reasoner "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/reasoning_engine.py"
click node_llm "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/llm_service.py"
click node_chat_service "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/chat_service.py"
click node_plant_service "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/plant_service.py"
click node_database "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/database.py"
click node_models "https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/models.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_app,node_plant_ui,node_analyze_ui,node_report_ui,node_history_ui,node_knowledge_ui,node_chat_ui,node_api_client toneBlue
class node_plants_api,node_analysis_api,node_knowledge_api,node_chat_api,node_meta_api,node_plant_service toneAmber
class node_analysis_orchestrator,node_vision,node_plant_state toneMint
class node_graphrag,node_knowledge_service,node_reasoner,node_llm,node_chat_service toneRose
class node_database,node_models,node_gardener toneIndigo
```

## Components

### PlantMind UI

- [App router](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Plant profiles](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/Plants.tsx): `frontend/src/pages/Plants.tsx`
- [Analysis submission](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/AnalyzePage.tsx): `frontend/src/pages/AnalyzePage.tsx`
- [Analysis report](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/components/AnalysisReport.tsx): `frontend/src/components/AnalysisReport.tsx`
- [Analysis history](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/HistoryPage.tsx): `frontend/src/pages/HistoryPage.tsx`
- [Knowledge explorer](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/pages/KnowledgeExplorer.tsx): `frontend/src/pages/KnowledgeExplorer.tsx`
- [Care chat](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/components/ChatAssistant.tsx): `frontend/src/components/ChatAssistant.tsx`
- [Typed API client](https://github.com/jeevan-shah/plant-mind/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Application API

- [Plant endpoints](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_plants.py): `backend/app/api/routes_plants.py`
- [Analysis endpoints](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_analyses.py): `backend/app/api/routes_analyses.py`
- [Knowledge endpoints](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_knowledge.py): `backend/app/api/routes_knowledge.py`
- [Chat endpoint](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_chat.py): `backend/app/api/routes_chat.py`
- [Dashboard and health](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/api/routes_meta.py): `backend/app/api/routes_meta.py`
- [Plant serialization](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/plant_service.py): `backend/app/services/plant_service.py`

### Plant Analysis

- [Analysis orchestration](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/analysis_service.py): `backend/app/services/analysis_service.py`
- [Demo vision](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/vision_service.py): `backend/app/services/vision_service.py`
- [Plant state fusion](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/plant_state_service.py): `backend/app/services/plant_state_service.py`

### Knowledge And Reasoning

- [GraphRAG retrieval](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/graphrag_service.py): `backend/app/services/graphrag_service.py`
- [Knowledge graph access](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/knowledge_service.py): `backend/app/services/knowledge_service.py`
- [Deterministic reasoning](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/reasoning_engine.py): `backend/app/services/reasoning_engine.py`
- [Optional LLM](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`
- [Chat reasoning](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/services/chat_service.py): `backend/app/services/chat_service.py`

### Persistence

- [Database session](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/database.py): `backend/app/database.py`
- [Plant and graph records](https://github.com/jeevan-shah/plant-mind/blob/main/backend/app/models.py): `backend/app/models.py`

### Other components

- **Plant caregiver**

## Connections

- Plant caregiver → App router: uses (evidence: `README.md`)
- App router → Plant profiles: routes to (evidence: `frontend/src/App.tsx`)
- App router → Analysis submission: routes to (evidence: `frontend/src/App.tsx`)
- App router → Analysis history: routes to (evidence: `frontend/src/App.tsx`)
- App router → Knowledge explorer: routes to (evidence: `frontend/src/App.tsx`)
- Analysis submission → Typed API client: submits through (evidence: `frontend/src/pages/AnalyzePage.tsx`)
- Plant profiles → Typed API client: requests through (evidence: `frontend/src/pages/Plants.tsx`)
- Analysis history → Typed API client: requests through
- Knowledge explorer → Typed API client: searches through (evidence: `frontend/src/pages/KnowledgeExplorer.tsx`)
- Analysis report → Care chat: renders (evidence: `frontend/src/components/AnalysisReport.tsx`)
- Care chat → Typed API client: sends questions (evidence: `frontend/src/components/ChatAssistant.tsx`)
- Typed API client → Plant endpoints: calls REST (evidence: `README.md`)
- Typed API client → Knowledge endpoints: calls REST (evidence: `README.md`)
- Typed API client → Chat endpoint: calls REST
- Plant endpoints → Analysis orchestration: invokes (evidence: `backend/app/api/routes_plants.py`)
- Plant endpoints → Plant serialization: serializes with (evidence: `backend/app/api/routes_plants.py`)
- Analysis endpoints → Plant serialization: serializes with (evidence: `backend/app/api/routes_analyses.py`)
- Chat endpoint → Chat reasoning: delegates to (evidence: `backend/app/api/routes_chat.py`)
- Knowledge endpoints → Knowledge graph access: queries (evidence: `backend/app/api/routes_knowledge.py`)
- Analysis orchestration → Demo vision: analyzes image (evidence: `README.md`)
- Analysis orchestration → Plant state fusion: builds state (evidence: `README.md`)
- Analysis orchestration → GraphRAG retrieval: retrieves evidence (evidence: `README.md`)
- GraphRAG retrieval → Knowledge graph access: expands graph (evidence: `backend/app/services/graphrag_service.py`)
- GraphRAG retrieval → Deterministic reasoning: falls back to (evidence: `README.md`)
- GraphRAG retrieval → Optional LLM: uses optionally (evidence: `README.md`)
- Chat reasoning → GraphRAG retrieval: retrieves evidence (evidence: `backend/app/services/chat_service.py`)
- Chat reasoning → Knowledge graph access: queries (evidence: `backend/app/services/chat_service.py`)
- Chat reasoning → Optional LLM: uses optionally (evidence: `backend/app/services/chat_service.py`)
- Chat reasoning → Plant serialization: formats plant context (evidence: `backend/app/services/chat_service.py`)
- Plant endpoints → Database session: uses session (evidence: `backend/app/api/routes_plants.py`)
- Knowledge endpoints → Database session: uses session (evidence: `backend/app/api/routes_knowledge.py`)
- Chat endpoint → Database session: uses session (evidence: `backend/app/api/routes_chat.py`)
- Database session → Plant and graph records: defines ORM base (evidence: `backend/app/database.py`)
- Dashboard and health → Plant serialization: computes health (evidence: `backend/app/api/routes_meta.py`)
- Dashboard and health → Database session: uses session (evidence: `backend/app/api/routes_meta.py`)
- Analysis orchestration → Plant and graph records: uses analysis records (evidence: `backend/app/services/analysis_service.py`)
