# nihalmishra3009/nirikshan-voice-agent architecture

> Architecture diagram of the GitHub repository nihalmishra3009/nirikshan-voice-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nihalmishra3009/nirikshan-voice-agent
- Repository: https://github.com/nihalmishra3009/nirikshan-voice-agent

## Overview

Nirikshan is a browser-based voice-call platform whose implemented workflow creates and starts a call, connects browser microphone audio through LiveKit, ingests and normalizes borrower audio into bounded in-memory buffers, and exposes call/audio health and lifecycle events to the UI. The graph preserves the call-control and media-ingestion stages plus the frontend call experience. The README and source index support the main wiring; some detailed internal media behavior is documented but not fully excerpted.

Main entry points: [`backend/app/orchestrator/call_manager.py`](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/call_manager.py) (Call manager), [`backend/app/media/audio_consumer.py`](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/audio_consumer.py) (LiveKit audio consumer), [`frontend/src/hooks/useCallSession.ts`](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/hooks/useCallSession.ts) (Call session hook), [`frontend/src/pages/LiveCall.tsx`](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/pages/LiveCall.tsx) (Live call page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser call client"]
  node_livecall["Live call page<br/>[LiveCall.tsx]"]
  node_callpanel["Call panel<br/>[CallPanel.tsx]"]
  node_sessionhook["Call session hook<br/>[useCallSession.ts]"]
  node_livekithook["LiveKit hook<br/>[useLiveKit.ts]"]
  node_callapi["Call API client<br/>[calls.ts]"]
  node_wsclient["WebSocket client<br/>[websocket.ts]"]
  node_healthui["Health display<br/>[LiveCall.tsx]"]
end

subgraph group_control["Call control"]
  node_callroutes["Call routes<br/>[calls.py]"]
  node_wsroute["Call WebSocket<br/>[websocket.py]"]
  node_manager["Call manager<br/>[call_manager.py]"]
  node_sessions[("Session store and event hub<br/>[session_manager.py]")]
  node_state["Conversation state"]
  node_healthroute["Health route<br/>[health.py]"]
end

subgraph group_media["Audio ingestion"]
  node_coordinator["Ingestion coordinator<br/>[coordinator.py]"]
  node_consumer["LiveKit audio consumer<br/>[audio_consumer.py]"]
  node_chunker["PCM frame chunker<br/>[frame_chunker.py]"]
  node_buffer["Bounded audio buffer<br/>[audio_buffer.py]"]
  node_sink["Audio frame sink<br/>[sink.py]"]
  node_audiohealth["Audio contracts and health<br/>[audio.py]"]
end

subgraph group_services["LiveKit services"]
  node_livekitservice["Room lifecycle service<br/>[livekit_service.py]"]
  node_tokens["Token service<br/>[token_service.py]"]
end

node_caller(("Caller browser"))
node_livekit{{"LiveKit SFU"}}

node_caller -->|"opens"| node_livecall
node_livecall -->|"renders"| node_callpanel
node_callpanel -->|"uses"| node_sessionhook
node_sessionhook -->|"requests"| node_callapi
node_sessionhook -->|"sends events"| node_wsclient
node_sessionhook -->|"uses"| node_livekithook
node_livecall -->|"shows telemetry"| node_healthui
node_callapi -->|"calls REST"| node_callroutes
node_wsclient -->|"signals"| node_wsroute
node_callroutes -->|"delegates"| node_manager
node_wsroute -->|"dispatches events"| node_manager
node_manager -->|"reads and saves"| node_sessions
node_manager -->|"transitions"| node_state
node_manager -->|"provisions rooms"| node_livekitservice
node_manager -->|"issues tokens"| node_tokens
node_manager -->|"attaches calls"| node_coordinator
node_manager -->|"broadcasts events"| node_sessions
node_coordinator -->|"manages consumer"| node_consumer
node_coordinator -->|"configures sink"| node_sink
node_consumer -->|"requests token"| node_tokens
node_consumer -->|"subscribes audio"| node_livekit
node_livekit -->|"streams microphone"| node_consumer
node_consumer -->|"normalizes frames"| node_chunker
node_chunker -->|"enqueues packets"| node_buffer
node_buffer -->|"provides frames"| node_sink
node_chunker -->|"creates packets"| node_audiohealth
node_buffer -->|"tracks queue metrics"| node_audiohealth
node_callroutes -->|"returns health"| node_audiohealth
node_healthroute -->|"serves health"| node_caller

click node_livecall "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/pages/LiveCall.tsx"
click node_callpanel "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/components/call/CallPanel.tsx"
click node_sessionhook "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/hooks/useCallSession.ts"
click node_livekithook "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/hooks/useLiveKit.ts"
click node_callapi "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/services/calls.ts"
click node_wsclient "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/services/websocket.ts"
click node_healthui "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/pages/LiveCall.tsx"
click node_callroutes "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/routes/calls.py"
click node_wsroute "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/websocket.py"
click node_manager "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/call_manager.py"
click node_sessions "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/session_manager.py"
click node_state "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/conversation_state.py"
click node_healthroute "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/routes/health.py"
click node_coordinator "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/coordinator.py"
click node_consumer "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/audio_consumer.py"
click node_chunker "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/frame_chunker.py"
click node_buffer "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/audio_buffer.py"
click node_sink "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/sink.py"
click node_audiohealth "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/schemas/audio.py"
click node_livekitservice "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/services/livekit_service.py"
click node_tokens "https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/services/token_service.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_livecall,node_callpanel,node_sessionhook,node_livekithook,node_callapi,node_wsclient,node_healthui,node_caller toneBlue
class node_callroutes,node_wsroute,node_manager,node_sessions,node_state,node_healthroute toneAmber
class node_coordinator,node_consumer,node_chunker,node_buffer,node_sink,node_audiohealth toneMint
class node_livekitservice,node_tokens toneRose
class node_livekit toneIndigo
```

## Components

### Browser call client

- [Live call page](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/pages/LiveCall.tsx): `frontend/src/pages/LiveCall.tsx`
- [Call panel](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/components/call/CallPanel.tsx): `frontend/src/components/call/CallPanel.tsx`
- [Call session hook](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/hooks/useCallSession.ts): `frontend/src/hooks/useCallSession.ts`
- [LiveKit hook](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/hooks/useLiveKit.ts): `frontend/src/hooks/useLiveKit.ts`
- [Call API client](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/services/calls.ts): `frontend/src/services/calls.ts`
- [WebSocket client](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/services/websocket.ts): `frontend/src/services/websocket.ts`
- [Health display](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/frontend/src/pages/LiveCall.tsx): `frontend/src/pages/LiveCall.tsx`

### Call control

- [Call routes](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/routes/calls.py): `backend/app/api/routes/calls.py`
- [Call WebSocket](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/websocket.py): `backend/app/api/websocket.py`
- [Call manager](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/call_manager.py): `backend/app/orchestrator/call_manager.py`
- [Session store and event hub](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/session_manager.py): `backend/app/orchestrator/session_manager.py`
- [Conversation state](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/orchestrator/conversation_state.py): `backend/app/orchestrator/conversation_state.py`
- [Health route](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/api/routes/health.py): `backend/app/api/routes/health.py`

### Audio ingestion

- [Ingestion coordinator](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/coordinator.py): `backend/app/media/coordinator.py`
- [LiveKit audio consumer](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/audio_consumer.py): `backend/app/media/audio_consumer.py`
- [PCM frame chunker](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/frame_chunker.py): `backend/app/media/frame_chunker.py`
- [Bounded audio buffer](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/audio_buffer.py): `backend/app/media/audio_buffer.py`
- [Audio frame sink](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/media/sink.py): `backend/app/media/sink.py`
- [Audio contracts and health](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/schemas/audio.py): `backend/app/schemas/audio.py`

### LiveKit services

- [Room lifecycle service](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/services/livekit_service.py): `backend/app/services/livekit_service.py`
- [Token service](https://github.com/nihalmishra3009/nirikshan-voice-agent/blob/main/backend/app/services/token_service.py): `backend/app/services/token_service.py`

### Other components

- **Caller browser**
- **LiveKit SFU**

## Connections

- Caller browser → Live call page: opens (evidence: `README.md`)
- Live call page → Call panel: renders (evidence: `frontend/src/pages/LiveCall.tsx`)
- Call panel → Call session hook: uses (evidence: `frontend/src/components/call/CallPanel.tsx`)
- Call session hook → Call API client: requests (evidence: `frontend/src/hooks/useCallSession.ts`)
- Call session hook → WebSocket client: sends events (evidence: `frontend/src/hooks/useCallSession.ts`)
- Call session hook → LiveKit hook: uses (evidence: `frontend/src/hooks/useCallSession.ts`)
- Live call page → Health display: shows telemetry (evidence: `frontend/src/pages/LiveCall.tsx`)
- Call API client → Call routes: calls REST (evidence: `README.md`)
- WebSocket client → Call WebSocket: signals (evidence: `README.md`)
- Call routes → Call manager: delegates (evidence: `backend/app/api/routes/calls.py`)
- Call WebSocket → Call manager: dispatches events (evidence: `backend/app/api/websocket.py`)
- Call manager → Session store and event hub: reads and saves (evidence: `backend/app/orchestrator/call_manager.py`)
- Call manager → Conversation state: transitions (evidence: `backend/app/orchestrator/call_manager.py`)
- Call manager → Room lifecycle service: provisions rooms (evidence: `backend/app/orchestrator/call_manager.py`)
- Call manager → Token service: issues tokens (evidence: `backend/app/orchestrator/call_manager.py`)
- Call manager → Ingestion coordinator: attaches calls (evidence: `backend/app/orchestrator/call_manager.py`)
- Call manager → Session store and event hub: broadcasts events (evidence: `backend/app/orchestrator/call_manager.py`)
- Ingestion coordinator → LiveKit audio consumer: manages consumer (evidence: `backend/app/media/coordinator.py`)
- Ingestion coordinator → Audio frame sink: configures sink (evidence: `backend/app/media/coordinator.py`)
- LiveKit audio consumer → Token service: requests token (evidence: `backend/app/media/audio_consumer.py`)
- LiveKit audio consumer → LiveKit SFU: subscribes audio (evidence: `README.md`)
- LiveKit SFU → LiveKit audio consumer: streams microphone (evidence: `README.md`)
- LiveKit audio consumer → PCM frame chunker: normalizes frames (evidence: `backend/app/media/audio_consumer.py`)
- PCM frame chunker → Bounded audio buffer: enqueues packets (evidence: `README.md`)
- Bounded audio buffer → Audio frame sink: provides frames (evidence: `README.md`)
- PCM frame chunker → Audio contracts and health: creates packets (evidence: `backend/app/media/frame_chunker.py`)
- Bounded audio buffer → Audio contracts and health: tracks queue metrics (evidence: `backend/app/media/audio_buffer.py`)
- Call routes → Audio contracts and health: returns health (evidence: `backend/app/api/routes/calls.py`)
- Health route → Caller browser: serves health (evidence: `backend/app/api/routes/health.py`)
