# joeltkvaidyan/shramsetu architecture

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

- Interactive diagram: https://gitdiagram.com/joeltkvaidyan/shramsetu
- Repository: https://github.com/joeltkvaidyan/shramsetu

## Overview

ShramSetu is a multilingual migrant-worker welfare platform: workers register and use welfare services, while officials review jurisdiction-scoped cases and alerts. The React client calls the Node API for identity, records, and business rules; the Node service persists domain data in MongoDB and proxies AI requests to the Python service. The AI service provides scheme retrieval and voice capabilities. Several feature modules were not sampled, so their presence and broad responsibilities come from the README and tree; edges are limited to documented or excerpted relationships.

Main entry points: [`server/src/app.js`](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/app.js) (API route dispatch), [`frontend/src/App.tsx`](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/App.tsx) (Web application), [`ai-service/main.py`](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/main.py) (AI service API), [`server/src/db.js`](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/db.js) (MongoDB)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Worker and official client"]
  node_web_app["Web application<br/>[App.tsx]"]
  node_worker_registration["Worker registration"]
  node_worker_dashboard["Worker dashboard"]
  node_wallet_ui["Document wallet"]
  node_grievance_ui["Grievance filing and tracking"]
  node_government_ui["Government dashboard"]
  node_client_api["API client<br/>[client.ts]"]
end

subgraph group_api["Welfare API"]
  node_api_routes["API route dispatch<br/>[app.js]"]
  node_authentication["Authentication and RBAC<br/>[auth.js]"]
  node_grievance_service["Grievance service<br/>[grievances.js]"]
  node_wallet_service["Encrypted document wallet<br/>[documents.js]"]
  node_government_service["Government operations<br/>[government.js]"]
  node_chat_service["AI chat proxy<br/>[chat.js]"]
  node_wage_sos["Wage diary and SOS"]
end

subgraph group_records["Welfare records"]
  node_mongo[("MongoDB<br/>[db.js]")]
  node_domain_models["Domain models"]
end

subgraph group_ai["AI and voice"]
  node_ai_service["AI service API<br/>[main.py]"]
  node_rag_answer["Grounded scheme answers<br/>[rag_service.py]"]
  node_voice_services["Speech recognition and synthesis"]
  node_translation["Indic query translation"]
  node_warmup["Model readiness<br/>[warmup.py]"]
end

subgraph group_knowledge["Scheme knowledge"]
  node_corpus["Scheme document ingestion<br/>[ingest.py]"]
  node_retrieval["Hybrid retrieval and embeddings"]
end

node_worker(("Worker"))
node_official(("Government official"))

node_worker -->|"uses"| node_web_app
node_official -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_worker_registration
node_web_app -->|"routes to"| node_worker_dashboard
node_web_app -->|"routes to"| node_wallet_ui
node_web_app -->|"routes to"| node_grievance_ui
node_web_app -->|"routes to"| node_government_ui
node_worker_registration -->|"calls"| node_client_api
node_worker_dashboard -->|"calls"| node_client_api
node_client_api -->|"REST requests"| node_api_routes
node_api_routes -->|"protects routes"| node_authentication
node_api_routes -->|"dispatches"| node_grievance_service
node_api_routes -->|"dispatches"| node_wallet_service
node_api_routes -->|"dispatches"| node_government_service
node_api_routes -->|"dispatches"| node_chat_service
node_api_routes -->|"dispatches"| node_wage_sos
node_grievance_service -->|"persists records"| node_mongo
node_wallet_service -->|"stores wallet data"| node_mongo
node_government_service -->|"reads records"| node_mongo
node_domain_models -->|"models data in"| node_mongo
node_chat_service -->|"proxies requests"| node_ai_service
node_ai_service -->|"routes questions"| node_rag_answer
node_ai_service -->|"routes voice"| node_voice_services
node_rag_answer -->|"translates query"| node_translation
node_rag_answer -->|"retrieves evidence"| node_retrieval
node_corpus -->|"builds index"| node_retrieval
node_ai_service -->|"reports readiness"| node_warmup

click node_web_app "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/App.tsx"
click node_worker_registration "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/WorkerRegisterPage.tsx"
click node_worker_dashboard "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/WorkerDashboardPage.tsx"
click node_wallet_ui "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/DocumentWalletPage.tsx"
click node_grievance_ui "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/GrievanceFormPage.tsx"
click node_government_ui "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/GovernmentDashboardPage.tsx"
click node_client_api "https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/api/client.ts"
click node_api_routes "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/app.js"
click node_authentication "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/middleware/auth.js"
click node_grievance_service "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/grievances.js"
click node_wallet_service "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/documents.js"
click node_government_service "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/government.js"
click node_chat_service "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/chat.js"
click node_wage_sos "https://github.com/joeltkvaidyan/shramsetu/tree/main/server/src/routes"
click node_mongo "https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/db.js"
click node_domain_models "https://github.com/joeltkvaidyan/shramsetu/tree/main/server/src/models"
click node_ai_service "https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/main.py"
click node_rag_answer "https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/services/rag_service.py"
click node_voice_services "https://github.com/joeltkvaidyan/shramsetu/tree/main/ai-service/app/services"
click node_translation "https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/services/translation_service.py"
click node_warmup "https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/core/warmup.py"
click node_corpus "https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/rag/ingest.py"
click node_retrieval "https://github.com/joeltkvaidyan/shramsetu/tree/main/ai-service/rag"

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_web_app,node_worker_registration,node_worker_dashboard,node_wallet_ui,node_grievance_ui,node_government_ui,node_client_api toneBlue
class node_api_routes,node_authentication,node_grievance_service,node_wallet_service,node_government_service,node_chat_service,node_wage_sos toneAmber
class node_mongo,node_domain_models toneMint
class node_ai_service,node_rag_answer,node_voice_services,node_translation,node_warmup,node_worker toneRose
class node_corpus,node_retrieval,node_official toneIndigo
```

## Components

### Worker and official client

- [Web application](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Worker registration](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/WorkerRegisterPage.tsx): `frontend/src/pages/WorkerRegisterPage.tsx`
- [Worker dashboard](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/WorkerDashboardPage.tsx): `frontend/src/pages/WorkerDashboardPage.tsx`
- [Document wallet](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/DocumentWalletPage.tsx): `frontend/src/pages/DocumentWalletPage.tsx`
- [Grievance filing and tracking](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/GrievanceFormPage.tsx): `frontend/src/pages/GrievanceFormPage.tsx`
- [Government dashboard](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/pages/GovernmentDashboardPage.tsx): `frontend/src/pages/GovernmentDashboardPage.tsx`
- [API client](https://github.com/joeltkvaidyan/shramsetu/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Welfare API

- [API route dispatch](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/app.js): `server/src/app.js`
- [Authentication and RBAC](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/middleware/auth.js): `server/src/middleware/auth.js`
- [Grievance service](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/grievances.js): `server/src/routes/grievances.js`
- [Encrypted document wallet](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/documents.js): `server/src/routes/documents.js`
- [Government operations](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/government.js): `server/src/routes/government.js`
- [AI chat proxy](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/routes/chat.js): `server/src/routes/chat.js`
- [Wage diary and SOS](https://github.com/joeltkvaidyan/shramsetu/tree/main/server/src/routes): `server/src/routes`

### Welfare records

- [MongoDB](https://github.com/joeltkvaidyan/shramsetu/blob/main/server/src/db.js): `server/src/db.js`
- [Domain models](https://github.com/joeltkvaidyan/shramsetu/tree/main/server/src/models): `server/src/models`

### AI and voice

- [AI service API](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/main.py): `ai-service/main.py`
- [Grounded scheme answers](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/services/rag_service.py): `ai-service/app/services/rag_service.py`
- [Speech recognition and synthesis](https://github.com/joeltkvaidyan/shramsetu/tree/main/ai-service/app/services): `ai-service/app/services`
- [Indic query translation](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/services/translation_service.py): `ai-service/app/services/translation_service.py`
- [Model readiness](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/app/core/warmup.py): `ai-service/app/core/warmup.py`

### Scheme knowledge

- [Scheme document ingestion](https://github.com/joeltkvaidyan/shramsetu/blob/main/ai-service/rag/ingest.py): `ai-service/rag/ingest.py`
- [Hybrid retrieval and embeddings](https://github.com/joeltkvaidyan/shramsetu/tree/main/ai-service/rag): `ai-service/rag`

### Other components

- **Worker**
- **Government official**

## Connections

- Worker → Web application: uses (evidence: `README.md`)
- Government official → Web application: uses (evidence: `README.md`)
- Web application → Worker registration: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Worker dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Document wallet: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Grievance filing and tracking: routes to (evidence: `frontend/src/App.tsx`)
- Web application → Government dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Worker registration → API client: calls (evidence: `frontend/src/pages/WorkerRegisterPage.tsx`)
- Worker dashboard → API client: calls (evidence: `frontend/src/pages/WorkerDashboardPage.tsx`)
- API client → API route dispatch: REST requests (evidence: `README.md`)
- API route dispatch → Authentication and RBAC: protects routes (evidence: `server/src/middleware/auth.js`)
- API route dispatch → Grievance service: dispatches (evidence: `server/src/app.js`)
- API route dispatch → Encrypted document wallet: dispatches (evidence: `server/src/app.js`)
- API route dispatch → Government operations: dispatches (evidence: `server/src/app.js`)
- API route dispatch → AI chat proxy: dispatches (evidence: `server/src/app.js`)
- API route dispatch → Wage diary and SOS: dispatches (evidence: `server/src/app.js`)
- Grievance service → MongoDB: persists records (evidence: `README.md`)
- Encrypted document wallet → MongoDB: stores wallet data (evidence: `README.md`)
- Government operations → MongoDB: reads records (evidence: `README.md`)
- Domain models → MongoDB: models data in (evidence: `README.md`)
- AI chat proxy → AI service API: proxies requests (evidence: `README.md`)
- AI service API → Grounded scheme answers: routes questions (evidence: `ai-service/main.py`)
- AI service API → Speech recognition and synthesis: routes voice (evidence: `ai-service/main.py`)
- Grounded scheme answers → Indic query translation: translates query (evidence: `ai-service/app/services/rag_service.py`)
- Grounded scheme answers → Hybrid retrieval and embeddings: retrieves evidence (evidence: `ai-service/app/services/rag_service.py`)
- Scheme document ingestion → Hybrid retrieval and embeddings: builds index (evidence: `ai-service/rag/ingest.py`)
- AI service API → Model readiness: reports readiness (evidence: `ai-service/main.py`)
