# raysoumyadip01-tech/agrinova architecture

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

- Interactive diagram: https://gitdiagram.com/raysoumyadip01-tech/agrinova
- Repository: https://github.com/raysoumyadip01-tech/agrinova

## Overview

AgriNova is a farm-to-market and cold-chain operations platform spanning farmer, warehouse, transporter, retailer, and admin roles. Users authenticate, enter a role-specific workspace, manage produce and shipments, and use tracking, spoilage-risk, redistribution, payment, and governance capabilities. The React client calls an API service; the repository documents both a Node/SQLite server and an optional FastAPI backend. Source excerpts confirm frontend routing, authentication, and selected backend internals; several feature components and backend routers are unsampled, so their detailed call paths are not asserted.

Main entry points: [`src/services/api.ts`](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/services/api.ts) (API client), [`src/pages/DashboardLayout.tsx`](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/pages/DashboardLayout.tsx) (Role workspaces), [`backend/app/routers/auth.py`](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/auth.py) (Authentication routes), [`backend/app/models.py`](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/models.py) (Domain records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.tsx]"]
  node_authpage["Sign-in UI<br/>[AuthPage.tsx]"]
  node_dashboard["Role workspaces"]
  node_api["API client<br/>[api.ts]"]
end

subgraph group_operations["Supply chain operations"]
  node_farmer["Farmer workspace"]
  node_enterprise["Operations console"]
  node_tracking["Shipment map<br/>[SupplyChainMap.tsx]"]
  node_foodbot["FoodBot assistant<br/>[FoodBotWidget.tsx]"]
  node_speech["Voice assistance<br/>[speech.ts]"]
  node_translations["Role translations"]
end

subgraph group_backend["Backend services"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_authroutes["Authentication routes<br/>[auth.py]"]
  node_dashroutes["Dashboard routes<br/>[dashboard.py]"]
  node_supplyroutes["Supply-chain routes<br/>[supply_chain.py]"]
  node_spoilage["Spoilage scoring<br/>[spoilage_ai.py]"]
  node_nodebackend["Node demo backend<br/>[server.ts]"]
end

subgraph group_identity["Identity and persistence"]
  node_authcontext["Auth state<br/>[AuthContext.tsx]"]
  node_firebase["Firebase client<br/>[firebase.ts]"]
  node_security["Token and RBAC<br/>[security.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

node_user(("Platform users"))
node_weather["Open-Meteo"]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_authpage
node_app -->|"routes to"| node_dashboard
node_authpage -->|"uses auth"| node_authcontext
node_authcontext -->|"calls"| node_api
node_authcontext -->|"syncs profile"| node_firebase
node_dashboard -->|"renders"| node_farmer
node_dashboard -->|"renders"| node_enterprise
node_dashboard -->|"renders"| node_foodbot
node_dashboard -->|"uses voice"| node_speech
node_dashboard -->|"loads language"| node_translations
node_enterprise -->|"renders"| node_tracking
node_enterprise -->|"calls"| node_api
node_speech -->|"requests voice services"| node_api
node_foodbot -.->|"uses assistant API"| node_api
node_api -->|"requests auth endpoints"| node_authroutes
node_api -->|"requests dashboard endpoints"| node_dashroutes
node_api -->|"requests operations endpoints"| node_supplyroutes
node_api -.->|"targets demo server"| node_nodebackend
node_fastapi -->|"registers"| node_authroutes
node_fastapi -->|"registers"| node_dashroutes
node_fastapi -->|"registers"| node_supplyroutes
node_authroutes -->|"creates and checks tokens"| node_security
node_authroutes -->|"queries records"| node_models
node_authroutes -->|"gets sessions"| node_database
node_dashroutes -->|"uses records"| node_models
node_supplyroutes -->|"uses risk scoring"| node_spoilage
node_supplyroutes -->|"uses records"| node_models
node_security -->|"checks users and sessions"| node_models
node_security -->|"gets database session"| node_database
node_models -->|"uses ORM base"| node_database
node_database -.->|"fetches forecast"| node_weather

click node_app "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/App.tsx"
click node_authpage "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/pages/AuthPage.tsx"
click node_dashboard "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/pages/DashboardLayout.tsx"
click node_farmer "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/FarmerWorkspace.tsx"
click node_enterprise "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/EnterpriseOperationsTabs.tsx"
click node_tracking "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/SupplyChainMap.tsx"
click node_foodbot "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/FoodBotWidget.tsx"
click node_speech "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/utils/speech.ts"
click node_translations "https://github.com/raysoumyadip01-tech/agrinova/tree/main/src/i18n"
click node_api "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/services/api.ts"
click node_authcontext "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/context/AuthContext.tsx"
click node_firebase "https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/lib/firebase.ts"
click node_fastapi "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/auth.py"
click node_dashroutes "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/dashboard.py"
click node_supplyroutes "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/supply_chain.py"
click node_spoilage "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/spoilage_ai.py"
click node_security "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/security.py"
click node_models "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/models.py"
click node_database "https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/database.py"
click node_nodebackend "https://github.com/raysoumyadip01-tech/agrinova/blob/main/server.ts"

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_authpage,node_dashboard,node_api,node_user toneBlue
class node_farmer,node_enterprise,node_tracking,node_foodbot,node_speech,node_translations toneAmber
class node_fastapi,node_authroutes,node_dashroutes,node_supplyroutes,node_spoilage,node_nodebackend toneMint
class node_authcontext,node_firebase,node_security,node_models,node_database toneRose
class node_weather toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in UI](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/pages/AuthPage.tsx): `src/pages/AuthPage.tsx`
- [Role workspaces](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/pages/DashboardLayout.tsx): `src/pages/DashboardLayout.tsx`
- [API client](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/services/api.ts): `src/services/api.ts`

### Supply chain operations

- [Farmer workspace](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/FarmerWorkspace.tsx): `src/components/FarmerWorkspace.tsx`
- [Operations console](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/EnterpriseOperationsTabs.tsx): `src/components/EnterpriseOperationsTabs.tsx`
- [Shipment map](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/SupplyChainMap.tsx): `src/components/SupplyChainMap.tsx`
- [FoodBot assistant](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/components/FoodBotWidget.tsx): `src/components/FoodBotWidget.tsx`
- [Voice assistance](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/utils/speech.ts): `src/utils/speech.ts`
- [Role translations](https://github.com/raysoumyadip01-tech/agrinova/tree/main/src/i18n): `src/i18n`

### Backend services

- [FastAPI application](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Dashboard routes](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/dashboard.py): `backend/app/routers/dashboard.py`
- [Supply-chain routes](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/routers/supply_chain.py): `backend/app/routers/supply_chain.py`
- [Spoilage scoring](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/spoilage_ai.py): `backend/app/spoilage_ai.py`
- [Node demo backend](https://github.com/raysoumyadip01-tech/agrinova/blob/main/server.ts): `server.ts`

### Identity and persistence

- [Auth state](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Firebase client](https://github.com/raysoumyadip01-tech/agrinova/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`
- [Token and RBAC](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/security.py): `backend/app/security.py`
- [Domain records](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/models.py): `backend/app/models.py`
- [SQL database](https://github.com/raysoumyadip01-tech/agrinova/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Platform users**
- **Open-Meteo**

## Connections

- Platform users → App routing: opens (evidence: `README.md`)
- App routing → Sign-in UI: routes to (evidence: `src/App.tsx`)
- App routing → Role workspaces: routes to (evidence: `src/App.tsx`)
- Sign-in UI → Auth state: uses auth (evidence: `src/pages/AuthPage.tsx`)
- Auth state → API client: calls (evidence: `src/context/AuthContext.tsx`)
- Auth state → Firebase client: syncs profile (evidence: `src/context/AuthContext.tsx`)
- Role workspaces → Farmer workspace: renders (evidence: `src/pages/DashboardLayout.tsx`)
- Role workspaces → Operations console: renders (evidence: `src/pages/DashboardLayout.tsx`)
- Role workspaces → FoodBot assistant: renders (evidence: `src/pages/DashboardLayout.tsx`)
- Role workspaces → Voice assistance: uses voice (evidence: `src/pages/DashboardLayout.tsx`)
- Role workspaces → Role translations: loads language (evidence: `src/pages/DashboardLayout.tsx`)
- Operations console → Shipment map: renders (evidence: `src/components/EnterpriseOperationsTabs.tsx`)
- Operations console → API client: calls (evidence: `src/components/EnterpriseOperationsTabs.tsx`)
- Voice assistance → API client: requests voice services (evidence: `src/utils/speech.ts`)
- FoodBot assistant → API client: uses assistant API
- API client → Authentication routes: requests auth endpoints (evidence: `README.md`)
- API client → Dashboard routes: requests dashboard endpoints (evidence: `README.md`)
- API client → Supply-chain routes: requests operations endpoints (evidence: `README.md`)
- API client → Node demo backend: targets demo server
- FastAPI application → Authentication routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Dashboard routes: registers (evidence: `backend/app/main.py`)
- FastAPI application → Supply-chain routes: registers (evidence: `backend/app/main.py`)
- Authentication routes → Token and RBAC: creates and checks tokens (evidence: `backend/app/routers/auth.py`)
- Authentication routes → Domain records: queries records (evidence: `backend/app/routers/auth.py`)
- Authentication routes → SQL database: gets sessions (evidence: `backend/app/routers/auth.py`)
- Dashboard routes → Domain records: uses records (evidence: `backend/app/routers/dashboard.py`)
- Supply-chain routes → Spoilage scoring: uses risk scoring (evidence: `backend/app/routers/supply_chain.py`)
- Supply-chain routes → Domain records: uses records (evidence: `backend/app/routers/supply_chain.py`)
- Token and RBAC → Domain records: checks users and sessions (evidence: `backend/app/security.py`)
- Token and RBAC → SQL database: gets database session (evidence: `backend/app/security.py`)
- Domain records → SQL database: uses ORM base (evidence: `backend/app/models.py`)
- SQL database → Open-Meteo: fetches forecast
