# muthugopi/sahakar-sathi architecture

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

- Interactive diagram: https://gitdiagram.com/muthugopi/sahakar-sathi
- Repository: https://github.com/muthugopi/sahakar-sathi

## Overview

Sahakar Sathi is a multilingual cooperative-support web application with an Express API. Members browse verified guidance and schemes, ask grounded questions with voice support, and submit or track grievances; administrators manage knowledge, schemes, and grievance status. The graph combines sampled call/import evidence with README-documented capabilities. Several API routes, services, and web pages were not sampled, so their documented connections are cited to the README rather than presented as inspected call paths.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/App.tsx) (Web application), [`apps/api/src/config/prisma.ts`](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/config/prisma.ts) (PostgreSQL and pgvector), [`apps/api/src/services/chat.service.ts`](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/chat.service.ts) (Chat orchestration), [`apps/api/src/services/admin`](https://github.com/muthugopi/sahakar-sathi/tree/main/apps/api/src/services/admin) (Admin services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Member experience"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_assistant["Assistant experience<br/>[AssistantPage.tsx]"]
  node_voice["Voice input and playback<br/>[speech.ts]"]
  node_content["Schemes and topics<br/>[SchemesPage.tsx]"]
  node_grievanceui["Grievance pages<br/>[GrievancePage.tsx]"]
  node_adminui["Admin pages"]
end

subgraph group_api["API and workflows"]
  node_api["API application<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_chat["Chat orchestration<br/>[chat.service.ts]"]
  node_grievance["Grievance workflow"]
  node_contentapi["Content services<br/>[content.service.ts]"]
end

subgraph group_knowledge["Knowledge and answers"]
  node_retrieval["Verified retrieval"]
  node_embeddings["Text embeddings<br/>[embeddings.ts]"]
  node_classification["Question routing<br/>[classify.ts]"]
  node_generation["Answer generation<br/>[llm.ts]"]
  node_websearch["Web search"]
end

subgraph group_admin["Administration"]
  node_adminservices["Admin services"]
end

subgraph group_platform["Shared platform"]
  node_database[("PostgreSQL and pgvector<br/>[prisma.ts]")]
  node_shared["Shared contracts<br/>[schemas.ts]"]
end

node_members(("Members"))

node_members -->|"use"| node_webapp
node_webapp -->|"routes to"| node_assistant
node_webapp -->|"routes to"| node_content
node_webapp -->|"routes to"| node_grievanceui
node_webapp -->|"routes to"| node_adminui
node_assistant -->|"uses"| node_voice
node_assistant -->|"asks"| node_chat
node_content -->|"fetches"| node_contentapi
node_grievanceui -->|"submits and tracks"| node_grievance
node_adminui -->|"manages"| node_adminservices
node_api -->|"connects through"| node_database
node_chat -->|"routes questions"| node_classification
node_chat -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"embeds query"| node_embeddings
node_retrieval -->|"queries vectors"| node_database
node_chat -->|"generates answer"| node_generation
node_chat -.->|"searches current topics"| node_websearch
node_websearch -.->|"uses configuration"| node_database
node_grievance -.->|"persists workflow"| node_database
node_contentapi -.->|"reads content"| node_database
node_adminservices -.->|"manages records"| node_database
node_adminservices -->|"updates status"| node_grievance
node_adminservices -->|"maintains knowledge"| node_retrieval
node_auth -->|"stores accounts"| node_database
node_webapp -->|"uses contracts"| node_shared
node_adminservices -->|"validates contracts"| node_shared

click node_webapp "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/App.tsx"
click node_assistant "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/AssistantPage.tsx"
click node_voice "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/lib/speech.ts"
click node_content "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/SchemesPage.tsx"
click node_grievanceui "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/GrievancePage.tsx"
click node_adminui "https://github.com/muthugopi/sahakar-sathi/tree/main/apps/web/src/pages/admin"
click node_api "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/app.ts"
click node_auth "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/auth.service.ts"
click node_chat "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/chat.service.ts"
click node_grievance "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/grievance.service.ts"
click node_contentapi "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/content.service.ts"
click node_retrieval "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/retrieval.service.ts"
click node_embeddings "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/embeddings.ts"
click node_classification "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/classify.ts"
click node_generation "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/llm.ts"
click node_websearch "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/websearch.service.ts"
click node_database "https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/config/prisma.ts"
click node_adminservices "https://github.com/muthugopi/sahakar-sathi/tree/main/apps/api/src/services/admin"
click node_shared "https://github.com/muthugopi/sahakar-sathi/blob/main/packages/shared/src/schemas.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_webapp,node_assistant,node_voice,node_content,node_grievanceui,node_adminui toneBlue
class node_api,node_auth,node_chat,node_grievance,node_contentapi toneAmber
class node_retrieval,node_embeddings,node_classification,node_generation,node_websearch toneMint
class node_adminservices toneRose
class node_database,node_shared,node_members toneIndigo
```

## Components

### Member experience

- [Web application](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Assistant experience](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/AssistantPage.tsx): `apps/web/src/pages/AssistantPage.tsx`
- [Voice input and playback](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/lib/speech.ts): `apps/web/src/lib/speech.ts`
- [Schemes and topics](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/SchemesPage.tsx): `apps/web/src/pages/SchemesPage.tsx`
- [Grievance pages](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/web/src/pages/GrievancePage.tsx): `apps/web/src/pages/GrievancePage.tsx`
- [Admin pages](https://github.com/muthugopi/sahakar-sathi/tree/main/apps/web/src/pages/admin): `apps/web/src/pages/admin`

### API and workflows

- [API application](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Authentication](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/auth.service.ts): `apps/api/src/services/auth.service.ts`
- [Chat orchestration](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/chat.service.ts): `apps/api/src/services/chat.service.ts`
- [Grievance workflow](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/grievance.service.ts): `apps/api/src/services/grievance.service.ts`
- [Content services](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/content.service.ts): `apps/api/src/services/content.service.ts`

### Knowledge and answers

- [Verified retrieval](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/retrieval.service.ts): `apps/api/src/services/retrieval.service.ts`
- [Text embeddings](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/embeddings.ts): `apps/api/src/ai/embeddings.ts`
- [Question routing](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/classify.ts): `apps/api/src/ai/classify.ts`
- [Answer generation](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/ai/llm.ts): `apps/api/src/ai/llm.ts`
- [Web search](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/services/websearch.service.ts): `apps/api/src/services/websearch.service.ts`

### Administration

- [Admin services](https://github.com/muthugopi/sahakar-sathi/tree/main/apps/api/src/services/admin): `apps/api/src/services/admin`

### Shared platform

- [PostgreSQL and pgvector](https://github.com/muthugopi/sahakar-sathi/blob/main/apps/api/src/config/prisma.ts): `apps/api/src/config/prisma.ts`
- [Shared contracts](https://github.com/muthugopi/sahakar-sathi/blob/main/packages/shared/src/schemas.ts): `packages/shared/src/schemas.ts`

### Other components

- **Members**

## Connections

- Members → Web application: use (evidence: `apps/web/src/App.tsx`)
- Web application → Assistant experience: routes to (evidence: `apps/web/src/App.tsx`)
- Web application → Schemes and topics: routes to (evidence: `apps/web/src/App.tsx`)
- Web application → Grievance pages: routes to (evidence: `apps/web/src/App.tsx`)
- Web application → Admin pages: routes to (evidence: `apps/web/src/App.tsx`)
- Assistant experience → Voice input and playback: uses
- Assistant experience → Chat orchestration: asks
- Schemes and topics → Content services: fetches
- Grievance pages → Grievance workflow: submits and tracks
- Admin pages → Admin services: manages
- API application → PostgreSQL and pgvector: connects through (evidence: `apps/api/src/config/prisma.ts`)
- Chat orchestration → Question routing: routes questions
- Chat orchestration → Verified retrieval: retrieves evidence
- Verified retrieval → Text embeddings: embeds query (evidence: `apps/api/src/services/retrieval.service.ts`)
- Verified retrieval → PostgreSQL and pgvector: queries vectors (evidence: `apps/api/src/services/retrieval.service.ts`)
- Chat orchestration → Answer generation: generates answer
- Chat orchestration → Web search: searches current topics
- Web search → PostgreSQL and pgvector: uses configuration
- Grievance workflow → PostgreSQL and pgvector: persists workflow
- Content services → PostgreSQL and pgvector: reads content
- Admin services → PostgreSQL and pgvector: manages records (evidence: `apps/api/src/services/admin/scheme-admin.service.ts`)
- Admin services → Grievance workflow: updates status (evidence: `apps/api/src/services/admin/grievance-admin.service.ts`)
- Admin services → Verified retrieval: maintains knowledge (evidence: `apps/api/src/services/admin/knowledge-admin.service.ts`)
- Authentication → PostgreSQL and pgvector: stores accounts (evidence: `apps/api/src/services/auth.service.ts`)
- Web application → Shared contracts: uses contracts
- Admin services → Shared contracts: validates contracts
