# mohithbs-stack/mahe_sanket architecture

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

- Interactive diagram: https://gitdiagram.com/mohithbs-stack/mahe_sanket
- Repository: https://github.com/mohithbs-stack/mahe_sanket

## Overview

Sanket protects elders during live calls: audio is captured, transcribed, scored, and—when risk warrants—surfaced as a vernacular takeover and guardian alert. Guardians can configure a profile and review saved incidents and reports; the elder companion and guardian console are separate entry surfaces. The graph follows documented features and indexed imports, but several page and service implementations were not sampled, so those links rely on README statements or are omitted where ownership is unclear.

Main entry points: [`sanket/src/pages/Console.jsx`](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Console.jsx) (Guardian console), [`sanket/src/pages/ElderIdle.jsx`](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/ElderIdle.jsx) (Elder companion), [`sanket/src/App.jsx`](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/App.jsx) (Route shell), [`sanket/src/services/db.js`](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/db.js) (Local incident store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["User surfaces"]
  node_app["Route shell<br/>[App.jsx]"]
  node_console["Guardian console<br/>[Console.jsx]"]
  node_companion["Elder companion<br/>[ElderIdle.jsx]"]
  node_onboarding["Profile setup<br/>[Onboarding.jsx]"]
  node_settings["Protection settings<br/>[Settings.jsx]"]
end

subgraph group_defense["Live call defense"]
  node_capture["Audio capture<br/>[useAudioCapture.js]"]
  node_session["Session telemetry"]
  node_asr["Speech recognition<br/>[sarvamASR.js]"]
  node_scoring["Threat scoring<br/>[riskScoring.js]"]
  node_riskdata["Scam scenarios<br/>[riskTestSet.js]"]
  node_gauge["Risk gauge<br/>[RiskGauge.jsx]"]
  node_transcript["Transcript stream"]
  node_statechip["Threat state<br/>[StateChip.jsx]"]
  node_takeover["Alert takeover<br/>[AlertTakeover.jsx]"]
end

subgraph group_records["Incident records"]
  node_history["Incident history<br/>[History.jsx]"]
  node_report["Incident report<br/>[IncidentReport.jsx]"]
  node_db[("Local incident store<br/>[db.js]")]
  node_reportgen["Report generator"]
  node_incidentcard["Incident card<br/>[IncidentCard.jsx]"]
end

subgraph group_integrations["External integrations"]
  node_tts["Warning speech<br/>[sarvamTTS.js]"]
  node_telegram["Guardian notification<br/>[telegramNotify.js]"]
end

node_elder(("Elder"))
node_guardian(("Guardian"))
node_localstorage[("Browser local storage")]
node_sarvam["Sarvam AI"]
node_n8n["n8n webhook"]
node_telegramservice["Telegram"]

node_elder -->|"uses"| node_companion
node_guardian -->|"uses"| node_console
node_app -->|"routes"| node_onboarding
node_app -->|"routes"| node_console
node_app -->|"routes"| node_companion
node_app -->|"routes"| node_history
node_app -->|"routes"| node_report
node_app -->|"routes"| node_settings
node_console -->|"starts"| node_capture
node_companion -->|"starts"| node_capture
node_capture -.->|"sends audio"| node_asr
node_console -->|"transcribes chunks"| node_asr
node_companion -->|"transcribes chunks"| node_asr
node_console -->|"scores transcript"| node_scoring
node_companion -->|"scores transcript"| node_scoring
node_scoring -.->|"posts optionally"| node_n8n
node_scoring -->|"evaluates scenarios"| node_riskdata
node_console -->|"manages session"| node_session
node_companion -->|"manages session"| node_session
node_session -->|"saves qualifying sessions"| node_db
node_db -->|"reads and writes"| node_localstorage
node_console -->|"renders score"| node_gauge
node_console -->|"renders transcript"| node_transcript
node_console -->|"renders state"| node_statechip
node_console -->|"renders alert"| node_takeover
node_companion -->|"renders alert"| node_takeover
node_console -->|"plays warning"| node_tts
node_companion -->|"plays warning"| node_tts
node_console -->|"sends alert"| node_telegram
node_telegram -->|"notifies"| node_telegramservice
node_tts -->|"requests speech"| node_sarvam
node_asr -->|"requests transcription"| node_sarvam
node_onboarding -->|"saves profile"| node_db
node_settings -->|"updates settings"| node_db
node_settings -->|"tests alert"| node_telegram
node_settings -->|"tests speech"| node_tts
node_history -->|"loads incidents"| node_db
node_history -->|"renders incidents"| node_incidentcard
node_report -->|"loads session"| node_db
node_report -->|"generates report"| node_reportgen
node_report -->|"renders score"| node_gauge
node_console -.->|"links incident report"| node_report

click node_app "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/App.jsx"
click node_console "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Console.jsx"
click node_companion "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/ElderIdle.jsx"
click node_onboarding "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Onboarding.jsx"
click node_settings "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Settings.jsx"
click node_history "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/History.jsx"
click node_report "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/IncidentReport.jsx"
click node_capture "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/hooks/useAudioCapture.js"
click node_session "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/hooks/useTranscriptSession.js"
click node_asr "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/sarvamASR.js"
click node_scoring "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/riskScoring.js"
click node_riskdata "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/data/riskTestSet.js"
click node_gauge "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/RiskGauge.jsx"
click node_transcript "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/TranscriptStream.jsx"
click node_statechip "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/StateChip.jsx"
click node_takeover "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/AlertTakeover.jsx"
click node_tts "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/sarvamTTS.js"
click node_telegram "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/telegramNotify.js"
click node_db "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/db.js"
click node_reportgen "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/incidentReportGenerator.js"
click node_incidentcard "https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/IncidentCard.jsx"

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_console,node_companion,node_onboarding,node_settings toneBlue
class node_capture,node_session,node_asr,node_scoring,node_riskdata,node_gauge,node_transcript,node_statechip,node_takeover,node_localstorage toneAmber
class node_history,node_report,node_db,node_reportgen,node_incidentcard,node_n8n toneMint
class node_tts,node_telegram toneRose
class node_elder,node_guardian,node_sarvam,node_telegramservice toneIndigo
```

## Components

### User surfaces

- [Route shell](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/App.jsx): `sanket/src/App.jsx`
- [Guardian console](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Console.jsx): `sanket/src/pages/Console.jsx`
- [Elder companion](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/ElderIdle.jsx): `sanket/src/pages/ElderIdle.jsx`
- [Profile setup](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Onboarding.jsx): `sanket/src/pages/Onboarding.jsx`
- [Protection settings](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/Settings.jsx): `sanket/src/pages/Settings.jsx`

### Live call defense

- [Audio capture](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/hooks/useAudioCapture.js): `sanket/src/hooks/useAudioCapture.js`
- [Session telemetry](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/hooks/useTranscriptSession.js): `sanket/src/hooks/useTranscriptSession.js`
- [Speech recognition](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/sarvamASR.js): `sanket/src/services/sarvamASR.js`
- [Threat scoring](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/riskScoring.js): `sanket/src/services/riskScoring.js`
- [Scam scenarios](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/data/riskTestSet.js): `sanket/src/data/riskTestSet.js`
- [Risk gauge](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/RiskGauge.jsx): `sanket/src/components/RiskGauge.jsx`
- [Transcript stream](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/TranscriptStream.jsx): `sanket/src/components/TranscriptStream.jsx`
- [Threat state](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/StateChip.jsx): `sanket/src/components/StateChip.jsx`
- [Alert takeover](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/AlertTakeover.jsx): `sanket/src/components/AlertTakeover.jsx`

### Incident records

- [Incident history](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/History.jsx): `sanket/src/pages/History.jsx`
- [Incident report](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/pages/IncidentReport.jsx): `sanket/src/pages/IncidentReport.jsx`
- [Local incident store](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/db.js): `sanket/src/services/db.js`
- [Report generator](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/incidentReportGenerator.js): `sanket/src/services/incidentReportGenerator.js`
- [Incident card](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/components/IncidentCard.jsx): `sanket/src/components/IncidentCard.jsx`

### External integrations

- [Warning speech](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/sarvamTTS.js): `sanket/src/services/sarvamTTS.js`
- [Guardian notification](https://github.com/mohithbs-stack/mahe_sanket/blob/main/sanket/src/services/telegramNotify.js): `sanket/src/services/telegramNotify.js`

### Other components

- **Elder**
- **Guardian**
- **Browser local storage**
- **Sarvam AI**
- **n8n webhook**
- **Telegram**

## Connections

- Elder → Elder companion: uses (evidence: `README.md`)
- Guardian → Guardian console: uses (evidence: `README.md`)
- Route shell → Profile setup: routes (evidence: `sanket/src/App.jsx`)
- Route shell → Guardian console: routes (evidence: `sanket/src/App.jsx`)
- Route shell → Elder companion: routes (evidence: `sanket/src/App.jsx`)
- Route shell → Incident history: routes (evidence: `sanket/src/App.jsx`)
- Route shell → Incident report: routes (evidence: `sanket/src/App.jsx`)
- Route shell → Protection settings: routes (evidence: `sanket/src/App.jsx`)
- Guardian console → Audio capture: starts (evidence: `sanket/src/pages/Console.jsx`)
- Elder companion → Audio capture: starts (evidence: `sanket/src/pages/ElderIdle.jsx`)
- Audio capture → Speech recognition: sends audio
- Guardian console → Speech recognition: transcribes chunks (evidence: `sanket/src/pages/Console.jsx`)
- Elder companion → Speech recognition: transcribes chunks (evidence: `sanket/src/pages/ElderIdle.jsx`)
- Guardian console → Threat scoring: scores transcript (evidence: `sanket/src/pages/Console.jsx`)
- Elder companion → Threat scoring: scores transcript (evidence: `sanket/src/pages/ElderIdle.jsx`)
- Threat scoring → n8n webhook: posts optionally (evidence: `sanket/src/services/riskScoring.js`)
- Threat scoring → Scam scenarios: evaluates scenarios (evidence: `sanket/src/data/riskTestSet.js`)
- Guardian console → Session telemetry: manages session (evidence: `sanket/src/pages/Console.jsx`)
- Elder companion → Session telemetry: manages session (evidence: `sanket/src/pages/ElderIdle.jsx`)
- Session telemetry → Local incident store: saves qualifying sessions (evidence: `sanket/src/hooks/useTranscriptSession.js`)
- Local incident store → Browser local storage: reads and writes (evidence: `sanket/src/services/db.js`)
- Guardian console → Risk gauge: renders score (evidence: `sanket/src/pages/Console.jsx`)
- Guardian console → Transcript stream: renders transcript (evidence: `sanket/src/pages/Console.jsx`)
- Guardian console → Threat state: renders state (evidence: `sanket/src/pages/Console.jsx`)
- Guardian console → Alert takeover: renders alert (evidence: `sanket/src/pages/Console.jsx`)
- Elder companion → Alert takeover: renders alert (evidence: `sanket/src/pages/ElderIdle.jsx`)
- Guardian console → Warning speech: plays warning (evidence: `README.md`)
- Elder companion → Warning speech: plays warning (evidence: `README.md`)
- Guardian console → Guardian notification: sends alert (evidence: `sanket/src/pages/Console.jsx`)
- Guardian notification → Telegram: notifies (evidence: `README.md`)
- Warning speech → Sarvam AI: requests speech (evidence: `sanket/src/services/sarvamTTS.js`)
- Speech recognition → Sarvam AI: requests transcription (evidence: `README.md`)
- Profile setup → Local incident store: saves profile (evidence: `sanket/src/pages/Onboarding.jsx`)
- Protection settings → Local incident store: updates settings (evidence: `sanket/src/pages/Settings.jsx`)
- Protection settings → Guardian notification: tests alert (evidence: `sanket/src/pages/Settings.jsx`)
- Protection settings → Warning speech: tests speech (evidence: `sanket/src/pages/Settings.jsx`)
- Incident history → Local incident store: loads incidents (evidence: `sanket/src/pages/History.jsx`)
- Incident history → Incident card: renders incidents (evidence: `sanket/src/pages/History.jsx`)
- Incident report → Local incident store: loads session (evidence: `sanket/src/pages/IncidentReport.jsx`)
- Incident report → Report generator: generates report (evidence: `sanket/src/pages/IncidentReport.jsx`)
- Incident report → Risk gauge: renders score (evidence: `sanket/src/pages/IncidentReport.jsx`)
- Guardian console → Incident report: links incident report
