# rohan45create/ashaai-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/rohan45create/ashaai-v2
- Repository: https://github.com/rohan45create/ashaai-v2

## Overview

AshaAI digitizes frontline ASHA health work and supervisor/NGO coordination. The principal flow is worker data capture (including voice, register OCR, and health forms), optional offline queuing, backend processing and persistence, then risk and review workflows for supervisors. The React PWA, Spring Boot API, and FastAPI AI service form the documented runtime. The graph preserves the README’s major capabilities; several subsystem connections are documented rather than verified from sampled implementation, so those edges cite the README and optional AI providers are dashed.

Main entry points: [`backend/src/main/java/com/ashaai/backend`](https://github.com/rohan45create/ashaai-v2/tree/main/backend/src/main/java/com/ashaai/backend) (Spring Boot API), [`frontend/src/utils/api.js`](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/utils/api.js) (API client), [`frontend/src/App.jsx`](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/App.jsx) (Worker and admin PWA), [`frontend/src/routes/admin`](https://github.com/rohan45create/ashaai-v2/tree/main/frontend/src/routes/admin) (Supervisor portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_field["ASHA Field App"]
  node_pwa["Worker and admin PWA<br/>[App.jsx]"]
  node_auth["Authentication state<br/>[authStore.js]"]
  node_api["API client<br/>[api.js]"]
  node_offline["Offline queue<br/>[useOfflineQueue.js]"]
  node_healthforms["Health registers"]
  node_capture["Voice and register capture"]
  node_adminui["Supervisor portal"]
end

subgraph group_backend["Backend Health Platform"]
  node_spring["Spring Boot API"]
  node_healthrecords[("Health records")]
  node_survey["Survey processing"]
  node_risk["Risk scoring"]
end

subgraph group_ai["AI Assistance"]
  node_aiapp["AI service API<br/>[main.py]"]
  node_agent["Conversational agent<br/>[agent.py]"]
  node_aiworkflows["AI health workflows"]
  node_providers["AI provider chain<br/>[provider_client.py]"]
end

subgraph group_oversight["Oversight and NGO"]
  node_review["Pending review"]
  node_ngo["NGO coordination<br/>[NgoController.java]"]
end

node_worker(("ASHA worker"))
node_supabase[("Supabase PostgreSQL")]
node_ngoform(("NGO registration form"))
node_externalai["External AI providers"]

node_worker -->|"uses"| node_pwa
node_pwa -->|"resolves identity"| node_auth
node_pwa -->|"routes to"| node_healthforms
node_healthforms -.->|"submits data"| node_api
node_capture -->|"sends capture"| node_api
node_api -.->|"queues requests"| node_offline
node_pwa -->|"routes to"| node_adminui
node_adminui -->|"requests data"| node_api
node_api -->|"HTTP requests"| node_spring
node_spring -->|"reads and writes"| node_supabase
node_spring -->|"calls AI service"| node_aiapp
node_aiapp -->|"registers routes"| node_aiworkflows
node_aiapp -->|"registers route"| node_agent
node_agent -->|"uses tools"| node_aiworkflows
node_agent -.->|"uses model service"| node_providers
node_providers -.->|"queries providers"| node_externalai
node_spring -.->|"processes submissions"| node_survey
node_survey -->|"persists records"| node_healthrecords
node_spring -.->|"scores health risk"| node_risk
node_risk -->|"updates child risk"| node_healthrecords
node_adminui -.->|"reviews cases"| node_review
node_review -->|"updates review status"| node_healthrecords
node_ngoform -->|"submits registration"| node_spring
node_spring -.->|"routes NGO requests"| node_ngo
node_adminui -.->|"coordinates visits"| node_ngo

click node_pwa "https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/App.jsx"
click node_auth "https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/stores/authStore.js"
click node_api "https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/utils/api.js"
click node_offline "https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/hooks/useOfflineQueue.js"
click node_healthforms "https://github.com/rohan45create/ashaai-v2/tree/main/frontend/src/routes/asha/modules"
click node_capture "https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/hooks/useVoiceRecorder.js"
click node_adminui "https://github.com/rohan45create/ashaai-v2/tree/main/frontend/src/routes/admin"
click node_spring "https://github.com/rohan45create/ashaai-v2/tree/main/backend/src/main/java/com/ashaai/backend"
click node_healthrecords "https://github.com/rohan45create/ashaai-v2/tree/main/backend/src/main/java/com/ashaai/backend/entity"
click node_survey "https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/service/SurveyProcessorService.java"
click node_risk "https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/service/RiskEngineService.java"
click node_review "https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/controller/PendingReviewController.java"
click node_ngo "https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/controller/NgoController.java"
click node_aiapp "https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/main.py"
click node_agent "https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/routers/agent.py"
click node_aiworkflows "https://github.com/rohan45create/ashaai-v2/tree/main/ai-service/routers"
click node_providers "https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/services/provider_client.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_pwa,node_auth,node_api,node_offline,node_healthforms,node_capture,node_adminui toneBlue
class node_spring,node_healthrecords,node_survey,node_risk,node_supabase toneAmber
class node_aiapp,node_agent,node_aiworkflows,node_providers toneMint
class node_review,node_ngo,node_worker toneRose
class node_ngoform,node_externalai toneIndigo
```

## Components

### ASHA Field App

- [Worker and admin PWA](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Authentication state](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/stores/authStore.js): `frontend/src/stores/authStore.js`
- [API client](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`
- [Offline queue](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/hooks/useOfflineQueue.js): `frontend/src/hooks/useOfflineQueue.js`
- [Health registers](https://github.com/rohan45create/ashaai-v2/tree/main/frontend/src/routes/asha/modules): `frontend/src/routes/asha/modules`
- [Voice and register capture](https://github.com/rohan45create/ashaai-v2/blob/main/frontend/src/hooks/useVoiceRecorder.js): `frontend/src/hooks/useVoiceRecorder.js`
- [Supervisor portal](https://github.com/rohan45create/ashaai-v2/tree/main/frontend/src/routes/admin): `frontend/src/routes/admin`

### Backend Health Platform

- [Spring Boot API](https://github.com/rohan45create/ashaai-v2/tree/main/backend/src/main/java/com/ashaai/backend): `backend/src/main/java/com/ashaai/backend`
- [Health records](https://github.com/rohan45create/ashaai-v2/tree/main/backend/src/main/java/com/ashaai/backend/entity): `backend/src/main/java/com/ashaai/backend/entity`
- [Survey processing](https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/service/SurveyProcessorService.java): `backend/src/main/java/com/ashaai/backend/service/SurveyProcessorService.java`
- [Risk scoring](https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/service/RiskEngineService.java): `backend/src/main/java/com/ashaai/backend/service/RiskEngineService.java`

### AI Assistance

- [AI service API](https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/main.py): `ai-service/main.py`
- [Conversational agent](https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/routers/agent.py): `ai-service/routers/agent.py`
- [AI health workflows](https://github.com/rohan45create/ashaai-v2/tree/main/ai-service/routers): `ai-service/routers`
- [AI provider chain](https://github.com/rohan45create/ashaai-v2/blob/main/ai-service/services/provider_client.py): `ai-service/services/provider_client.py`

### Oversight and NGO

- [Pending review](https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/controller/PendingReviewController.java): `backend/src/main/java/com/ashaai/backend/controller/PendingReviewController.java`
- [NGO coordination](https://github.com/rohan45create/ashaai-v2/blob/main/backend/src/main/java/com/ashaai/backend/controller/NgoController.java): `backend/src/main/java/com/ashaai/backend/controller/NgoController.java`

### Other components

- **ASHA worker**
- **Supabase PostgreSQL**
- **NGO registration form**
- **External AI providers**

## Connections

- ASHA worker → Worker and admin PWA: uses (evidence: `README.md`)
- Worker and admin PWA → Authentication state: resolves identity (evidence: `frontend/src/App.jsx`)
- Worker and admin PWA → Health registers: routes to (evidence: `frontend/src/App.jsx`)
- Health registers → API client: submits data
- Voice and register capture → API client: sends capture (evidence: `frontend/src/hooks/useVoiceRecorder.js`)
- API client → Offline queue: queues requests
- Worker and admin PWA → Supervisor portal: routes to (evidence: `frontend/src/App.jsx`)
- Supervisor portal → API client: requests data (evidence: `frontend/src/routes/admin/WorkerActivity.jsx`)
- API client → Spring Boot API: HTTP requests (evidence: `README.md`)
- Spring Boot API → Supabase PostgreSQL: reads and writes (evidence: `README.md`)
- Spring Boot API → AI service API: calls AI service (evidence: `README.md`)
- AI service API → AI health workflows: registers routes (evidence: `ai-service/main.py`)
- AI service API → Conversational agent: registers route (evidence: `ai-service/main.py`)
- Conversational agent → AI health workflows: uses tools (evidence: `ai-service/routers/agent.py`)
- Conversational agent → AI provider chain: uses model service
- AI provider chain → External AI providers: queries providers (evidence: `README.md`)
- Spring Boot API → Survey processing: processes submissions (evidence: `backend/src/main/java/com/ashaai/backend/service/SurveyProcessorService.java`)
- Survey processing → Health records: persists records (evidence: `backend/src/main/java/com/ashaai/backend/service/SurveyProcessorService.java`)
- Spring Boot API → Risk scoring: scores health risk (evidence: `backend/src/main/java/com/ashaai/backend/service/PriorityListService.java`)
- Risk scoring → Health records: updates child risk (evidence: `backend/src/main/java/com/ashaai/backend/service/RiskEngineService.java`)
- Supervisor portal → Pending review: reviews cases
- Pending review → Health records: updates review status (evidence: `backend/src/main/java/com/ashaai/backend/controller/PendingReviewController.java`)
- NGO registration form → Spring Boot API: submits registration (evidence: `README.md`)
- Spring Boot API → NGO coordination: routes NGO requests (evidence: `backend/src/main/java/com/ashaai/backend/controller/NgoController.java`)
- Supervisor portal → NGO coordination: coordinates visits
