# vignesh81232/agriguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/vignesh81232/agriguard-ai
- Repository: https://github.com/vignesh81232/agriguard-ai

## Overview

AgriGuard is a crop-leaf diagnosis web app. A grower uploads a leaf image, optionally selects a crop or describes symptoms, and receives a model-generated diagnosis with localized disease guidance, severity, care advice, and nearby-store information. Accounts and diagnosis history are stored locally in the browser. The graph follows the shown client-to-server diagnosis path and the app’s documented component wiring; server internals and the store-locator implementation were not excerpted, so uncertain relationships are omitted or marked unverified.

Main entry points: [`src/App.tsx`](https://github.com/vignesh81232/agriguard-ai/blob/main/src/App.tsx) (App coordinator), [`src/components/CaptureCard.tsx`](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/CaptureCard.tsx) (Leaf capture), [`src/components/ResultsDashboard.tsx`](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/ResultsDashboard.tsx) (Results dashboard), [`src/i18n/index.tsx`](https://github.com/vignesh81232/agriguard-ai/blob/main/src/i18n/index.tsx) (Language provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and workflow"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_capture["Leaf capture<br/>[CaptureCard.tsx]"]
  node_speech["Speech input"]
  node_auth["Account screen<br/>[AuthScreen.tsx]"]
  node_topbar["Top bar<br/>[TopBar.tsx]"]
end

subgraph group_diagnosis["Diagnosis and guidance"]
  node_diagnose["Diagnosis client<br/>[diagnose.ts]"]
  node_diseases["Disease guidance<br/>[diseases.ts]"]
  node_healthy["Healthy counterpart"]
  node_store_data["Store listings<br/>[stores.ts]"]
end

subgraph group_account["Local accounts"]
  node_accounts["Local accounts and history<br/>[localAccounts.ts]"]
  node_account_db[("Browser account store<br/>[localAccounts.ts]")]
end

subgraph group_presentation["Shared presentation"]
  node_summary["Diagnosis summary<br/>[ResultsSummary.tsx]"]
  node_dashboard["Results dashboard"]
  node_stores["Store locator<br/>[StoreLocator.tsx]"]
  node_i18n["Language provider<br/>[index.tsx]"]
  node_translations["Translations<br/>[translations.ts]"]
  node_icons["Icon set<br/>[icons.tsx]"]
end

subgraph group_service["Diagnosis service"]
  node_api["Diagnosis API<br/>[server.js]"]
  node_gemini["Gemini analysis<br/>[gemini.js]"]
end

node_grower(("Grower"))
node_gemini_service["Gemini service"]

node_grower -->|"uses"| node_app
node_app -->|"renders"| node_auth
node_app -->|"renders"| node_capture
node_app -->|"renders"| node_topbar
node_app -->|"renders"| node_summary
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_stores
node_capture -->|"uses"| node_speech
node_capture -->|"submits image"| node_diagnose
node_diagnose -->|"POST diagnosis"| node_api
node_api -->|"dispatches"| node_gemini
node_gemini -.->|"analyzes image"| node_gemini_service
node_diagnose -->|"returns result"| node_capture
node_app -->|"loads session and history"| node_accounts
node_auth -->|"registers or signs in"| node_accounts
node_accounts -->|"reads and writes"| node_account_db
node_summary -->|"gets localized guidance"| node_diseases
node_dashboard -->|"reads guidance"| node_diseases
node_dashboard -->|"uses comparison"| node_healthy
node_stores -->|"reads listings"| node_store_data
node_stores -->|"shows locations"| node_grower
node_auth -->|"uses translations"| node_i18n
node_capture -->|"uses translations"| node_i18n
node_i18n -->|"loads dictionaries"| node_translations
node_app -->|"provides language context"| node_i18n
node_capture -->|"renders icons"| node_icons
node_summary -->|"renders icons"| node_icons
node_dashboard -->|"renders icons"| node_icons

click node_app "https://github.com/vignesh81232/agriguard-ai/blob/main/src/App.tsx"
click node_capture "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/CaptureCard.tsx"
click node_speech "https://github.com/vignesh81232/agriguard-ai/blob/main/src/hooks/useSpeechRecognition.ts"
click node_auth "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/AuthScreen.tsx"
click node_topbar "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/TopBar.tsx"
click node_diagnose "https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/diagnose.ts"
click node_api "https://github.com/vignesh81232/agriguard-ai/blob/main/server.js"
click node_gemini "https://github.com/vignesh81232/agriguard-ai/blob/main/server/gemini.js"
click node_diseases "https://github.com/vignesh81232/agriguard-ai/blob/main/src/data/diseases.ts"
click node_healthy "https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/healthyCounterpart.ts"
click node_summary "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/ResultsSummary.tsx"
click node_dashboard "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/ResultsDashboard.tsx"
click node_stores "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/StoreLocator.tsx"
click node_store_data "https://github.com/vignesh81232/agriguard-ai/blob/main/src/data/stores.ts"
click node_accounts "https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/localAccounts.ts"
click node_account_db "https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/localAccounts.ts"
click node_i18n "https://github.com/vignesh81232/agriguard-ai/blob/main/src/i18n/index.tsx"
click node_translations "https://github.com/vignesh81232/agriguard-ai/blob/main/src/i18n/translations.ts"
click node_icons "https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/icons.tsx"

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_capture,node_speech,node_auth,node_topbar toneBlue
class node_diagnose,node_diseases,node_healthy,node_store_data toneAmber
class node_accounts,node_account_db toneMint
class node_summary,node_dashboard,node_stores,node_i18n,node_translations,node_icons toneRose
class node_api,node_gemini,node_grower,node_gemini_service toneIndigo
```

## Components

### App and workflow

- [App coordinator](https://github.com/vignesh81232/agriguard-ai/blob/main/src/App.tsx): `src/App.tsx`
- [Leaf capture](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/CaptureCard.tsx): `src/components/CaptureCard.tsx`
- [Speech input](https://github.com/vignesh81232/agriguard-ai/blob/main/src/hooks/useSpeechRecognition.ts): `src/hooks/useSpeechRecognition.ts`
- [Account screen](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/AuthScreen.tsx): `src/components/AuthScreen.tsx`
- [Top bar](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/TopBar.tsx): `src/components/TopBar.tsx`

### Diagnosis and guidance

- [Diagnosis client](https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/diagnose.ts): `src/lib/diagnose.ts`
- [Disease guidance](https://github.com/vignesh81232/agriguard-ai/blob/main/src/data/diseases.ts): `src/data/diseases.ts`
- [Healthy counterpart](https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/healthyCounterpart.ts): `src/lib/healthyCounterpart.ts`
- [Store listings](https://github.com/vignesh81232/agriguard-ai/blob/main/src/data/stores.ts): `src/data/stores.ts`

### Local accounts

- [Local accounts and history](https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/localAccounts.ts): `src/lib/localAccounts.ts`
- [Browser account store](https://github.com/vignesh81232/agriguard-ai/blob/main/src/lib/localAccounts.ts): `src/lib/localAccounts.ts`

### Shared presentation

- [Diagnosis summary](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/ResultsSummary.tsx): `src/components/ResultsSummary.tsx`
- [Results dashboard](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/ResultsDashboard.tsx): `src/components/ResultsDashboard.tsx`
- [Store locator](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/StoreLocator.tsx): `src/components/StoreLocator.tsx`
- [Language provider](https://github.com/vignesh81232/agriguard-ai/blob/main/src/i18n/index.tsx): `src/i18n/index.tsx`
- [Translations](https://github.com/vignesh81232/agriguard-ai/blob/main/src/i18n/translations.ts): `src/i18n/translations.ts`
- [Icon set](https://github.com/vignesh81232/agriguard-ai/blob/main/src/components/icons.tsx): `src/components/icons.tsx`

### Diagnosis service

- [Diagnosis API](https://github.com/vignesh81232/agriguard-ai/blob/main/server.js): `server.js`
- [Gemini analysis](https://github.com/vignesh81232/agriguard-ai/blob/main/server/gemini.js): `server/gemini.js`

### Other components

- **Grower**
- **Gemini service**

## Connections

- Grower → App coordinator: uses (evidence: `src/App.tsx`)
- App coordinator → Account screen: renders (evidence: `src/App.tsx`)
- App coordinator → Leaf capture: renders (evidence: `src/App.tsx`)
- App coordinator → Top bar: renders (evidence: `src/App.tsx`)
- App coordinator → Diagnosis summary: renders (evidence: `src/App.tsx`)
- App coordinator → Results dashboard: renders (evidence: `src/App.tsx`)
- App coordinator → Store locator: renders (evidence: `src/App.tsx`)
- Leaf capture → Speech input: uses (evidence: `src/components/CaptureCard.tsx`)
- Leaf capture → Diagnosis client: submits image (evidence: `src/components/CaptureCard.tsx`)
- Diagnosis client → Diagnosis API: POST diagnosis (evidence: `src/lib/diagnose.ts`)
- Diagnosis API → Gemini analysis: dispatches (evidence: `server.js`)
- Gemini analysis → Gemini service: analyzes image
- Diagnosis client → Leaf capture: returns result (evidence: `src/components/CaptureCard.tsx`)
- App coordinator → Local accounts and history: loads session and history (evidence: `src/App.tsx`)
- Account screen → Local accounts and history: registers or signs in (evidence: `src/components/AuthScreen.tsx`)
- Local accounts and history → Browser account store: reads and writes (evidence: `src/lib/localAccounts.ts`)
- Diagnosis summary → Disease guidance: gets localized guidance (evidence: `src/components/ResultsSummary.tsx`)
- Results dashboard → Disease guidance: reads guidance (evidence: `src/components/ResultsDashboard.tsx`)
- Results dashboard → Healthy counterpart: uses comparison (evidence: `src/components/ResultsDashboard.tsx`)
- Store locator → Store listings: reads listings (evidence: `src/components/StoreLocator.tsx`)
- Store locator → Grower: shows locations (evidence: `src/components/StoreLocator.tsx`)
- Account screen → Language provider: uses translations (evidence: `src/components/AuthScreen.tsx`)
- Leaf capture → Language provider: uses translations (evidence: `src/components/CaptureCard.tsx`)
- Language provider → Translations: loads dictionaries (evidence: `src/i18n/index.tsx`)
- App coordinator → Language provider: provides language context (evidence: `src/App.tsx`)
- Leaf capture → Icon set: renders icons (evidence: `src/components/CaptureCard.tsx`)
- Diagnosis summary → Icon set: renders icons (evidence: `src/components/ResultsSummary.tsx`)
- Results dashboard → Icon set: renders icons (evidence: `src/components/ResultsDashboard.tsx`)
