# nanthini2007/digital-sakhi architecture

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

## Overview

SAKHI is a bilingual (Tamil/English) government-service guidance app. Users ask by text or voice, receive service-specific step guidance, and can advance, ask for simpler help, or open an official site. The repository also has a separate session-backed journey API for starting, advancing, checking, and recovering a journey. Source excerpts show some calls directly; where route wiring is supported only by the source index, the graph avoids inferring additional flow.

Main entry points: [`src/app/page.tsx`](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/page.tsx) (Guidance screen), [`src/lib/supabase.ts`](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/supabase.ts) (Journey persistence), [`src/app/api/sakhi/route.ts`](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/sakhi/route.ts) (Guidance handler), [`src/app/api/journey/start/route.ts`](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/start/route.ts) (Start journey)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_page["Guidance screen<br/>[page.tsx]"]
  node_header["Language header<br/>[Header.tsx]"]
  node_mic["Voice control<br/>[MicButton.tsx]"]
  node_voice["Speech engine<br/>[voice.ts]"]
  node_journey_card["Step card<br/>[JourneyCard.tsx]"]
  node_sahayata["Sahayata card<br/>[SahayataCard.tsx]"]
  node_stuck_modal["Stuck help<br/>[StuckModal.tsx]"]
  node_handoff["Official handoff"]
end

subgraph group_guidance["Guidance and services"]
  node_languages["Language registry<br/>[languages.ts]"]
  node_chat_api["Chat endpoint<br/>[route.ts]"]
  node_sakhi_api["Guidance handler<br/>[route.ts]"]
  node_schemes["Service catalog<br/>[schemes.ts]"]
  node_safety["Input safety<br/>[safety.ts]"]
end

subgraph group_journey["Journey API"]
  node_journey_start["Start journey<br/>[route.ts]"]
  node_journey_next["Advance journey<br/>[route.ts]"]
  node_journey_state["Read journey state<br/>[route.ts]"]
  node_journey_stuck["Stuck endpoint<br/>[route.ts]"]
  node_service_details["Service details endpoint<br/>[route.ts]"]
end

subgraph group_platform["Persistence and operations"]
  node_rate_limit["Rate limiter<br/>[rate-limit.ts]"]
  node_store[("Journey persistence<br/>[supabase.ts]")]
  node_logger["Safe event logger<br/>[logger.ts]"]
end

node_user(("Service seeker"))
node_gemini{{"Google Gemini"}}
node_supabase[("Supabase")]
node_browser_speech{{"Browser speech APIs"}}

node_user -->|"asks for guidance"| node_page
node_page -->|"renders"| node_header
node_page -->|"renders"| node_mic
node_page -->|"renders"| node_journey_card
node_page -->|"renders"| node_stuck_modal
node_page -->|"renders"| node_handoff
node_page -->|"renders"| node_sahayata
node_header -->|"reads"| node_languages
node_mic -->|"uses"| node_voice
node_voice -->|"uses"| node_browser_speech
node_page -->|"starts and stops speech"| node_voice
node_page -->|"posts chat request"| node_chat_api
node_chat_api -->|"delegates to"| node_sakhi_api
node_sakhi_api -->|"checks requests"| node_rate_limit
node_sakhi_api -->|"checks input"| node_safety
node_sakhi_api -->|"selects service"| node_schemes
node_sakhi_api -->|"requests generation"| node_gemini
node_journey_start -->|"creates session and saves state"| node_store
node_journey_start -->|"resolves service"| node_schemes
node_journey_start -->|"checks requests"| node_rate_limit
node_journey_start -->|"logs start"| node_logger
node_journey_next -->|"loads service and saves state"| node_store
node_journey_next -->|"logs progress"| node_logger
node_journey_stuck -->|"loads service"| node_store
node_journey_stuck -->|"logs stuck event"| node_logger
node_journey_state -->|"reads state"| node_store
node_service_details -->|"reads service"| node_store
node_store -->|"reads and writes"| node_supabase

click node_page "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/page.tsx"
click node_header "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/Header.tsx"
click node_mic "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/MicButton.tsx"
click node_voice "https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/voice.ts"
click node_journey_card "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/JourneyCard.tsx"
click node_sahayata "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/SahayataCard.tsx"
click node_stuck_modal "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/StuckModal.tsx"
click node_handoff "https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/OfficialHandoffModal.tsx"
click node_languages "https://github.com/nanthini2007/digital-sakhi/blob/main/src/data/languages.ts"
click node_chat_api "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/ai/chat/route.ts"
click node_sakhi_api "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/sakhi/route.ts"
click node_schemes "https://github.com/nanthini2007/digital-sakhi/blob/main/src/data/schemes.ts"
click node_safety "https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/safety.ts"
click node_rate_limit "https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/rate-limit.ts"
click node_journey_start "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/start/route.ts"
click node_journey_next "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/next/route.ts"
click node_journey_state "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/state/route.ts"
click node_journey_stuck "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/stuck/route.ts"
click node_service_details "https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/service/details/route.ts"
click node_store "https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/supabase.ts"
click node_logger "https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/logger.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_page,node_header,node_mic,node_voice,node_journey_card,node_sahayata,node_stuck_modal,node_handoff,node_browser_speech toneBlue
class node_languages,node_chat_api,node_sakhi_api,node_schemes,node_safety,node_supabase toneAmber
class node_journey_start,node_journey_next,node_journey_state,node_journey_stuck,node_service_details toneMint
class node_rate_limit,node_store,node_logger toneRose
class node_user,node_gemini toneIndigo
```

## Components

### User experience

- [Guidance screen](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Language header](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [Voice control](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/MicButton.tsx): `src/components/MicButton.tsx`
- [Speech engine](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/voice.ts): `src/lib/voice.ts`
- [Step card](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/JourneyCard.tsx): `src/components/JourneyCard.tsx`
- [Sahayata card](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/SahayataCard.tsx): `src/components/SahayataCard.tsx`
- [Stuck help](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/StuckModal.tsx): `src/components/StuckModal.tsx`
- [Official handoff](https://github.com/nanthini2007/digital-sakhi/blob/main/src/components/OfficialHandoffModal.tsx): `src/components/OfficialHandoffModal.tsx`

### Guidance and services

- [Language registry](https://github.com/nanthini2007/digital-sakhi/blob/main/src/data/languages.ts): `src/data/languages.ts`
- [Chat endpoint](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/ai/chat/route.ts): `src/app/api/ai/chat/route.ts`
- [Guidance handler](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/sakhi/route.ts): `src/app/api/sakhi/route.ts`
- [Service catalog](https://github.com/nanthini2007/digital-sakhi/blob/main/src/data/schemes.ts): `src/data/schemes.ts`
- [Input safety](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/safety.ts): `src/lib/safety.ts`

### Journey API

- [Start journey](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/start/route.ts): `src/app/api/journey/start/route.ts`
- [Advance journey](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/next/route.ts): `src/app/api/journey/next/route.ts`
- [Read journey state](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/state/route.ts): `src/app/api/journey/state/route.ts`
- [Stuck endpoint](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/journey/stuck/route.ts): `src/app/api/journey/stuck/route.ts`
- [Service details endpoint](https://github.com/nanthini2007/digital-sakhi/blob/main/src/app/api/service/details/route.ts): `src/app/api/service/details/route.ts`

### Persistence and operations

- [Rate limiter](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/rate-limit.ts): `src/lib/rate-limit.ts`
- [Journey persistence](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Safe event logger](https://github.com/nanthini2007/digital-sakhi/blob/main/src/lib/logger.ts): `src/lib/logger.ts`

### Other components

- **Service seeker**
- **Google Gemini**
- **Supabase**
- **Browser speech APIs**

## Connections

- Service seeker → Guidance screen: asks for guidance (evidence: `src/app/page.tsx`)
- Guidance screen → Language header: renders (evidence: `src/app/page.tsx`)
- Guidance screen → Voice control: renders (evidence: `src/app/page.tsx`)
- Guidance screen → Step card: renders (evidence: `src/app/page.tsx`)
- Guidance screen → Stuck help: renders (evidence: `src/app/page.tsx`)
- Guidance screen → Official handoff: renders (evidence: `src/app/page.tsx`)
- Guidance screen → Sahayata card: renders (evidence: `src/app/page.tsx`)
- Language header → Language registry: reads (evidence: `src/components/Header.tsx`)
- Voice control → Speech engine: uses (evidence: `src/components/MicButton.tsx`)
- Speech engine → Browser speech APIs: uses (evidence: `src/lib/voice.ts`)
- Guidance screen → Speech engine: starts and stops speech (evidence: `src/app/page.tsx`)
- Guidance screen → Chat endpoint: posts chat request (evidence: `src/app/page.tsx`)
- Chat endpoint → Guidance handler: delegates to (evidence: `src/app/api/ai/chat/route.ts`)
- Guidance handler → Rate limiter: checks requests (evidence: `src/app/api/sakhi/route.ts`)
- Guidance handler → Input safety: checks input (evidence: `src/app/api/sakhi/route.ts`)
- Guidance handler → Service catalog: selects service (evidence: `src/app/api/sakhi/route.ts`)
- Guidance handler → Google Gemini: requests generation (evidence: `src/app/api/sakhi/route.ts`)
- Start journey → Journey persistence: creates session and saves state (evidence: `src/app/api/journey/start/route.ts`)
- Start journey → Service catalog: resolves service (evidence: `src/app/api/journey/start/route.ts`)
- Start journey → Rate limiter: checks requests (evidence: `src/app/api/journey/start/route.ts`)
- Start journey → Safe event logger: logs start (evidence: `src/app/api/journey/start/route.ts`)
- Advance journey → Journey persistence: loads service and saves state (evidence: `src/app/api/journey/next/route.ts`)
- Advance journey → Safe event logger: logs progress (evidence: `src/app/api/journey/next/route.ts`)
- Stuck endpoint → Journey persistence: loads service (evidence: `src/app/api/journey/stuck/route.ts`)
- Stuck endpoint → Safe event logger: logs stuck event (evidence: `src/app/api/journey/stuck/route.ts`)
- Read journey state → Journey persistence: reads state (evidence: `src/app/api/journey/state/route.ts`)
- Service details endpoint → Journey persistence: reads service (evidence: `src/app/api/service/details/route.ts`)
- Journey persistence → Supabase: reads and writes (evidence: `src/lib/supabase.ts`)
