# ankan00v/annrakshak architecture

> Architecture diagram of the GitHub repository ankan00v/annrakshak, 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/ankan00v/annrakshak
- Repository: https://github.com/ankan00v/annrakshak

## Overview

AnnRakshak is a crop-health early-warning system connecting farmer field observations to diagnosis, safe localized advice, expert validation, and district action. The main workflow runs from farmer app through API orchestration and decision engines to persisted cases and notifications; expert and officer consoles close the feedback loop. Weather, satellite, live scouting, and in-app help are distinct capabilities. Source excerpts establish selected calls and imports; other links below rely on explicit README descriptions, so unsampled implementation details are not inferred.

Main entry points: [`backend/app/services.py`](https://github.com/ankan00v/annrakshak/blob/main/backend/app/services.py) (Case orchestration), [`backend/app/routers/farmer.py`](https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/farmer.py) (Farmer routes), [`backend/app/main.py`](https://github.com/ankan00v/annrakshak/blob/main/backend/app/main.py) (HTTP API), [`backend/app/models.py`](https://github.com/ankan00v/annrakshak/blob/main/backend/app/models.py) (Farm and case store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_farmer["Farmer experience"]
  node_farmer_app["Farmer app<br/>[FarmerApp.tsx]"]
  node_farmer_scan["Photo and live scouting<br/>[Scan.tsx]"]
  node_farmer_weather["Weather and alerts<br/>[Weather.tsx]"]
  node_farmer_help["Krishi help<br/>[Krishi.tsx]"]
end

subgraph group_backend["Decision and services"]
  node_api["HTTP API<br/>[main.py]"]
  node_farmer_routes["Farmer routes<br/>[farmer.py]"]
  node_orchestration["Case orchestration<br/>[services.py]"]
  node_diagnosis["Image diagnosis<br/>[vision.py]"]
  node_decision_gate["Decision gate<br/>[gate.py]"]
  node_advisory["Advice and risk<br/>[advisory.py]"]
  node_live_engine["Live field scan<br/>[livescan.py]"]
  node_weather_risk["Weather forecasting<br/>[risk.py]"]
  node_satellite["Satellite monitoring<br/>[satellite.py]"]
end

subgraph group_district["Expert and district"]
  node_expert_queue["Review queue<br/>[expert.py]"]
  node_officer_console["District console<br/>[officials.py]"]
  node_darpan["Darpan insights<br/>[darpan.py]"]
end

subgraph group_platform["Shared platform"]
  node_notifications["Farmer notifications<br/>[notify.py]"]
  node_localization["Language and voice<br/>[i18n.py]"]
  node_voice["Speech services<br/>[voice.py]"]
  node_knowledge["Crop knowledge base<br/>[kb.py]"]
  node_auth["Identity and roles<br/>[auth.py]"]
  node_database[("Farm and case store<br/>[models.py]")]
end

subgraph group_learning["Model preparation"]
  node_training["Classifier training<br/>[train.py]"]
  node_image_prep["Image preparation<br/>[ingest_more.py]"]
  node_compositing["Background compositing<br/>[composite.py]"]
end

node_farmer_actor(("Farmer"))
node_expert_actor(("KVK expert"))

node_farmer_actor -->|"uses"| node_farmer_app
node_farmer_app -->|"starts scouting"| node_farmer_scan
node_farmer_scan -->|"submits evidence"| node_api
node_farmer_weather -->|"requests updates"| node_api
node_farmer_help -->|"asks field questions"| node_api
node_api -->|"routes requests"| node_farmer_routes
node_farmer_routes -->|"delegates"| node_orchestration
node_orchestration -->|"classifies image"| node_diagnosis
node_diagnosis -->|"screens prediction"| node_decision_gate
node_orchestration -->|"builds advice"| node_advisory
node_orchestration -->|"calculates risk"| node_weather_risk
node_farmer_routes -.->|"runs live check"| node_live_engine
node_orchestration -->|"reads field signals"| node_satellite
node_orchestration -->|"uses crop facts"| node_knowledge
node_farmer_routes -->|"reads and writes"| node_database
node_orchestration -.->|"persists cases"| node_database
node_orchestration -->|"localizes responses"| node_localization
node_localization -->|"uses speech"| node_voice
node_orchestration -->|"triggers updates"| node_notifications
node_farmer_routes -->|"checks access"| node_auth
node_expert_actor -->|"reviews cases"| node_expert_queue
node_expert_queue -.->|"resolves or refers"| node_orchestration
node_expert_queue -.->|"reviews case records"| node_database
node_orchestration -->|"shares verdict"| node_notifications
node_officer_console -.->|"reads district rows"| node_database
node_officer_console -->|"offers district answers"| node_darpan
node_weather_risk -->|"raises alerts"| node_notifications
node_training -->|"augments images"| node_compositing
node_image_prep -->|"checks plain backgrounds"| node_compositing
node_training -.->|"produces classifier artifact"| node_diagnosis

click node_farmer_app "https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/FarmerApp.tsx"
click node_farmer_scan "https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/screens/Scan.tsx"
click node_farmer_weather "https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/screens/Weather.tsx"
click node_farmer_help "https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/krishi/Krishi.tsx"
click node_api "https://github.com/ankan00v/annrakshak/blob/main/backend/app/main.py"
click node_farmer_routes "https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/farmer.py"
click node_orchestration "https://github.com/ankan00v/annrakshak/blob/main/backend/app/services.py"
click node_diagnosis "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/vision.py"
click node_decision_gate "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/gate.py"
click node_advisory "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/advisory.py"
click node_live_engine "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/livescan.py"
click node_weather_risk "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/risk.py"
click node_satellite "https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/satellite.py"
click node_expert_queue "https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/expert.py"
click node_officer_console "https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/officials.py"
click node_darpan "https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/darpan.py"
click node_notifications "https://github.com/ankan00v/annrakshak/blob/main/backend/app/notify.py"
click node_localization "https://github.com/ankan00v/annrakshak/blob/main/backend/app/i18n.py"
click node_voice "https://github.com/ankan00v/annrakshak/blob/main/backend/app/voice.py"
click node_knowledge "https://github.com/ankan00v/annrakshak/blob/main/backend/app/kb.py"
click node_auth "https://github.com/ankan00v/annrakshak/blob/main/backend/app/auth.py"
click node_database "https://github.com/ankan00v/annrakshak/blob/main/backend/app/models.py"
click node_training "https://github.com/ankan00v/annrakshak/blob/main/ml/train.py"
click node_image_prep "https://github.com/ankan00v/annrakshak/blob/main/data/ingest_more.py"
click node_compositing "https://github.com/ankan00v/annrakshak/blob/main/ml/composite.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_farmer_app,node_farmer_scan,node_farmer_weather,node_farmer_help toneBlue
class node_api,node_farmer_routes,node_orchestration,node_diagnosis,node_decision_gate,node_advisory,node_live_engine,node_weather_risk,node_satellite toneAmber
class node_expert_queue,node_officer_console,node_darpan toneMint
class node_notifications,node_localization,node_voice,node_knowledge,node_auth,node_database toneRose
class node_training,node_image_prep,node_compositing,node_farmer_actor,node_expert_actor toneIndigo
```

## Components

### Farmer experience

- [Farmer app](https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/FarmerApp.tsx): `frontend/landing/src/farmer/FarmerApp.tsx`
- [Photo and live scouting](https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/screens/Scan.tsx): `frontend/landing/src/farmer/screens/Scan.tsx`
- [Weather and alerts](https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/farmer/screens/Weather.tsx): `frontend/landing/src/farmer/screens/Weather.tsx`
- [Krishi help](https://github.com/ankan00v/annrakshak/blob/main/frontend/landing/src/krishi/Krishi.tsx): `frontend/landing/src/krishi/Krishi.tsx`

### Decision and services

- [HTTP API](https://github.com/ankan00v/annrakshak/blob/main/backend/app/main.py): `backend/app/main.py`
- [Farmer routes](https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/farmer.py): `backend/app/routers/farmer.py`
- [Case orchestration](https://github.com/ankan00v/annrakshak/blob/main/backend/app/services.py): `backend/app/services.py`
- [Image diagnosis](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/vision.py): `backend/app/engine/vision.py`
- [Decision gate](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/gate.py): `backend/app/engine/gate.py`
- [Advice and risk](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/advisory.py): `backend/app/engine/advisory.py`
- [Live field scan](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/livescan.py): `backend/app/engine/livescan.py`
- [Weather forecasting](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/risk.py): `backend/app/engine/risk.py`
- [Satellite monitoring](https://github.com/ankan00v/annrakshak/blob/main/backend/app/engine/satellite.py): `backend/app/engine/satellite.py`

### Expert and district

- [Review queue](https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/expert.py): `backend/app/routers/expert.py`
- [District console](https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/officials.py): `backend/app/routers/officials.py`
- [Darpan insights](https://github.com/ankan00v/annrakshak/blob/main/backend/app/routers/darpan.py): `backend/app/routers/darpan.py`

### Shared platform

- [Farmer notifications](https://github.com/ankan00v/annrakshak/blob/main/backend/app/notify.py): `backend/app/notify.py`
- [Language and voice](https://github.com/ankan00v/annrakshak/blob/main/backend/app/i18n.py): `backend/app/i18n.py`
- [Speech services](https://github.com/ankan00v/annrakshak/blob/main/backend/app/voice.py): `backend/app/voice.py`
- [Crop knowledge base](https://github.com/ankan00v/annrakshak/blob/main/backend/app/kb.py): `backend/app/kb.py`
- [Identity and roles](https://github.com/ankan00v/annrakshak/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Farm and case store](https://github.com/ankan00v/annrakshak/blob/main/backend/app/models.py): `backend/app/models.py`

### Model preparation

- [Classifier training](https://github.com/ankan00v/annrakshak/blob/main/ml/train.py): `ml/train.py`
- [Image preparation](https://github.com/ankan00v/annrakshak/blob/main/data/ingest_more.py): `data/ingest_more.py`
- [Background compositing](https://github.com/ankan00v/annrakshak/blob/main/ml/composite.py): `ml/composite.py`

### Other components

- **Farmer**
- **KVK expert**

## Connections

- Farmer → Farmer app: uses (evidence: `README.md`)
- Farmer app → Photo and live scouting: starts scouting (evidence: `frontend/landing/src/App.tsx`)
- Photo and live scouting → HTTP API: submits evidence (evidence: `README.md`)
- Weather and alerts → HTTP API: requests updates (evidence: `README.md`)
- Krishi help → HTTP API: asks field questions (evidence: `README.md`)
- HTTP API → Farmer routes: routes requests (evidence: `backend/app/main.py`)
- Farmer routes → Case orchestration: delegates (evidence: `backend/app/routers/farmer.py`)
- Case orchestration → Image diagnosis: classifies image (evidence: `backend/app/services.py`)
- Image diagnosis → Decision gate: screens prediction (evidence: `backend/app/engine/vision.py`)
- Case orchestration → Advice and risk: builds advice (evidence: `backend/app/services.py`)
- Case orchestration → Weather forecasting: calculates risk (evidence: `backend/app/services.py`)
- Farmer routes → Live field scan: runs live check
- Case orchestration → Satellite monitoring: reads field signals (evidence: `backend/app/services.py`)
- Case orchestration → Crop knowledge base: uses crop facts (evidence: `backend/app/services.py`)
- Farmer routes → Farm and case store: reads and writes (evidence: `backend/app/routers/farmer.py`)
- Case orchestration → Farm and case store: persists cases (evidence: `backend/app/services.py`)
- Case orchestration → Language and voice: localizes responses (evidence: `backend/app/services.py`)
- Language and voice → Speech services: uses speech (evidence: `backend/app/i18n.py`)
- Case orchestration → Farmer notifications: triggers updates (evidence: `backend/app/services.py`)
- Farmer routes → Identity and roles: checks access (evidence: `backend/app/routers/farmer.py`)
- KVK expert → Review queue: reviews cases (evidence: `README.md`)
- Review queue → Case orchestration: resolves or refers
- Review queue → Farm and case store: reviews case records
- Case orchestration → Farmer notifications: shares verdict (evidence: `README.md`)
- District console → Farm and case store: reads district rows
- District console → Darpan insights: offers district answers (evidence: `README.md`)
- Weather forecasting → Farmer notifications: raises alerts (evidence: `README.md`)
- Classifier training → Background compositing: augments images (evidence: `ml/composite.py`)
- Image preparation → Background compositing: checks plain backgrounds (evidence: `data/ingest_more.py`)
- Classifier training → Image diagnosis: produces classifier artifact
