# harsh-pathak3601/dhwani-ai architecture

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

- Interactive diagram: https://gitdiagram.com/harsh-pathak3601/dhwani-ai
- Repository: https://github.com/harsh-pathak3601/dhwani-ai

## Overview

Dhwani AI is a real-time voice-cloning and scam-protection application. A user starts a live or uploaded-audio session; the browser extracts acoustic features and streams audio/transcripts, while the server evaluates voice authenticity, caller identity and conversational context, then applies risk policy and can hold consequential actions for out-of-band verification. Results feed live coaching and reports, with separate case/community and account capabilities. Server routing and the browser session flow are sampled; internal socket dispatch and several route/service implementations are not, so those links are limited to documented or strongly indicated boundaries.

Main entry points: [`server/src/sockets/callSocket.ts`](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/sockets/callSocket.ts) (Call event handler), [`server/src/index.ts`](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/index.ts) (HTTP and socket entry), [`server/src/config/db.ts`](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/config/db.ts) (MongoDB), [`client/src/components/CallSession.tsx`](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/CallSession.tsx) (Call session UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_app["App routes<br/>[App.tsx]"]
  node_callui["Call session UI<br/>[CallSession.tsx]"]
  node_liveviews["Transcript and coaching<br/>[TranscriptFeed.tsx]"]
  node_safetyviews["Hold and verification"]
end

subgraph group_live["Live protection"]
  node_sessionhook["Session coordinator<br/>[useSession.ts]"]
  node_capture["Audio capture<br/>[useAudioCapture.ts]"]
  node_extractor["Feature extraction"]
  node_socketclient["Socket connection<br/>[useSocket.ts]"]
  node_clientstate[("Session state<br/>[useSessionStore.ts]")]
end

subgraph group_analysis["Risk analysis"]
  node_voiceauth["Voice authenticity"]
  node_classifier["Acoustic classifier"]
  node_identity["Identity context"]
  node_policy["Risk policy<br/>[policyEngine.ts]"]
  node_liveness["Liveness checks<br/>[livenessService.ts]"]
  node_trust["Trust channel"]
end

subgraph group_server["Server capabilities"]
  node_serverentry["HTTP and socket entry<br/>[index.ts]"]
  node_socketserver["Call event handler<br/>[callSocket.ts]"]
  node_sessionroutes["Session API<br/>[sessions.ts]"]
  node_authroutes["Authentication API<br/>[auth.ts]"]
  node_reportroutes["Reports API<br/>[reports.ts]"]
  node_communityroutes["Community reports API<br/>[community.ts]"]
  node_reportsvc["Report generation<br/>[reportService.ts]"]
  node_deepgram["Deepgram integration<br/>[deepgramService.ts]"]
  node_groq["Groq integration<br/>[groqService.ts]"]
end

subgraph group_persistence["State and records"]
  node_db[("MongoDB<br/>[db.ts]")]
  node_callmodel[("Call sessions<br/>[CallSession.ts]")]
  node_reportmodel[("Reports<br/>[Report.ts]")]
  node_communitymodel[("Community reports<br/>[CommunityReport.ts]")]
  node_speakerprofile[("Speaker profiles<br/>[SpeakerProfile.ts]")]
  node_authmodel[("Users<br/>[User.ts]")]
end

node_person(("User"))
node_deepgramext(("Deepgram"))
node_groqext(("Groq"))

node_person -->|"uses"| node_app
node_app -->|"routes to"| node_callui
node_callui -->|"starts session"| node_sessionhook
node_sessionhook -->|"controls capture"| node_capture
node_sessionhook -->|"uses connection"| node_socketclient
node_sessionhook -->|"updates state"| node_clientstate
node_capture -->|"extracts features"| node_extractor
node_capture -->|"emits audio features"| node_socketclient
node_socketclient -->|"connects"| node_serverentry
node_serverentry -->|"dispatches calls"| node_socketserver
node_serverentry -->|"mounts API"| node_sessionroutes
node_serverentry -->|"mounts API"| node_authroutes
node_serverentry -->|"mounts API"| node_reportroutes
node_serverentry -->|"mounts API"| node_communityroutes
node_socketserver -->|"analyzes voice"| node_voiceauth
node_voiceauth -->|"classifies features"| node_classifier
node_socketserver -->|"checks identity context"| node_identity
node_identity -->|"reads profile"| node_speakerprofile
node_identity -.->|"requests analysis"| node_groq
node_groq -.->|"calls"| node_groqext
node_socketserver -->|"evaluates risk"| node_policy
node_policy -->|"uses voice result"| node_voiceauth
node_policy -->|"uses identity result"| node_identity
node_socketserver -->|"checks liveness"| node_liveness
node_socketserver -->|"requests verification"| node_trust
node_socketserver -->|"creates report"| node_reportsvc
node_reportsvc -->|"stores report"| node_reportmodel
node_sessionroutes -->|"accesses sessions"| node_callmodel
node_authroutes -->|"accesses users"| node_authmodel
node_communityroutes -->|"accesses reports"| node_communitymodel
node_reportroutes -->|"uses reporting"| node_reportsvc
node_deepgram -.->|"connects"| node_deepgramext
node_callui -->|"displays transcript and coaching"| node_liveviews
node_callui -->|"displays hold controls"| node_safetyviews
node_person -.->|"speech transcription"| node_deepgram
node_db -->|"persists"| node_callmodel
node_db -->|"persists"| node_reportmodel
node_db -->|"persists"| node_communitymodel
node_db -->|"persists"| node_speakerprofile
node_db -->|"persists"| node_authmodel

click node_app "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/App.tsx"
click node_callui "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/CallSession.tsx"
click node_sessionhook "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useSession.ts"
click node_capture "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useAudioCapture.ts"
click node_extractor "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/services/audioFeatureExtractor.ts"
click node_socketclient "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useSocket.ts"
click node_clientstate "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/store/useSessionStore.ts"
click node_liveviews "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/TranscriptFeed.tsx"
click node_safetyviews "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/PreTransactionWarningModal.tsx"
click node_serverentry "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/index.ts"
click node_socketserver "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/sockets/callSocket.ts"
click node_sessionroutes "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/sessions.ts"
click node_authroutes "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/auth.ts"
click node_reportroutes "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/reports.ts"
click node_communityroutes "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/community.ts"
click node_voiceauth "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/voiceAuthService.ts"
click node_classifier "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/voiceMlClassifier.ts"
click node_identity "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/identityContextService.ts"
click node_policy "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/policyEngine.ts"
click node_liveness "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/livenessService.ts"
click node_trust "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/trustChannelService.ts"
click node_reportsvc "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/reportService.ts"
click node_deepgram "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/deepgramService.ts"
click node_groq "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/groqService.ts"
click node_db "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/config/db.ts"
click node_callmodel "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/CallSession.ts"
click node_reportmodel "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/Report.ts"
click node_communitymodel "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/CommunityReport.ts"
click node_speakerprofile "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/SpeakerProfile.ts"
click node_authmodel "https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/User.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_app,node_callui,node_liveviews,node_safetyviews,node_person toneBlue
class node_sessionhook,node_capture,node_extractor,node_socketclient,node_clientstate toneAmber
class node_voiceauth,node_classifier,node_identity,node_policy,node_liveness,node_trust toneMint
class node_serverentry,node_socketserver,node_sessionroutes,node_authroutes,node_reportroutes,node_communityroutes,node_reportsvc,node_deepgram,node_groq toneRose
class node_db,node_callmodel,node_reportmodel,node_communitymodel,node_speakerprofile,node_authmodel,node_deepgramext,node_groqext toneIndigo
```

## Components

### Browser experience

- [App routes](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Call session UI](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/CallSession.tsx): `client/src/components/CallSession.tsx`
- [Transcript and coaching](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/TranscriptFeed.tsx): `client/src/components/TranscriptFeed.tsx`
- [Hold and verification](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/components/PreTransactionWarningModal.tsx): `client/src/components/PreTransactionWarningModal.tsx`

### Live protection

- [Session coordinator](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useSession.ts): `client/src/hooks/useSession.ts`
- [Audio capture](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useAudioCapture.ts): `client/src/hooks/useAudioCapture.ts`
- [Feature extraction](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/services/audioFeatureExtractor.ts): `client/src/services/audioFeatureExtractor.ts`
- [Socket connection](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/hooks/useSocket.ts): `client/src/hooks/useSocket.ts`
- [Session state](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/client/src/store/useSessionStore.ts): `client/src/store/useSessionStore.ts`

### Risk analysis

- [Voice authenticity](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/voiceAuthService.ts): `server/src/services/voiceAuthService.ts`
- [Acoustic classifier](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/voiceMlClassifier.ts): `server/src/services/voiceMlClassifier.ts`
- [Identity context](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/identityContextService.ts): `server/src/services/identityContextService.ts`
- [Risk policy](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/policyEngine.ts): `server/src/services/policyEngine.ts`
- [Liveness checks](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/livenessService.ts): `server/src/services/livenessService.ts`
- [Trust channel](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/trustChannelService.ts): `server/src/services/trustChannelService.ts`

### Server capabilities

- [HTTP and socket entry](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/index.ts): `server/src/index.ts`
- [Call event handler](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/sockets/callSocket.ts): `server/src/sockets/callSocket.ts`
- [Session API](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/sessions.ts): `server/src/routes/sessions.ts`
- [Authentication API](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`
- [Reports API](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/reports.ts): `server/src/routes/reports.ts`
- [Community reports API](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/routes/community.ts): `server/src/routes/community.ts`
- [Report generation](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/reportService.ts): `server/src/services/reportService.ts`
- [Deepgram integration](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/deepgramService.ts): `server/src/services/deepgramService.ts`
- [Groq integration](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/services/groqService.ts): `server/src/services/groqService.ts`

### State and records

- [MongoDB](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/config/db.ts): `server/src/config/db.ts`
- [Call sessions](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/CallSession.ts): `server/src/models/CallSession.ts`
- [Reports](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/Report.ts): `server/src/models/Report.ts`
- [Community reports](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/CommunityReport.ts): `server/src/models/CommunityReport.ts`
- [Speaker profiles](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/SpeakerProfile.ts): `server/src/models/SpeakerProfile.ts`
- [Users](https://github.com/harsh-pathak3601/dhwani-ai/blob/main/server/src/models/User.ts): `server/src/models/User.ts`

### Other components

- **User**
- **Deepgram**
- **Groq**

## Connections

- User → App routes: uses
- App routes → Call session UI: routes to
- Call session UI → Session coordinator: starts session
- Session coordinator → Audio capture: controls capture
- Session coordinator → Socket connection: uses connection
- Session coordinator → Session state: updates state
- Audio capture → Feature extraction: extracts features
- Audio capture → Socket connection: emits audio features
- Socket connection → HTTP and socket entry: connects
- HTTP and socket entry → Call event handler: dispatches calls
- HTTP and socket entry → Session API: mounts API
- HTTP and socket entry → Authentication API: mounts API
- HTTP and socket entry → Reports API: mounts API
- HTTP and socket entry → Community reports API: mounts API
- Call event handler → Voice authenticity: analyzes voice
- Voice authenticity → Acoustic classifier: classifies features
- Call event handler → Identity context: checks identity context
- Identity context → Speaker profiles: reads profile
- Identity context → Groq integration: requests analysis
- Groq integration → Groq: calls
- Call event handler → Risk policy: evaluates risk
- Risk policy → Voice authenticity: uses voice result
- Risk policy → Identity context: uses identity result
- Call event handler → Liveness checks: checks liveness
- Call event handler → Trust channel: requests verification
- Call event handler → Report generation: creates report
- Report generation → Reports: stores report
- Session API → Call sessions: accesses sessions
- Authentication API → Users: accesses users
- Community reports API → Community reports: accesses reports
- Reports API → Report generation: uses reporting
- Deepgram integration → Deepgram: connects
- Call session UI → Transcript and coaching: displays transcript and coaching
- Call session UI → Hold and verification: displays hold controls
- User → Deepgram integration: speech transcription
- MongoDB → Call sessions: persists
- MongoDB → Reports: persists
- MongoDB → Community reports: persists
- MongoDB → Speaker profiles: persists
- MongoDB → Users: persists
