# whoevenisshubham/cliniq architecture

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

- Interactive diagram: https://gitdiagram.com/whoevenisshubham/cliniq
- Repository: https://github.com/whoevenisshubham/cliniq

## Overview

CliniQ is a clinical decision-support and EMR platform for Indian healthcare. Its central workflow runs from a doctor’s consultation through live transcription, AI extraction and differential diagnosis, then review and saving of structured records, prescriptions, safety checks, billing, and an audit trail. Patient, receptionist, administrator, and researcher dashboards provide distinct supporting workflows. The README documents several capabilities whose implementation was not sampled; those links are shown as documented rather than inferred from source. Evidence is limited to the supplied excerpts, source index, and README.

Main entry points: [`src/components/doctor/ActiveConsultationClient.tsx`](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/doctor/ActiveConsultationClient.tsx) (Consultation Workspace), [`src/hooks/useMedicalScribe.ts`](https://github.com/whoevenisshubham/cliniq/blob/main/src/hooks/useMedicalScribe.ts) (Voice Scribe), [`src/app/api/extract/route.ts`](https://github.com/whoevenisshubham/cliniq/blob/main/src/app/api/extract/route.ts) (Clinical Extraction), [`src/lib/supabase-server.ts`](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/supabase-server.ts) (Supabase)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_care["Clinical Workflow"]
  node_consult["Consultation Workspace"]
  node_scribe["Voice Scribe"]
  node_extract["Clinical Extraction<br/>[route.ts]"]
  node_emr["EMR Records"]
end

subgraph group_services["Clinical Services"]
  node_epidemiology["Epidemiology Context<br/>[epidemiology.ts]"]
  node_safety["Drug Safety<br/>[safety-guard.ts]"]
  node_pricing["Generic Drug Pricing<br/>[jan-aushadhi.ts]"]
  node_billing["Live Billing<br/>[billing-engine.ts]"]
  node_audit["Audit Trail<br/>[audit-chain.ts]"]
end

subgraph group_platform["Platform State"]
  node_offline["Offline Sync<br/>[useOfflineSync.ts]"]
  node_store["Consultation State"]
  node_database[("Supabase<br/>[supabase-server.ts]")]
end

subgraph group_portals["Role Portals"]
  node_patient["Patient Portal"]
  node_patientchat["Patient AI Chat"]
  node_admin["Admin Portal"]
  node_research["Research Portal"]
end

subgraph group_operations["Care Operations"]
  node_reception["Reception Desk"]
  node_queue["Patient Queue API<br/>[route.ts]"]
  node_triage["Ambulance Triage<br/>[triage.ts]"]
end

node_doctor(("Doctor"))
node_groq{{"Groq LLM"}}
node_deepgram{{"Deepgram STT"}}

node_doctor -->|"conducts visit"| node_consult
node_consult -->|"starts recording"| node_scribe
node_scribe -->|"streams audio"| node_deepgram
node_scribe -->|"updates transcript"| node_store
node_consult -->|"requests extraction"| node_extract
node_extract -->|"requests extraction"| node_groq
node_extract -->|"builds context"| node_epidemiology
node_consult -->|"reviews records"| node_emr
node_consult -->|"checks prescription"| node_safety
node_consult -->|"shows alternatives"| node_pricing
node_consult -->|"updates charges"| node_billing
node_consult -->|"records actions"| node_audit
node_consult -->|"queues offline data"| node_offline
node_offline -->|"syncs queued data"| node_database
node_consult -->|"reads consultation state"| node_store
node_reception -->|"manages queue"| node_queue
node_queue -->|"reads and writes"| node_database
node_patient -->|"asks health questions"| node_patientchat
node_admin -.->|"reviews operations data"| node_database
node_research -.->|"reviews trends"| node_epidemiology
node_consult -.->|"uses pre-arrival notes"| node_triage

click node_consult "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/doctor/ActiveConsultationClient.tsx"
click node_scribe "https://github.com/whoevenisshubham/cliniq/blob/main/src/hooks/useMedicalScribe.ts"
click node_extract "https://github.com/whoevenisshubham/cliniq/blob/main/src/app/api/extract/route.ts"
click node_epidemiology "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/epidemiology.ts"
click node_emr "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/doctor/EMRRecordsClient.tsx"
click node_safety "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/safety-guard.ts"
click node_pricing "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/jan-aushadhi.ts"
click node_billing "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/billing-engine.ts"
click node_audit "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/audit-chain.ts"
click node_offline "https://github.com/whoevenisshubham/cliniq/blob/main/src/hooks/useOfflineSync.ts"
click node_store "https://github.com/whoevenisshubham/cliniq/blob/main/src/store/consultationStore.ts"
click node_database "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/supabase-server.ts"
click node_patient "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/patient/PatientDashboardClient.tsx"
click node_patientchat "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/patient/PatientChatClient.tsx"
click node_reception "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/receptionist/ReceptionistDashboardClient.tsx"
click node_queue "https://github.com/whoevenisshubham/cliniq/blob/main/src/app/api/queue/route.ts"
click node_triage "https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/triage.ts"
click node_admin "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/admin/AdminDashboardClient.tsx"
click node_research "https://github.com/whoevenisshubham/cliniq/blob/main/src/components/research/ResearchDashboardClient.tsx"

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_consult,node_scribe,node_extract,node_emr toneBlue
class node_epidemiology,node_safety,node_pricing,node_billing,node_audit toneAmber
class node_offline,node_store,node_database toneMint
class node_patient,node_patientchat,node_admin,node_research toneRose
class node_reception,node_queue,node_triage,node_doctor,node_groq,node_deepgram toneIndigo
```

## Components

### Clinical Workflow

- [Consultation Workspace](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/doctor/ActiveConsultationClient.tsx): `src/components/doctor/ActiveConsultationClient.tsx`
- [Voice Scribe](https://github.com/whoevenisshubham/cliniq/blob/main/src/hooks/useMedicalScribe.ts): `src/hooks/useMedicalScribe.ts`
- [Clinical Extraction](https://github.com/whoevenisshubham/cliniq/blob/main/src/app/api/extract/route.ts): `src/app/api/extract/route.ts`
- [EMR Records](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/doctor/EMRRecordsClient.tsx): `src/components/doctor/EMRRecordsClient.tsx`

### Clinical Services

- [Epidemiology Context](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/epidemiology.ts): `src/lib/epidemiology.ts`
- [Drug Safety](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/safety-guard.ts): `src/lib/safety-guard.ts`
- [Generic Drug Pricing](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/jan-aushadhi.ts): `src/lib/jan-aushadhi.ts`
- [Live Billing](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/billing-engine.ts): `src/lib/billing-engine.ts`
- [Audit Trail](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/audit-chain.ts): `src/lib/audit-chain.ts`

### Platform State

- [Offline Sync](https://github.com/whoevenisshubham/cliniq/blob/main/src/hooks/useOfflineSync.ts): `src/hooks/useOfflineSync.ts`
- [Consultation State](https://github.com/whoevenisshubham/cliniq/blob/main/src/store/consultationStore.ts): `src/store/consultationStore.ts`
- [Supabase](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/supabase-server.ts): `src/lib/supabase-server.ts`

### Role Portals

- [Patient Portal](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/patient/PatientDashboardClient.tsx): `src/components/patient/PatientDashboardClient.tsx`
- [Patient AI Chat](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/patient/PatientChatClient.tsx): `src/components/patient/PatientChatClient.tsx`
- [Admin Portal](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/admin/AdminDashboardClient.tsx): `src/components/admin/AdminDashboardClient.tsx`
- [Research Portal](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/research/ResearchDashboardClient.tsx): `src/components/research/ResearchDashboardClient.tsx`

### Care Operations

- [Reception Desk](https://github.com/whoevenisshubham/cliniq/blob/main/src/components/receptionist/ReceptionistDashboardClient.tsx): `src/components/receptionist/ReceptionistDashboardClient.tsx`
- [Patient Queue API](https://github.com/whoevenisshubham/cliniq/blob/main/src/app/api/queue/route.ts): `src/app/api/queue/route.ts`
- [Ambulance Triage](https://github.com/whoevenisshubham/cliniq/blob/main/src/lib/triage.ts): `src/lib/triage.ts`

### Other components

- **Doctor**
- **Groq LLM**
- **Deepgram STT**

## Connections

- Doctor → Consultation Workspace: conducts visit
- Consultation Workspace → Voice Scribe: starts recording (evidence: `src/components/doctor/ActiveConsultationClient.tsx`)
- Voice Scribe → Deepgram STT: streams audio
- Voice Scribe → Consultation State: updates transcript (evidence: `src/hooks/useMedicalScribe.ts`)
- Consultation Workspace → Clinical Extraction: requests extraction
- Clinical Extraction → Groq LLM: requests extraction (evidence: `src/app/api/extract/route.ts`)
- Clinical Extraction → Epidemiology Context: builds context (evidence: `src/app/api/extract/route.ts`)
- Consultation Workspace → EMR Records: reviews records
- Consultation Workspace → Drug Safety: checks prescription
- Consultation Workspace → Generic Drug Pricing: shows alternatives
- Consultation Workspace → Live Billing: updates charges
- Consultation Workspace → Audit Trail: records actions (evidence: `src/components/doctor/ActiveConsultationClient.tsx`)
- Consultation Workspace → Offline Sync: queues offline data (evidence: `src/components/doctor/ActiveConsultationClient.tsx`)
- Offline Sync → Supabase: syncs queued data
- Consultation Workspace → Consultation State: reads consultation state (evidence: `src/components/doctor/ActiveConsultationClient.tsx`)
- Reception Desk → Patient Queue API: manages queue
- Patient Queue API → Supabase: reads and writes (evidence: `src/app/api/queue/route.ts`)
- Patient Portal → Patient AI Chat: asks health questions
- Admin Portal → Supabase: reviews operations data
- Research Portal → Epidemiology Context: reviews trends
- Consultation Workspace → Ambulance Triage: uses pre-arrival notes
