# nuby911/qr-dokter architecture

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

- Interactive diagram: https://gitdiagram.com/nuby911/qr-dokter
- Repository: https://github.com/nuby911/qr-dokter

## Overview

MediQR is a three-app, offline-first digital prescription system. The main workflow is: a doctor completes onboarding, creates and signs a prescription, then issues it as a compressed QR receipt; a patient can open and verify that prescription and show its QR to a pharmacy; the pharmacy scans and verifies it, matches prescribed items to local stock, and records dispensing. README documents these cross-app handoffs and capabilities. Source excerpts support the main component calls; unsampled internals are represented only where documented, so some relationships are omitted.

Main entry points: [`apps/apotek/src/app/page.tsx`](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/app/page.tsx) (Pharmacy workspace), [`apps/dokter/src/app/page.tsx`](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/app/page.tsx) (Prescription workspace), [`apps/pasien-web/src/components/patient/PatientViewer.tsx`](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/PatientViewer.tsx) (Prescription viewer), [`apps/apotek/src/lib/inventory-store.ts`](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/inventory-store.ts) (Inventory and dispense store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_doctor["Doctor desktop"]
  node_doctor_app["Prescription workspace<br/>[page.tsx]"]
  node_doctor_onboard["Doctor onboarding"]
  node_prescription_form["Prescription form"]
  node_doctor_crypto["Signing keys<br/>[crypto.ts]"]
  node_doctor_store[("Doctor profile store<br/>[doctor-store.ts]")]
  node_receipt["Thermal QR receipt"]
  node_doctor_codec["Prescription QR codec<br/>[qr-codec.ts]"]
end

subgraph group_patient["Patient portal"]
  node_patient_route["Prescription view route<br/>[page.tsx]"]
  node_patient_viewer["Prescription viewer<br/>[PatientViewer.tsx]"]
  node_patient_codec["Prescription QR codec<br/>[qr-codec.ts]"]
  node_patient_crypto["Signature verification<br/>[crypto.ts]"]
  node_prescription_card["Prescription card"]
  node_qr_modal["Patient QR modal<br/>[QrModal.tsx]"]
  node_service_worker["Offline service worker<br/>[sw.js]"]
end

subgraph group_pharmacy["Pharmacy desktop"]
  node_pharmacy_app["Pharmacy workspace<br/>[page.tsx]"]
  node_pharmacy_onboard["Pharmacy onboarding"]
  node_scanner["QR scanner input<br/>[QrScannerInput.tsx]"]
  node_pharmacy_codec["Prescription QR codec<br/>[qr-codec.ts]"]
  node_pharmacy_crypto["Signature verification<br/>[crypto.ts]"]
  node_dispense["Dispense workspace"]
  node_inventory_manager["Inventory manager"]
  node_inventory_store[("Inventory and dispense store<br/>[inventory-store.ts]")]
end

node_doctor(("Doctor"))
node_patient(("Patient"))
node_pharmacist(("Pharmacist"))

node_doctor -->|"uses"| node_doctor_app
node_doctor_app -->|"opens"| node_doctor_onboard
node_doctor_app -->|"renders"| node_prescription_form
node_doctor_app -->|"renders"| node_receipt
node_doctor_app -->|"loads profile"| node_doctor_store
node_doctor_onboard -->|"saves profile"| node_doctor_store
node_prescription_form -->|"signs prescription"| node_doctor_crypto
node_prescription_form -->|"saves profile"| node_doctor_store
node_receipt -->|"encodes QR"| node_doctor_codec
node_receipt -->|"issues QR"| node_patient
node_patient -->|"opens prescription"| node_patient_route
node_patient_route -->|"renders"| node_patient_viewer
node_patient_viewer -->|"decodes input"| node_patient_codec
node_patient_viewer -->|"verifies signature"| node_patient_crypto
node_patient_viewer -->|"renders"| node_prescription_card
node_prescription_card -->|"opens"| node_qr_modal
node_prescription_card -->|"shows QR"| node_pharmacist
node_patient_viewer -->|"offline support"| node_service_worker
node_pharmacist -->|"uses"| node_pharmacy_app
node_pharmacy_app -->|"opens"| node_pharmacy_onboard
node_pharmacy_app -->|"renders"| node_scanner
node_pharmacy_app -->|"decodes input"| node_pharmacy_codec
node_pharmacy_app -->|"verifies prescription"| node_pharmacy_crypto
node_pharmacy_app -->|"renders"| node_dispense
node_pharmacy_app -->|"renders"| node_inventory_manager
node_pharmacy_app -->|"resets data"| node_inventory_store
node_pharmacy_onboard -->|"stores profile"| node_inventory_store
node_dispense -->|"updates stock"| node_inventory_store
node_inventory_manager -->|"updates inventory"| node_inventory_store

click node_doctor_app "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/app/page.tsx"
click node_doctor_onboard "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/DoctorOnboardingModal.tsx"
click node_prescription_form "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/PrescriptionForm.tsx"
click node_doctor_crypto "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/crypto.ts"
click node_doctor_store "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/doctor-store.ts"
click node_receipt "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/ThermalReceiptPreview.tsx"
click node_doctor_codec "https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/qr-codec.ts"
click node_patient_route "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/app/view/page.tsx"
click node_patient_viewer "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/PatientViewer.tsx"
click node_patient_codec "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/lib/qr-codec.ts"
click node_patient_crypto "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/lib/crypto.ts"
click node_prescription_card "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/PrescriptionCard.tsx"
click node_qr_modal "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/QrModal.tsx"
click node_service_worker "https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/public/sw.js"
click node_pharmacy_app "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/app/page.tsx"
click node_pharmacy_onboard "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/PharmacyOnboardingModal.tsx"
click node_scanner "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/QrScannerInput.tsx"
click node_pharmacy_codec "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/qr-codec.ts"
click node_pharmacy_crypto "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/crypto.ts"
click node_dispense "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/DispenseWorkspace.tsx"
click node_inventory_manager "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/InventoryManager.tsx"
click node_inventory_store "https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/inventory-store.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_doctor_app,node_doctor_onboard,node_prescription_form,node_doctor_crypto,node_doctor_store,node_receipt,node_doctor_codec toneBlue
class node_patient_route,node_patient_viewer,node_patient_codec,node_patient_crypto,node_prescription_card,node_qr_modal,node_service_worker toneAmber
class node_pharmacy_app,node_pharmacy_onboard,node_scanner,node_pharmacy_codec,node_pharmacy_crypto,node_dispense,node_inventory_manager,node_inventory_store toneMint
class node_doctor,node_patient,node_pharmacist toneIndigo
```

## Components

### Doctor desktop

- [Prescription workspace](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/app/page.tsx): `apps/dokter/src/app/page.tsx`
- [Doctor onboarding](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/DoctorOnboardingModal.tsx): `apps/dokter/src/components/doctor/DoctorOnboardingModal.tsx`
- [Prescription form](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/PrescriptionForm.tsx): `apps/dokter/src/components/doctor/PrescriptionForm.tsx`
- [Signing keys](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/crypto.ts): `apps/dokter/src/lib/crypto.ts`
- [Doctor profile store](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/doctor-store.ts): `apps/dokter/src/lib/doctor-store.ts`
- [Thermal QR receipt](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/components/doctor/ThermalReceiptPreview.tsx): `apps/dokter/src/components/doctor/ThermalReceiptPreview.tsx`
- [Prescription QR codec](https://github.com/nuby911/qr-dokter/blob/master/apps/dokter/src/lib/qr-codec.ts): `apps/dokter/src/lib/qr-codec.ts`

### Patient portal

- [Prescription view route](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/app/view/page.tsx): `apps/pasien-web/src/app/view/page.tsx`
- [Prescription viewer](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/PatientViewer.tsx): `apps/pasien-web/src/components/patient/PatientViewer.tsx`
- [Prescription QR codec](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/lib/qr-codec.ts): `apps/pasien-web/src/lib/qr-codec.ts`
- [Signature verification](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/lib/crypto.ts): `apps/pasien-web/src/lib/crypto.ts`
- [Prescription card](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/PrescriptionCard.tsx): `apps/pasien-web/src/components/patient/PrescriptionCard.tsx`
- [Patient QR modal](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/src/components/patient/QrModal.tsx): `apps/pasien-web/src/components/patient/QrModal.tsx`
- [Offline service worker](https://github.com/nuby911/qr-dokter/blob/master/apps/pasien-web/public/sw.js): `apps/pasien-web/public/sw.js`

### Pharmacy desktop

- [Pharmacy workspace](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/app/page.tsx): `apps/apotek/src/app/page.tsx`
- [Pharmacy onboarding](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/PharmacyOnboardingModal.tsx): `apps/apotek/src/components/pharmacy/PharmacyOnboardingModal.tsx`
- [QR scanner input](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/QrScannerInput.tsx): `apps/apotek/src/components/pharmacy/QrScannerInput.tsx`
- [Prescription QR codec](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/qr-codec.ts): `apps/apotek/src/lib/qr-codec.ts`
- [Signature verification](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/crypto.ts): `apps/apotek/src/lib/crypto.ts`
- [Dispense workspace](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/DispenseWorkspace.tsx): `apps/apotek/src/components/pharmacy/DispenseWorkspace.tsx`
- [Inventory manager](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/components/pharmacy/InventoryManager.tsx): `apps/apotek/src/components/pharmacy/InventoryManager.tsx`
- [Inventory and dispense store](https://github.com/nuby911/qr-dokter/blob/master/apps/apotek/src/lib/inventory-store.ts): `apps/apotek/src/lib/inventory-store.ts`

### Other components

- **Doctor**
- **Patient**
- **Pharmacist**

## Connections

- Doctor → Prescription workspace: uses (evidence: `README.md`)
- Prescription workspace → Doctor onboarding: opens (evidence: `apps/dokter/src/app/page.tsx`)
- Prescription workspace → Prescription form: renders (evidence: `apps/dokter/src/app/page.tsx`)
- Prescription workspace → Thermal QR receipt: renders (evidence: `apps/dokter/src/app/page.tsx`)
- Prescription workspace → Doctor profile store: loads profile (evidence: `apps/dokter/src/app/page.tsx`)
- Doctor onboarding → Doctor profile store: saves profile (evidence: `apps/dokter/src/components/doctor/DoctorOnboardingModal.tsx`)
- Prescription form → Signing keys: signs prescription (evidence: `apps/dokter/src/components/doctor/PrescriptionForm.tsx`)
- Prescription form → Doctor profile store: saves profile (evidence: `apps/dokter/src/components/doctor/PrescriptionForm.tsx`)
- Thermal QR receipt → Prescription QR codec: encodes QR (evidence: `apps/dokter/src/components/doctor/ThermalReceiptPreview.tsx`)
- Thermal QR receipt → Patient: issues QR (evidence: `README.md`)
- Patient → Prescription view route: opens prescription (evidence: `README.md`)
- Prescription view route → Prescription viewer: renders (evidence: `apps/pasien-web/src/app/view/page.tsx`)
- Prescription viewer → Prescription QR codec: decodes input (evidence: `apps/pasien-web/src/components/patient/PatientViewer.tsx`)
- Prescription viewer → Signature verification: verifies signature (evidence: `apps/pasien-web/src/components/patient/PatientViewer.tsx`)
- Prescription viewer → Prescription card: renders (evidence: `apps/pasien-web/src/components/patient/PatientViewer.tsx`)
- Prescription card → Patient QR modal: opens (evidence: `apps/pasien-web/src/components/patient/PrescriptionCard.tsx`)
- Prescription card → Pharmacist: shows QR (evidence: `README.md`)
- Prescription viewer → Offline service worker: offline support (evidence: `README.md`)
- Pharmacist → Pharmacy workspace: uses (evidence: `README.md`)
- Pharmacy workspace → Pharmacy onboarding: opens (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → QR scanner input: renders (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → Prescription QR codec: decodes input (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → Signature verification: verifies prescription (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → Dispense workspace: renders (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → Inventory manager: renders (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy workspace → Inventory and dispense store: resets data (evidence: `apps/apotek/src/app/page.tsx`)
- Pharmacy onboarding → Inventory and dispense store: stores profile (evidence: `apps/apotek/src/components/pharmacy/PharmacyOnboardingModal.tsx`)
- Dispense workspace → Inventory and dispense store: updates stock (evidence: `apps/apotek/src/components/pharmacy/DispenseWorkspace.tsx`)
- Inventory manager → Inventory and dispense store: updates inventory (evidence: `apps/apotek/src/components/pharmacy/InventoryManager.tsx`)
