# philip-afk249/clinic_management_fe architecture

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

- Interactive diagram: https://gitdiagram.com/philip-afk249/clinic_management_fe
- Repository: https://github.com/philip-afk249/clinic_management_fe

## Overview

This is a multi-role clinic workflow frontend, built with React and TypeScript. Users enter through patient booking, kiosk check-in, or staff portals; the application also covers reception queues, doctor encounters, pharmacy dispensing, and administration. Routing is visible in `src/App.tsx`; sampled hooks and service clients show selected auth, intake, and clinical integrations. Most page internals were not sampled, and the README describes only a Vite template, so links between unsampled domain stages are omitted rather than inferred.

Main entry points: [`src/App.tsx`](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/App.tsx) (Role-based routes), [`src/services/intakeApi.ts`](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/intakeApi.ts) (Intake and queue API), [`src/pages/doctor/hooks/useAmbientConsultation.ts`](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/hooks/useAmbientConsultation.ts) (Ambient consultation), [`src/services/clinicalApi.ts`](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/clinicalApi.ts) (Clinical consultation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application routing"]
  node_app["Role-based routes<br/>[App.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_authprovider["Session provider<br/>[AuthProvider.tsx]"]
  node_authhook["Auth context hook<br/>[useAuth.ts]"]
  node_login["Login and registration<br/>[LoginPage.tsx]"]
end

subgraph group_patient["Patient services"]
  node_booking["Patient booking<br/>[BookingPage.tsx]"]
  node_patientdash["Patient dashboard"]
  node_activebooking["Active booking state<br/>[activeBooking.ts]"]
  node_patientticket["Patient ticket state"]
  node_kiosk["Kiosk check-in<br/>[KioskPage.tsx]"]
  node_kiosksession["Kiosk session<br/>[useKioskSession.ts]"]
end

subgraph group_care["Clinical care"]
  node_doctor["Doctor EHR<br/>[DoctorEHRPage.tsx]"]
  node_ambient["Ambient consultation"]
  node_ambientmapper["Ambient encounter mapping<br/>[ambientMapper.ts]"]
  node_rxmapper["Prescription mapping<br/>[rxMapper.ts]"]
  node_drugcatalog["Drug catalog hook<br/>[useDrugCatalog.ts]"]
end

subgraph group_operations["Clinic operations"]
  node_reception["Reception desk"]
  node_intakeform["Reception intake form<br/>[useIntakeForm.ts]"]
  node_nursequeue["Nurse history queue"]
  node_pharmacy["Pharmacy queue"]
  node_admin["Administration dashboard"]
  node_knowledge["Knowledge base management"]
end

subgraph group_services["Backend services"]
  node_authapi["Authentication API<br/>[authApi.ts]"]
  node_token[("Session token storage<br/>[authToken.ts]")]
  node_intakeapi["Intake and queue API<br/>[intakeApi.ts]"]
  node_voice["Voice triage API<br/>[voiceTriageApi.ts]"]
  node_clinicalapi["Clinical consultation API<br/>[clinicalApi.ts]"]
  node_aiadminapi["AI gateway admin API"]
  node_ocr["OCR service<br/>[ocrApi.ts]"]
end

node_visitor(("Patient or staff"))

node_visitor -->|"opens portal"| node_app
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_booking
node_app -->|"routes to"| node_patientdash
node_app -->|"routes to"| node_kiosk
node_app -->|"routes to"| node_doctor
node_app -->|"routes to"| node_reception
node_app -->|"routes to"| node_pharmacy
node_app -->|"routes to"| node_admin
node_app -->|"guards routes"| node_authhook
node_authprovider -->|"authenticates"| node_authapi
node_authprovider -->|"persists session"| node_token
node_authhook -->|"reads context"| node_authprovider
node_login -->|"uses session"| node_authhook
node_kiosksession -->|"issues check-in"| node_intakeapi
node_activebooking -->|"loads booking"| node_intakeapi
node_patientticket -->|"manages ticket"| node_intakeapi
node_intakeform -->|"submits intake"| node_intakeapi
node_intakeform -->|"requests OCR"| node_ocr
node_nursequeue -->|"loads queue"| node_intakeapi
node_ambient -->|"sends consultation"| node_clinicalapi
node_ambient -->|"uses formulary"| node_drugcatalog
node_ambient -->|"maps encounter"| node_ambientmapper
node_ambient -->|"maps prescription"| node_rxmapper
node_drugcatalog -->|"loads drugs"| node_clinicalapi
node_pharmacy -->|"loads prescriptions"| node_clinicalapi
node_pharmacy -->|"uses formulary"| node_drugcatalog
node_knowledge -->|"manages knowledge"| node_aiadminapi
node_authapi -->|"attaches bearer token"| node_token
node_intakeapi -->|"attaches bearer token"| node_token
node_clinicalapi -->|"attaches bearer token"| node_token

click node_app "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/App.tsx"
click node_authprovider "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/context/AuthProvider.tsx"
click node_authhook "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/context/useAuth.ts"
click node_authapi "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/authApi.ts"
click node_token "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/authToken.ts"
click node_login "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/auth/LoginPage.tsx"
click node_booking "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/BookingPage.tsx"
click node_patientdash "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/PatientDashboardPage.tsx"
click node_activebooking "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/data/activeBooking.ts"
click node_patientticket "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/hooks/usePatientTicket.ts"
click node_kiosk "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/kiosk/KioskPage.tsx"
click node_kiosksession "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/kiosk/hooks/useKioskSession.ts"
click node_intakeapi "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/intakeApi.ts"
click node_voice "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/voiceTriageApi.ts"
click node_reception "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/reception/ReceptionDeskPage.tsx"
click node_intakeform "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/reception/hooks/useIntakeForm.ts"
click node_nursequeue "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/nurse/hooks/useNurseHistoryQueue.ts"
click node_doctor "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/DoctorEHRPage.tsx"
click node_ambient "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/hooks/useAmbientConsultation.ts"
click node_ambientmapper "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/data/ambientMapper.ts"
click node_rxmapper "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/data/rxMapper.ts"
click node_drugcatalog "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/hooks/useDrugCatalog.ts"
click node_pharmacy "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/pharmacy/hooks/usePharmacyQueue.ts"
click node_clinicalapi "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/clinicalApi.ts"
click node_admin "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/admin/AdminDashboardPage.tsx"
click node_knowledge "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/admin/hooks/useKnowledgeBase.ts"
click node_aiadminapi "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/aiGatewayAdminApi.ts"
click node_ocr "https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/ocrApi.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 toneBlue
class node_authprovider,node_authhook,node_login toneAmber
class node_booking,node_patientdash,node_activebooking,node_patientticket,node_kiosk,node_kiosksession toneMint
class node_doctor,node_ambient,node_ambientmapper,node_rxmapper,node_drugcatalog toneRose
class node_reception,node_intakeform,node_nursequeue,node_pharmacy,node_admin,node_knowledge,node_visitor toneIndigo
class node_authapi,node_token,node_intakeapi,node_voice,node_clinicalapi,node_aiadminapi,node_ocr toneTeal
```

## Components

### Application routing

- [Role-based routes](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/App.tsx): `src/App.tsx`

### Identity and access

- [Session provider](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/context/AuthProvider.tsx): `src/context/AuthProvider.tsx`
- [Auth context hook](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/context/useAuth.ts): `src/context/useAuth.ts`
- [Login and registration](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/auth/LoginPage.tsx): `src/pages/auth/LoginPage.tsx`

### Patient services

- [Patient booking](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/BookingPage.tsx): `src/pages/patient/BookingPage.tsx`
- [Patient dashboard](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/PatientDashboardPage.tsx): `src/pages/patient/PatientDashboardPage.tsx`
- [Active booking state](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/data/activeBooking.ts): `src/pages/patient/data/activeBooking.ts`
- [Patient ticket state](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/patient/hooks/usePatientTicket.ts): `src/pages/patient/hooks/usePatientTicket.ts`
- [Kiosk check-in](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/kiosk/KioskPage.tsx): `src/pages/kiosk/KioskPage.tsx`
- [Kiosk session](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/kiosk/hooks/useKioskSession.ts): `src/pages/kiosk/hooks/useKioskSession.ts`

### Clinical care

- [Doctor EHR](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/DoctorEHRPage.tsx): `src/pages/doctor/DoctorEHRPage.tsx`
- [Ambient consultation](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/hooks/useAmbientConsultation.ts): `src/pages/doctor/hooks/useAmbientConsultation.ts`
- [Ambient encounter mapping](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/data/ambientMapper.ts): `src/pages/doctor/data/ambientMapper.ts`
- [Prescription mapping](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/doctor/data/rxMapper.ts): `src/pages/doctor/data/rxMapper.ts`
- [Drug catalog hook](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/hooks/useDrugCatalog.ts): `src/hooks/useDrugCatalog.ts`

### Clinic operations

- [Reception desk](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/reception/ReceptionDeskPage.tsx): `src/pages/reception/ReceptionDeskPage.tsx`
- [Reception intake form](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/reception/hooks/useIntakeForm.ts): `src/pages/reception/hooks/useIntakeForm.ts`
- [Nurse history queue](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/nurse/hooks/useNurseHistoryQueue.ts): `src/pages/nurse/hooks/useNurseHistoryQueue.ts`
- [Pharmacy queue](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/pharmacy/hooks/usePharmacyQueue.ts): `src/pages/pharmacy/hooks/usePharmacyQueue.ts`
- [Administration dashboard](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/admin/AdminDashboardPage.tsx): `src/pages/admin/AdminDashboardPage.tsx`
- [Knowledge base management](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/pages/admin/hooks/useKnowledgeBase.ts): `src/pages/admin/hooks/useKnowledgeBase.ts`

### Backend services

- [Authentication API](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/authApi.ts): `src/services/authApi.ts`
- [Session token storage](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/authToken.ts): `src/services/authToken.ts`
- [Intake and queue API](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/intakeApi.ts): `src/services/intakeApi.ts`
- [Voice triage API](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/voiceTriageApi.ts): `src/services/voiceTriageApi.ts`
- [Clinical consultation API](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/clinicalApi.ts): `src/services/clinicalApi.ts`
- [AI gateway admin API](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/aiGatewayAdminApi.ts): `src/services/aiGatewayAdminApi.ts`
- [OCR service](https://github.com/philip-afk249/clinic_management_fe/blob/main/src/services/ocrApi.ts): `src/services/ocrApi.ts`

### Other components

- **Patient or staff**

## Connections

- Patient or staff → Role-based routes: opens portal (evidence: `src/App.tsx`)
- Role-based routes → Login and registration: routes to (evidence: `src/App.tsx`)
- Role-based routes → Patient booking: routes to (evidence: `src/App.tsx`)
- Role-based routes → Patient dashboard: routes to (evidence: `src/App.tsx`)
- Role-based routes → Kiosk check-in: routes to (evidence: `src/App.tsx`)
- Role-based routes → Doctor EHR: routes to (evidence: `src/App.tsx`)
- Role-based routes → Reception desk: routes to (evidence: `src/App.tsx`)
- Role-based routes → Pharmacy queue: routes to (evidence: `src/App.tsx`)
- Role-based routes → Administration dashboard: routes to (evidence: `src/App.tsx`)
- Role-based routes → Auth context hook: guards routes (evidence: `src/App.tsx`)
- Session provider → Authentication API: authenticates (evidence: `src/context/AuthProvider.tsx`)
- Session provider → Session token storage: persists session (evidence: `src/context/AuthProvider.tsx`)
- Auth context hook → Session provider: reads context (evidence: `src/context/useAuth.ts`)
- Login and registration → Auth context hook: uses session (evidence: `src/pages/auth/LoginPage.tsx`)
- Kiosk session → Intake and queue API: issues check-in (evidence: `src/pages/kiosk/hooks/useKioskSession.ts`)
- Active booking state → Intake and queue API: loads booking (evidence: `src/pages/patient/data/activeBooking.ts`)
- Patient ticket state → Intake and queue API: manages ticket (evidence: `src/pages/patient/hooks/usePatientTicket.ts`)
- Reception intake form → Intake and queue API: submits intake (evidence: `src/pages/reception/hooks/useIntakeForm.ts`)
- Reception intake form → OCR service: requests OCR (evidence: `src/pages/reception/hooks/useIntakeForm.ts`)
- Nurse history queue → Intake and queue API: loads queue (evidence: `src/pages/nurse/hooks/useNurseHistoryQueue.ts`)
- Ambient consultation → Clinical consultation API: sends consultation (evidence: `src/pages/doctor/hooks/useAmbientConsultation.ts`)
- Ambient consultation → Drug catalog hook: uses formulary (evidence: `src/pages/doctor/hooks/useAmbientConsultation.ts`)
- Ambient consultation → Ambient encounter mapping: maps encounter (evidence: `src/pages/doctor/hooks/useAmbientConsultation.ts`)
- Ambient consultation → Prescription mapping: maps prescription (evidence: `src/pages/doctor/hooks/useAmbientConsultation.ts`)
- Drug catalog hook → Clinical consultation API: loads drugs (evidence: `src/hooks/useDrugCatalog.ts`)
- Pharmacy queue → Clinical consultation API: loads prescriptions (evidence: `src/pages/pharmacy/hooks/usePharmacyQueue.ts`)
- Pharmacy queue → Drug catalog hook: uses formulary (evidence: `src/pages/pharmacy/hooks/usePharmacyQueue.ts`)
- Knowledge base management → AI gateway admin API: manages knowledge (evidence: `src/pages/admin/hooks/useKnowledgeBase.ts`)
- Authentication API → Session token storage: attaches bearer token (evidence: `src/services/authApi.ts`)
- Intake and queue API → Session token storage: attaches bearer token (evidence: `src/services/intakeApi.ts`)
- Clinical consultation API → Session token storage: attaches bearer token (evidence: `src/services/clinicalApi.ts`)
