# kartikchilling-afk/sih architecture

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

- Interactive diagram: https://gitdiagram.com/kartikchilling-afk/sih
- Repository: https://github.com/kartikchilling-afk/sih

## Overview

MediKiosk is a patient intake portal: patients authenticate, create a guided health story, upload records, and review a clinical summary/report. Supabase provides authentication, per-user data, and private document storage; Edge Functions handle Aadhaar verification, document OCR, AI report review, and optional cloned-voice playback. The sampled excerpts establish these backend integrations and the App’s document reads, but omit much of App’s event wiring, so uncertain frontend-to-function links are not shown.

Main entry points: [`src/App.tsx`](https://github.com/kartikchilling-afk/sih/blob/main/src/App.tsx) (Portal UI), [`supabase/functions/aadhaar-auth/index.ts`](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/aadhaar-auth/index.ts) (Aadhaar OTP), [`supabase/functions/speak-cloned-voice/index.ts`](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/speak-cloned-voice/index.ts) (Cloned voice), [`src/lib/useSpeech.ts`](https://github.com/kartikchilling-afk/sih/blob/main/src/lib/useSpeech.ts) (Speech controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Patient portal"]
  node_app["Portal UI<br/>[App.tsx]"]
  node_entry["React entry<br/>[main.tsx]"]
  node_veda["Veda assistant<br/>[VedaAssistant.tsx]"]
  node_speech["Speech controls<br/>[useSpeech.ts]"]
  node_translations["Translations<br/>[i18n.ts]"]
end

subgraph group_identity["Identity and security"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_aadhaar["Aadhaar OTP<br/>[index.ts]"]
end

subgraph group_records["Clinical records"]
  node_supabase[("Supabase platform")]
  node_schema["Patient data schema"]
  node_documents_schema["Document processing schema"]
  node_ocr["Document processing<br/>[index.ts]"]
end

subgraph group_services["Edge services"]
  node_clinical_draft["Clinical draft review<br/>[index.ts]"]
  node_voice["Cloned voice<br/>[index.ts]"]
end

node_patient(("Patient"))
node_provider["Authorized OTP provider"]
node_ocr_provider["OCR provider"]
node_openai["OpenAI"]
node_elevenlabs["ElevenLabs"]

node_patient -->|"opens portal"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"reads documents"| node_supabase_client
node_supabase_client -->|"queries"| node_supabase
node_schema -->|"defines records"| node_supabase
node_documents_schema -->|"defines queue"| node_supabase
node_app -->|"requests OTP"| node_aadhaar
node_aadhaar -->|"requests or verifies"| node_provider
node_aadhaar -->|"links identity and session"| node_supabase
node_ocr -->|"reads files and updates results"| node_supabase
node_ocr -.->|"submits document"| node_ocr_provider
node_clinical_draft -->|"loads and saves review"| node_supabase
node_clinical_draft -.->|"generates draft"| node_openai
node_speech -.->|"requests cloned speech"| node_supabase
node_speech -.->|"sends text"| node_voice
node_voice -->|"validates session"| node_supabase
node_voice -.->|"generates audio"| node_elevenlabs
node_app -.->|"relationship not evidenced"| node_veda

click node_app "https://github.com/kartikchilling-afk/sih/blob/main/src/App.tsx"
click node_entry "https://github.com/kartikchilling-afk/sih/blob/main/src/main.tsx"
click node_veda "https://github.com/kartikchilling-afk/sih/blob/main/src/components/VedaAssistant.tsx"
click node_speech "https://github.com/kartikchilling-afk/sih/blob/main/src/lib/useSpeech.ts"
click node_translations "https://github.com/kartikchilling-afk/sih/blob/main/src/lib/i18n.ts"
click node_supabase_client "https://github.com/kartikchilling-afk/sih/blob/main/src/lib/supabase.ts"
click node_aadhaar "https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/aadhaar-auth/index.ts"
click node_schema "https://github.com/kartikchilling-afk/sih/blob/main/supabase/migrations/20260901003102_create_medikiosk_schema.sql"
click node_documents_schema "https://github.com/kartikchilling-afk/sih/blob/main/supabase/migrations/20260908002000_add_document_processing_queue.sql"
click node_ocr "https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/process-document/index.ts"
click node_clinical_draft "https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/generate-clinical-draft/index.ts"
click node_voice "https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/speak-cloned-voice/index.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_entry,node_veda,node_speech,node_translations toneBlue
class node_supabase_client,node_aadhaar toneAmber
class node_supabase,node_schema,node_documents_schema,node_ocr toneMint
class node_clinical_draft,node_voice toneRose
class node_patient,node_provider,node_ocr_provider,node_openai,node_elevenlabs toneIndigo
```

## Components

### Patient portal

- [Portal UI](https://github.com/kartikchilling-afk/sih/blob/main/src/App.tsx): `src/App.tsx`
- [React entry](https://github.com/kartikchilling-afk/sih/blob/main/src/main.tsx): `src/main.tsx`
- [Veda assistant](https://github.com/kartikchilling-afk/sih/blob/main/src/components/VedaAssistant.tsx): `src/components/VedaAssistant.tsx`
- [Speech controls](https://github.com/kartikchilling-afk/sih/blob/main/src/lib/useSpeech.ts): `src/lib/useSpeech.ts`
- [Translations](https://github.com/kartikchilling-afk/sih/blob/main/src/lib/i18n.ts): `src/lib/i18n.ts`

### Identity and security

- [Supabase client](https://github.com/kartikchilling-afk/sih/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- [Aadhaar OTP](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/aadhaar-auth/index.ts): `supabase/functions/aadhaar-auth/index.ts`

### Clinical records

- **Supabase platform**
- [Patient data schema](https://github.com/kartikchilling-afk/sih/blob/main/supabase/migrations/20260901003102_create_medikiosk_schema.sql): `supabase/migrations/20260901003102_create_medikiosk_schema.sql`
- [Document processing schema](https://github.com/kartikchilling-afk/sih/blob/main/supabase/migrations/20260908002000_add_document_processing_queue.sql): `supabase/migrations/20260908002000_add_document_processing_queue.sql`
- [Document processing](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/process-document/index.ts): `supabase/functions/process-document/index.ts`

### Edge services

- [Clinical draft review](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/generate-clinical-draft/index.ts): `supabase/functions/generate-clinical-draft/index.ts`
- [Cloned voice](https://github.com/kartikchilling-afk/sih/blob/main/supabase/functions/speak-cloned-voice/index.ts): `supabase/functions/speak-cloned-voice/index.ts`

### Other components

- **Patient**
- **Authorized OTP provider**
- **OCR provider**
- **OpenAI**
- **ElevenLabs**

## Connections

- Patient → React entry: opens portal
- React entry → Portal UI: renders
- Portal UI → Supabase client: reads documents
- Supabase client → Supabase platform: queries
- Patient data schema → Supabase platform: defines records
- Document processing schema → Supabase platform: defines queue
- Portal UI → Aadhaar OTP: requests OTP
- Aadhaar OTP → Authorized OTP provider: requests or verifies
- Aadhaar OTP → Supabase platform: links identity and session
- Document processing → Supabase platform: reads files and updates results
- Document processing → OCR provider: submits document
- Clinical draft review → Supabase platform: loads and saves review
- Clinical draft review → OpenAI: generates draft
- Speech controls → Supabase platform: requests cloned speech
- Speech controls → Cloned voice: sends text
- Cloned voice → Supabase platform: validates session
- Cloned voice → ElevenLabs: generates audio
- Portal UI → Veda assistant: relationship not evidenced
