# sandeep001e/medikiosk architecture

> Architecture diagram of the GitHub repository sandeep001e/medikiosk, 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/sandeep001e/medikiosk
- Repository: https://github.com/sandeep001e/medikiosk

## Overview

MediKiosk is a two-dashboard healthcare prototype: patients register, report concerns, manage records and share cases; clinicians review shared cases and manage prescriptions. The unified backend serves both dashboards, coordinates clinical and AI-assisted operations, and persists shared state through Firestore. The README documents SSE updates and backend ownership of shared state. Frontend and several service implementations were not sampled, so their internal wiring is represented only where documented or directly evidenced.

Main entry points: [`backend/src/server.js`](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/server.js) (Unified API), [`apps/patient/src/PatientApp.jsx`](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/PatientApp.jsx) (Patient dashboard), [`apps/doctor/src/DoctorApp.jsx`](https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/DoctorApp.jsx) (Doctor dashboard), [`backend/src/services/sarvamStt.js`](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/sarvamStt.js) (Speech transcription)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient care"]
  node_patient_app["Patient dashboard<br/>[PatientApp.jsx]"]
  node_patient_auth["Registration and ABHA<br/>[Register.jsx]"]
  node_patient_problem["Problem reporting<br/>[Dashboard.jsx]"]
  node_patient_records["Reports and prescriptions<br/>[Reports.jsx]"]
  node_patient_share["Case sharing"]
end

subgraph group_doctor["Doctor workflow"]
  node_doctor_app["Doctor dashboard<br/>[DoctorApp.jsx]"]
  node_doctor_cases["Case review"]
  node_doctor_rx["Prescription entry"]
end

subgraph group_backend["Backend services"]
  node_api["Unified API<br/>[server.js]"]
  node_abha["ABHA verification"]
  node_speech["Speech transcription<br/>[sarvamStt.js]"]
  node_ocr["Document OCR<br/>[geminiFlashOcr.js]"]
  node_summary["Problem summary<br/>[aiSummary.js]"]
  node_questions["Dynamic questions"]
  node_sync["Live updates<br/>[useLiveSync.js]"]
end

subgraph group_records["Shared records"]
  node_store["Shared state service<br/>[sharedStore.js]"]
  node_firestore_service["Firestore adapter"]
end

node_patient_actor(("Patient"))
node_doctor_actor(("Doctor"))
node_firestore[("Firestore")]
node_ai_provider{{"AI providers"}}
node_sarvam{{"Sarvam"}}

node_patient_actor -->|"uses"| node_patient_app
node_patient_app -->|"API requests"| node_api
node_patient_app -->|"opens SSE"| node_sync
node_patient_app -->|"registers"| node_patient_auth
node_patient_app -->|"reports concern"| node_patient_problem
node_patient_app -->|"manages records"| node_patient_records
node_patient_app -->|"shares case"| node_patient_share
node_doctor_actor -->|"uses"| node_doctor_app
node_doctor_app -->|"API requests"| node_api
node_doctor_app -->|"reviews cases"| node_doctor_cases
node_doctor_app -->|"writes prescription"| node_doctor_rx
node_api -->|"verifies identity"| node_abha
node_api -->|"transcribes audio"| node_speech
node_api -->|"digitizes image"| node_ocr
node_api -->|"generates summary"| node_summary
node_api -->|"generates questions"| node_questions
node_speech -.->|"calls"| node_sarvam
node_ocr -.->|"calls"| node_ai_provider
node_summary -.->|"calls"| node_ai_provider
node_questions -.->|"calls"| node_ai_provider
node_api -->|"reads and writes"| node_store
node_store -->|"persists records"| node_firestore_service
node_firestore_service -->|"reads and writes"| node_firestore
node_sync -->|"receives SSE"| node_api

click node_patient_app "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/PatientApp.jsx"
click node_patient_auth "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Register.jsx"
click node_patient_problem "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Dashboard.jsx"
click node_patient_records "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Reports.jsx"
click node_patient_share "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/components/PatientShareQrModal.jsx"
click node_doctor_app "https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/DoctorApp.jsx"
click node_doctor_cases "https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/DoctorDashboard.jsx"
click node_doctor_rx "https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/components/IssuePrescriptionModal.jsx"
click node_api "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/server.js"
click node_abha "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/abhaVerification.js"
click node_speech "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/sarvamStt.js"
click node_ocr "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/geminiFlashOcr.js"
click node_summary "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/aiSummary.js"
click node_questions "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/dynamicQuestions.js"
click node_sync "https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/shared/useLiveSync.js"
click node_store "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/shared/sharedStore.js"
click node_firestore_service "https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/firestoreService.js"

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_patient_app,node_patient_auth,node_patient_problem,node_patient_records,node_patient_share toneBlue
class node_doctor_app,node_doctor_cases,node_doctor_rx,node_firestore toneAmber
class node_api,node_abha,node_speech,node_ocr,node_summary,node_questions,node_sync toneMint
class node_store,node_firestore_service toneRose
class node_patient_actor,node_doctor_actor,node_ai_provider,node_sarvam toneIndigo
```

## Components

### Patient care

- [Patient dashboard](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/PatientApp.jsx): `apps/patient/src/PatientApp.jsx`
- [Registration and ABHA](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Register.jsx): `apps/patient/src/pages/patient/Register.jsx`
- [Problem reporting](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Dashboard.jsx): `apps/patient/src/pages/patient/Dashboard.jsx`
- [Reports and prescriptions](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/pages/patient/Reports.jsx): `apps/patient/src/pages/patient/Reports.jsx`
- [Case sharing](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/components/PatientShareQrModal.jsx): `apps/patient/src/components/PatientShareQrModal.jsx`

### Doctor workflow

- [Doctor dashboard](https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/DoctorApp.jsx): `apps/doctor/src/DoctorApp.jsx`
- [Case review](https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/DoctorDashboard.jsx): `apps/doctor/src/DoctorDashboard.jsx`
- [Prescription entry](https://github.com/sandeep001e/medikiosk/blob/master/apps/doctor/src/components/IssuePrescriptionModal.jsx): `apps/doctor/src/components/IssuePrescriptionModal.jsx`

### Backend services

- [Unified API](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/server.js): `backend/src/server.js`
- [ABHA verification](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/abhaVerification.js): `backend/src/services/abhaVerification.js`
- [Speech transcription](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/sarvamStt.js): `backend/src/services/sarvamStt.js`
- [Document OCR](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/geminiFlashOcr.js): `backend/src/services/geminiFlashOcr.js`
- [Problem summary](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/aiSummary.js): `backend/src/services/aiSummary.js`
- [Dynamic questions](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/dynamicQuestions.js): `backend/src/services/dynamicQuestions.js`
- [Live updates](https://github.com/sandeep001e/medikiosk/blob/master/apps/patient/src/shared/useLiveSync.js): `apps/patient/src/shared/useLiveSync.js`

### Shared records

- [Shared state service](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/shared/sharedStore.js): `backend/src/shared/sharedStore.js`
- [Firestore adapter](https://github.com/sandeep001e/medikiosk/blob/master/backend/src/services/firestoreService.js): `backend/src/services/firestoreService.js`

### Other components

- **Patient**
- **Doctor**
- **Firestore**
- **AI providers**
- **Sarvam**

## Connections

- Patient → Patient dashboard: uses
- Patient dashboard → Unified API: API requests
- Patient dashboard → Live updates: opens SSE
- Patient dashboard → Registration and ABHA: registers
- Patient dashboard → Problem reporting: reports concern
- Patient dashboard → Reports and prescriptions: manages records
- Patient dashboard → Case sharing: shares case
- Doctor → Doctor dashboard: uses
- Doctor dashboard → Unified API: API requests
- Doctor dashboard → Case review: reviews cases
- Doctor dashboard → Prescription entry: writes prescription
- Unified API → ABHA verification: verifies identity
- Unified API → Speech transcription: transcribes audio
- Unified API → Document OCR: digitizes image
- Unified API → Problem summary: generates summary
- Unified API → Dynamic questions: generates questions
- Speech transcription → Sarvam: calls
- Document OCR → AI providers: calls
- Problem summary → AI providers: calls
- Dynamic questions → AI providers: calls
- Unified API → Shared state service: reads and writes
- Shared state service → Firestore adapter: persists records
- Firestore adapter → Firestore: reads and writes
- Live updates → Unified API: receives SSE
