# sxnjai23/agro-guard--ai architecture

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

- Interactive diagram: https://gitdiagram.com/sxnjai23/agro-guard--ai
- Repository: https://github.com/sxnjai23/agro-guard--ai

## Overview

AgroGuard AI is a frontend crop-health assistant. The main user flow is account login or registration, then image submission for disease analysis or a text question answered by the app’s rule-based chat; voice input is also exposed in the chat UI. Routing also provides history, about, and developer screens. Source excerpts show the routing, API calls, and chat behavior, but not the history data source or the backend implementation, so those connections are not inferred.

Main entry points: [`src/app/routes.ts`](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/routes.ts) (Route table), [`src/api.ts`](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/api.ts) (API client and chat rules), [`src/app/components/Chat.tsx`](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Chat.tsx) (Crop chat and analysis), [`src/app/components/Login.tsx`](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Login.tsx) (Login and signup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App shell and routing"]
  node_app["App entry<br/>[App.tsx]"]
  node_routes["Route table<br/>[routes.ts]"]
  node_root["Root layout<br/>[Root.tsx]"]
end

subgraph group_crop["Crop assistance"]
  node_api["API client and chat rules<br/>[api.ts]"]
  node_chat["Crop chat and analysis<br/>[Chat.tsx]"]
end

subgraph group_identity["Account access"]
  node_login["Login and signup<br/>[Login.tsx]"]
end

subgraph group_support["Information screens"]
  node_history["History screen<br/>[History.tsx]"]
  node_about["About screen<br/>[About.tsx]"]
  node_developer["Developer screen<br/>[Developer.tsx]"]
end

subgraph group_ui["Shared UI"]
  node_ui["Shared UI components"]
end

node_user(("App user"))
node_backend{{"AgroGuard API"}}

node_user -->|"opens"| node_app
node_app -->|"provides routes"| node_routes
node_routes -->|"routes to"| node_root
node_routes -->|"routes to"| node_login
node_routes -->|"routes to"| node_chat
node_routes -->|"routes to"| node_history
node_routes -->|"routes to"| node_about
node_routes -->|"routes to"| node_developer
node_user -->|"submits credentials"| node_login
node_login -->|"calls auth"| node_api
node_api -->|"sends auth requests"| node_backend
node_user -->|"asks or uploads"| node_chat
node_chat -->|"requests analysis or reply"| node_api
node_api -->|"posts image"| node_backend
node_api -->|"returns rule-based reply"| node_chat
node_api -.->|"transcribes audio"| node_backend
node_chat -->|"renders controls"| node_ui
node_login -->|"renders controls"| node_ui

click node_app "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/App.tsx"
click node_routes "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/routes.ts"
click node_root "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Root.tsx"
click node_login "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Login.tsx"
click node_api "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/api.ts"
click node_chat "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Chat.tsx"
click node_history "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/History.tsx"
click node_about "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/About.tsx"
click node_developer "https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Developer.tsx"
click node_ui "https://github.com/sxnjai23/agro-guard--ai/tree/main/src/app/components/ui"

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_routes,node_root,node_user toneBlue
class node_api,node_chat toneAmber
class node_login,node_backend toneMint
class node_history,node_about,node_developer toneRose
class node_ui toneIndigo
```

## Components

### App shell and routing

- [App entry](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [Route table](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/routes.ts): `src/app/routes.ts`
- [Root layout](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Root.tsx): `src/app/components/Root.tsx`

### Crop assistance

- [API client and chat rules](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/api.ts): `src/api.ts`
- [Crop chat and analysis](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Chat.tsx): `src/app/components/Chat.tsx`

### Account access

- [Login and signup](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Login.tsx): `src/app/components/Login.tsx`

### Information screens

- [History screen](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/History.tsx): `src/app/components/History.tsx`
- [About screen](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/About.tsx): `src/app/components/About.tsx`
- [Developer screen](https://github.com/sxnjai23/agro-guard--ai/blob/main/src/app/components/Developer.tsx): `src/app/components/Developer.tsx`

### Shared UI

- [Shared UI components](https://github.com/sxnjai23/agro-guard--ai/tree/main/src/app/components/ui): `src/app/components/ui`

### Other components

- **App user**
- **AgroGuard API**

## Connections

- App user → App entry: opens
- App entry → Route table: provides routes (evidence: `src/app/App.tsx`)
- Route table → Root layout: routes to (evidence: `src/app/routes.ts`)
- Route table → Login and signup: routes to (evidence: `src/app/routes.ts`)
- Route table → Crop chat and analysis: routes to (evidence: `src/app/routes.ts`)
- Route table → History screen: routes to (evidence: `src/app/routes.ts`)
- Route table → About screen: routes to (evidence: `src/app/routes.ts`)
- Route table → Developer screen: routes to (evidence: `src/app/routes.ts`)
- App user → Login and signup: submits credentials (evidence: `src/app/components/Login.tsx`)
- Login and signup → API client and chat rules: calls auth (evidence: `src/app/components/Login.tsx`)
- API client and chat rules → AgroGuard API: sends auth requests (evidence: `src/api.ts`)
- App user → Crop chat and analysis: asks or uploads (evidence: `src/app/components/Chat.tsx`)
- Crop chat and analysis → API client and chat rules: requests analysis or reply (evidence: `src/app/components/Chat.tsx`)
- API client and chat rules → AgroGuard API: posts image (evidence: `src/api.ts`)
- API client and chat rules → Crop chat and analysis: returns rule-based reply (evidence: `src/api.ts`)
- API client and chat rules → AgroGuard API: transcribes audio (evidence: `src/api.ts`)
- Crop chat and analysis → Shared UI components: renders controls (evidence: `src/app/components/Chat.tsx`)
- Login and signup → Shared UI components: renders controls (evidence: `src/app/components/Login.tsx`)
