# yagnaakula229/herbvision architecture

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

- Interactive diagram: https://gitdiagram.com/yagnaakula229/herbvision
- Repository: https://github.com/yagnaakula229/herbvision

## Overview

HerbVision is a medicinal-plant identification web app. Users register or log in, then upload a plant image; the protected dashboard submits it for top-three classification, displays confidence and medicinal guidance, and refreshes per-user prediction history. The Flask backend handles authentication and prediction requests, runs image preprocessing and DenseNet inference, and persists results in SQLite. The graph follows the documented React-to-Flask workflow and sampled calls; unsampled behavior is represented only where README capabilities support it.

Main entry points: [`frontend/src/pages/Dashboard.jsx`](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Dashboard.jsx) (Dashboard), [`backend/app.py`](https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py) (Flask API), [`frontend/src/api.js`](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/api.js) (API client), [`frontend/src/App.jsx`](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/App.jsx) (Protected routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["React application"]
  node_app_entry["App bootstrap<br/>[main.jsx]"]
  node_routing["Protected routing<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_upload["Image upload<br/>[ImageUpload.jsx]"]
  node_result_view["Results display<br/>[ResultCard.jsx]"]
end

subgraph group_identity["Identity and access"]
  node_login["Login form<br/>[Login.jsx]"]
  node_registration["Registration form<br/>[Register.jsx]"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_auth_logic["Authentication<br/>[app.py]"]
end

subgraph group_classification["Plant classification"]
  node_inference["Image inference<br/>[app.py]"]
  node_plant_guidance["Plant guidance<br/>[plant_tips.py]"]
end

subgraph group_persistence["Prediction persistence"]
  node_user_record["User records<br/>[models.py]"]
  node_prediction_record["Prediction records<br/>[models.py]"]
  node_sqlite[("SQLite database<br/>[app.py]")]
end

node_visitor(("User"))

node_visitor -->|"opens app"| node_app_entry
node_app_entry -->|"renders"| node_routing
node_routing -->|"routes to"| node_login
node_routing -->|"routes to"| node_registration
node_routing -->|"protects route"| node_dashboard
node_login -->|"submits credentials"| node_api_client
node_registration -->|"submits credentials"| node_api_client
node_api_client -->|"sends requests"| node_flask_api
node_dashboard -->|"requests history"| node_api_client
node_dashboard -->|"renders"| node_navbar
node_dashboard -->|"renders"| node_upload
node_dashboard -->|"renders results"| node_result_view
node_upload -->|"submits file"| node_dashboard
node_dashboard -->|"submits image"| node_api_client
node_flask_api -->|"handles auth"| node_auth_logic
node_flask_api -->|"runs prediction"| node_inference
node_inference -->|"looks up tips"| node_plant_guidance
node_flask_api -->|"queries users"| node_user_record
node_flask_api -->|"reads and writes"| node_prediction_record
node_user_record -->|"persists"| node_sqlite
node_prediction_record -->|"persists"| node_sqlite

click node_app_entry "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/main.jsx"
click node_routing "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Login.jsx"
click node_registration "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Register.jsx"
click node_api_client "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/api.js"
click node_dashboard "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Dashboard.jsx"
click node_navbar "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/Navbar.jsx"
click node_upload "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/ImageUpload.jsx"
click node_result_view "https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/ResultCard.jsx"
click node_flask_api "https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py"
click node_auth_logic "https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py"
click node_inference "https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py"
click node_plant_guidance "https://github.com/yagnaakula229/herbvision/blob/main/backend/plant_tips.py"
click node_user_record "https://github.com/yagnaakula229/herbvision/blob/main/backend/models.py"
click node_prediction_record "https://github.com/yagnaakula229/herbvision/blob/main/backend/models.py"
click node_sqlite "https://github.com/yagnaakula229/herbvision/blob/main/backend/app.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_entry,node_routing,node_api_client,node_dashboard,node_navbar,node_upload,node_result_view,node_visitor toneBlue
class node_login,node_registration,node_flask_api,node_auth_logic toneAmber
class node_inference,node_plant_guidance toneMint
class node_user_record,node_prediction_record,node_sqlite toneRose
```

## Components

### React application

- [App bootstrap](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Protected routing](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API client](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Dashboard](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Navigation](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Image upload](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/ImageUpload.jsx): `frontend/src/components/ImageUpload.jsx`
- [Results display](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/components/ResultCard.jsx): `frontend/src/components/ResultCard.jsx`

### Identity and access

- [Login form](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration form](https://github.com/yagnaakula229/herbvision/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Flask API](https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py): `backend/app.py`
- [Authentication](https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py): `backend/app.py`

### Plant classification

- [Image inference](https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py): `backend/app.py`
- [Plant guidance](https://github.com/yagnaakula229/herbvision/blob/main/backend/plant_tips.py): `backend/plant_tips.py`

### Prediction persistence

- [User records](https://github.com/yagnaakula229/herbvision/blob/main/backend/models.py): `backend/models.py`
- [Prediction records](https://github.com/yagnaakula229/herbvision/blob/main/backend/models.py): `backend/models.py`
- [SQLite database](https://github.com/yagnaakula229/herbvision/blob/main/backend/app.py): `backend/app.py`

### Other components

- **User**

## Connections

- User → App bootstrap: opens app (evidence: `README.md`)
- App bootstrap → Protected routing: renders (evidence: `frontend/src/main.jsx`)
- Protected routing → Login form: routes to (evidence: `frontend/src/App.jsx`)
- Protected routing → Registration form: routes to (evidence: `frontend/src/App.jsx`)
- Protected routing → Dashboard: protects route (evidence: `frontend/src/App.jsx`)
- Login form → API client: submits credentials (evidence: `frontend/src/pages/Login.jsx`)
- Registration form → API client: submits credentials (evidence: `frontend/src/pages/Register.jsx`)
- API client → Flask API: sends requests (evidence: `README.md`)
- Dashboard → API client: requests history (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Navigation: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Image upload: renders (evidence: `frontend/src/pages/Dashboard.jsx`)
- Dashboard → Results display: renders results (evidence: `frontend/src/pages/Dashboard.jsx`)
- Image upload → Dashboard: submits file (evidence: `frontend/src/components/ImageUpload.jsx`)
- Dashboard → API client: submits image (evidence: `frontend/src/pages/Dashboard.jsx`)
- Flask API → Authentication: handles auth (evidence: `backend/app.py`)
- Flask API → Image inference: runs prediction (evidence: `backend/app.py`)
- Image inference → Plant guidance: looks up tips (evidence: `backend/app.py`)
- Flask API → User records: queries users (evidence: `backend/app.py`)
- Flask API → Prediction records: reads and writes (evidence: `backend/app.py`)
- User records → SQLite database: persists (evidence: `backend/app.py`)
- Prediction records → SQLite database: persists (evidence: `backend/app.py`)
