# lithishkanna/grannus architecture

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

- Interactive diagram: https://gitdiagram.com/lithishkanna/grannus
- Repository: https://github.com/lithishkanna/grannus

## Overview

Grannus is a multilingual, voice-first healthcare triage platform. A patient records or uploads symptoms; the frontend submits audio to FastAPI, whose pipeline preprocesses it, transcribes and translates it, extracts a structured clinical summary, screens for safety risks, analyzes acoustic biomarkers, and assigns priority. Results feed a doctor dashboard; doctors can return translated spoken advice, and export triage data as an ABDM-ready FHIR bundle. The graph reflects the documented workflow and sampled source references; some frontend wiring and backend stages are described by the README rather than inspected source.

Main entry points: [`backend/app/pipeline.py`](https://github.com/lithishkanna/grannus/blob/main/backend/app/pipeline.py) (Triage orchestration), [`backend/app/main.py`](https://github.com/lithishkanna/grannus/blob/main/backend/app/main.py) (FastAPI endpoints), [`frontend/src/lib/api.ts`](https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/api.ts) (API client), [`backend/app/priority.py`](https://github.com/lithishkanna/grannus/blob/main/backend/app/priority.py) (Priority assessment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient intake"]
  node_voice_input["Voice capture<br/>[audio-recorder.tsx]"]
  node_upload["Audio upload<br/>[file-uploader.tsx]"]
end

subgraph group_triage["Triage pipeline"]
  node_api_server["FastAPI endpoints<br/>[main.py]"]
  node_pipeline["Triage orchestration<br/>[pipeline.py]"]
  node_audio["Audio preprocessing"]
  node_biomarkers["Acoustic analysis"]
  node_schemas["Clinical data contracts<br/>[schemas.py]"]
  node_safety["Safety screening<br/>[safety.py]"]
  node_missing["Missing information<br/>[missing_info.py]"]
  node_features["Feature extraction"]
  node_priority["Priority assessment<br/>[priority.py]"]
  node_ml["ML classifier<br/>[ml_model.py]"]
end

subgraph group_services["Language services"]
  node_speech["Speech transcription<br/>[sarvam_stt.py]"]
  node_extraction["Medical extraction<br/>[gemini_extract.py]"]
  node_translation["Translation<br/>[translation.py]"]
  node_remedies["Self-care guidance"]
  node_tts["Speech synthesis<br/>[sarvam_tts.py]"]
end

subgraph group_clinician["Doctor workflow"]
  node_dashboard["Doctor dashboard<br/>[page.tsx]"]
  node_reply["Voice reply"]
  node_fhir["FHIR bundle export<br/>[fhir_bundle.py]"]
end

subgraph group_client["Frontend and data"]
  node_api["API client<br/>[api.ts]"]
  node_store["Result persistence<br/>[store-result.ts]"]
  node_supabase[("Consultation database<br/>[supabase.ts]")]
end

node_patient_actor(("Patient"))
node_doctor_actor(("Doctor"))
node_sarvam{{"Sarvam AI"}}
node_gemini{{"Gemini API"}}

node_patient_actor -->|"records audio"| node_voice_input
node_patient_actor -->|"provides audio"| node_upload
node_voice_input -.->|"submits audio"| node_api
node_upload -.->|"submits audio"| node_api
node_api -->|"calls API"| node_api_server
node_api_server -->|"runs triage"| node_pipeline
node_pipeline -->|"preprocesses audio"| node_audio
node_pipeline -->|"analyzes audio"| node_biomarkers
node_pipeline -->|"transcribes audio"| node_speech
node_speech -->|"requests transcription"| node_sarvam
node_pipeline -->|"extracts summary"| node_extraction
node_extraction -->|"requests extraction"| node_gemini
node_pipeline -->|"screens risks"| node_safety
node_pipeline -->|"detects gaps"| node_missing
node_pipeline -->|"derives features"| node_features
node_pipeline -->|"assesses priority"| node_priority
node_priority -->|"extracts features"| node_features
node_priority -->|"classifies priority"| node_ml
node_pipeline -->|"produces structured result"| node_schemas
node_api_server -->|"generates bundle"| node_fhir
node_pipeline -->|"generates low-priority guidance"| node_remedies
node_remedies -->|"requests guidance"| node_gemini
node_pipeline -->|"translates follow-ups"| node_translation
node_translation -->|"requests translation"| node_sarvam
node_api_server -->|"transcribes doctor audio"| node_speech
node_api_server -->|"translates doctor advice"| node_translation
node_api_server -->|"generates voice note"| node_tts
node_tts -->|"requests speech synthesis"| node_sarvam
node_api -->|"provides API results"| node_store
node_store -->|"stores consultation"| node_supabase
node_store -->|"reads API client"| node_api
node_dashboard -.->|"loads consultations"| node_supabase
node_doctor_actor -->|"reviews triage"| node_dashboard
node_doctor_actor -->|"records advice"| node_reply
node_doctor_actor -->|"exports record"| node_fhir

click node_voice_input "https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/voice/audio-recorder.tsx"
click node_upload "https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/voice/file-uploader.tsx"
click node_api "https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/api.ts"
click node_api_server "https://github.com/lithishkanna/grannus/blob/main/backend/app/main.py"
click node_pipeline "https://github.com/lithishkanna/grannus/blob/main/backend/app/pipeline.py"
click node_audio "https://github.com/lithishkanna/grannus/blob/main/backend/app/audio_preprocessing.py"
click node_biomarkers "https://github.com/lithishkanna/grannus/blob/main/backend/app/acoustic_biomarkers.py"
click node_speech "https://github.com/lithishkanna/grannus/blob/main/backend/app/services/sarvam_stt.py"
click node_extraction "https://github.com/lithishkanna/grannus/blob/main/backend/app/services/gemini_extract.py"
click node_schemas "https://github.com/lithishkanna/grannus/blob/main/backend/app/schemas.py"
click node_safety "https://github.com/lithishkanna/grannus/blob/main/backend/app/safety.py"
click node_missing "https://github.com/lithishkanna/grannus/blob/main/backend/app/missing_info.py"
click node_features "https://github.com/lithishkanna/grannus/blob/main/backend/app/feature_extraction.py"
click node_priority "https://github.com/lithishkanna/grannus/blob/main/backend/app/priority.py"
click node_ml "https://github.com/lithishkanna/grannus/blob/main/backend/app/ml_model.py"
click node_translation "https://github.com/lithishkanna/grannus/blob/main/backend/app/services/translation.py"
click node_remedies "https://github.com/lithishkanna/grannus/blob/main/backend/app/services/gemini_home_remedies.py"
click node_dashboard "https://github.com/lithishkanna/grannus/blob/main/frontend/src/app/dashboard/page.tsx"
click node_store "https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/store-result.ts"
click node_supabase "https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/supabase.ts"
click node_reply "https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/dashboard/voice-reply-recorder.tsx"
click node_tts "https://github.com/lithishkanna/grannus/blob/main/backend/app/services/sarvam_tts.py"
click node_fhir "https://github.com/lithishkanna/grannus/blob/main/backend/app/fhir_bundle.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_voice_input,node_upload toneBlue
class node_api_server,node_pipeline,node_audio,node_biomarkers,node_schemas,node_safety,node_missing,node_features,node_priority,node_ml toneAmber
class node_speech,node_extraction,node_translation,node_remedies,node_tts,node_gemini toneMint
class node_dashboard,node_reply,node_fhir toneRose
class node_api,node_store,node_supabase,node_patient_actor,node_doctor_actor,node_sarvam toneIndigo
```

## Components

### Patient intake

- [Voice capture](https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/voice/audio-recorder.tsx): `frontend/src/components/voice/audio-recorder.tsx`
- [Audio upload](https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/voice/file-uploader.tsx): `frontend/src/components/voice/file-uploader.tsx`

### Triage pipeline

- [FastAPI endpoints](https://github.com/lithishkanna/grannus/blob/main/backend/app/main.py): `backend/app/main.py`
- [Triage orchestration](https://github.com/lithishkanna/grannus/blob/main/backend/app/pipeline.py): `backend/app/pipeline.py`
- [Audio preprocessing](https://github.com/lithishkanna/grannus/blob/main/backend/app/audio_preprocessing.py): `backend/app/audio_preprocessing.py`
- [Acoustic analysis](https://github.com/lithishkanna/grannus/blob/main/backend/app/acoustic_biomarkers.py): `backend/app/acoustic_biomarkers.py`
- [Clinical data contracts](https://github.com/lithishkanna/grannus/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Safety screening](https://github.com/lithishkanna/grannus/blob/main/backend/app/safety.py): `backend/app/safety.py`
- [Missing information](https://github.com/lithishkanna/grannus/blob/main/backend/app/missing_info.py): `backend/app/missing_info.py`
- [Feature extraction](https://github.com/lithishkanna/grannus/blob/main/backend/app/feature_extraction.py): `backend/app/feature_extraction.py`
- [Priority assessment](https://github.com/lithishkanna/grannus/blob/main/backend/app/priority.py): `backend/app/priority.py`
- [ML classifier](https://github.com/lithishkanna/grannus/blob/main/backend/app/ml_model.py): `backend/app/ml_model.py`

### Language services

- [Speech transcription](https://github.com/lithishkanna/grannus/blob/main/backend/app/services/sarvam_stt.py): `backend/app/services/sarvam_stt.py`
- [Medical extraction](https://github.com/lithishkanna/grannus/blob/main/backend/app/services/gemini_extract.py): `backend/app/services/gemini_extract.py`
- [Translation](https://github.com/lithishkanna/grannus/blob/main/backend/app/services/translation.py): `backend/app/services/translation.py`
- [Self-care guidance](https://github.com/lithishkanna/grannus/blob/main/backend/app/services/gemini_home_remedies.py): `backend/app/services/gemini_home_remedies.py`
- [Speech synthesis](https://github.com/lithishkanna/grannus/blob/main/backend/app/services/sarvam_tts.py): `backend/app/services/sarvam_tts.py`

### Doctor workflow

- [Doctor dashboard](https://github.com/lithishkanna/grannus/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`
- [Voice reply](https://github.com/lithishkanna/grannus/blob/main/frontend/src/components/dashboard/voice-reply-recorder.tsx): `frontend/src/components/dashboard/voice-reply-recorder.tsx`
- [FHIR bundle export](https://github.com/lithishkanna/grannus/blob/main/backend/app/fhir_bundle.py): `backend/app/fhir_bundle.py`

### Frontend and data

- [API client](https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [Result persistence](https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/store-result.ts): `frontend/src/lib/store-result.ts`
- [Consultation database](https://github.com/lithishkanna/grannus/blob/main/frontend/src/lib/supabase.ts): `frontend/src/lib/supabase.ts`

### Other components

- **Patient**
- **Doctor**
- **Sarvam AI**
- **Gemini API**

## Connections

- Patient → Voice capture: records audio
- Patient → Audio upload: provides audio
- Voice capture → API client: submits audio
- Audio upload → API client: submits audio
- API client → FastAPI endpoints: calls API
- FastAPI endpoints → Triage orchestration: runs triage (evidence: `backend/app/main.py`)
- Triage orchestration → Audio preprocessing: preprocesses audio (evidence: `backend/app/pipeline.py`)
- Triage orchestration → Acoustic analysis: analyzes audio (evidence: `backend/app/pipeline.py`)
- Triage orchestration → Speech transcription: transcribes audio (evidence: `backend/app/pipeline.py`)
- Speech transcription → Sarvam AI: requests transcription (evidence: `backend/app/services/sarvam_stt.py`)
- Triage orchestration → Medical extraction: extracts summary (evidence: `backend/app/pipeline.py`)
- Medical extraction → Gemini API: requests extraction (evidence: `backend/app/services/gemini_extract.py`)
- Triage orchestration → Safety screening: screens risks (evidence: `backend/app/pipeline.py`)
- Triage orchestration → Missing information: detects gaps (evidence: `backend/app/pipeline.py`)
- Triage orchestration → Feature extraction: derives features (evidence: `backend/app/pipeline.py`)
- Triage orchestration → Priority assessment: assesses priority (evidence: `backend/app/pipeline.py`)
- Priority assessment → Feature extraction: extracts features (evidence: `backend/app/priority.py`)
- Priority assessment → ML classifier: classifies priority (evidence: `backend/app/priority.py`)
- Triage orchestration → Clinical data contracts: produces structured result (evidence: `backend/app/pipeline.py`)
- FastAPI endpoints → FHIR bundle export: generates bundle (evidence: `backend/app/main.py`)
- Triage orchestration → Self-care guidance: generates low-priority guidance (evidence: `backend/app/services/gemini_home_remedies.py`)
- Self-care guidance → Gemini API: requests guidance (evidence: `backend/app/services/gemini_home_remedies.py`)
- Triage orchestration → Translation: translates follow-ups (evidence: `backend/app/pipeline.py`)
- Translation → Sarvam AI: requests translation (evidence: `backend/app/services/translation.py`)
- FastAPI endpoints → Speech transcription: transcribes doctor audio (evidence: `backend/app/main.py`)
- FastAPI endpoints → Translation: translates doctor advice (evidence: `backend/app/main.py`)
- FastAPI endpoints → Speech synthesis: generates voice note (evidence: `backend/app/main.py`)
- Speech synthesis → Sarvam AI: requests speech synthesis
- API client → Result persistence: provides API results (evidence: `frontend/src/lib/store-result.ts`)
- Result persistence → Consultation database: stores consultation (evidence: `frontend/src/lib/store-result.ts`)
- Result persistence → API client: reads API client (evidence: `frontend/src/lib/store-result.ts`)
- Doctor dashboard → Consultation database: loads consultations
- Doctor → Doctor dashboard: reviews triage
- Doctor → Voice reply: records advice
- Doctor → FHIR bundle export: exports record
