# syedmurtaza15/subhan-care-hms-supabase architecture

> Architecture diagram of the GitHub repository syedmurtaza15/subhan-care-hms-supabase, 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/syedmurtaza15/subhan-care-hms-supabase
- Repository: https://github.com/syedmurtaza15/subhan-care-hms-supabase

## Overview

Subhan Care is a role-aware hospital management frontend backed by Supabase, with local demo-data fallback. Users enter through public authentication or protected dashboard routes; role-aware pages support patient and appointment workflows alongside prescriptions, inventory, billing, staff administration, and reporting. Shared contexts and services manage identity and domain data, with persistence delegated to Supabase or browser storage. The route map and data/auth service excerpts support the main wiring shown; unsampled page implementations and database policies limit finer-grained call-flow detail.

Main entry points: [`src/layouts/DashboardLayout.jsx`](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/layouts/DashboardLayout.jsx) (Dashboard shell), [`src/routes/AppRoutes.jsx`](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/routes/AppRoutes.jsx) (Route dispatcher), [`src/services/authService.js`](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/authService.js) (Auth service), [`src/services/dataService.js`](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/dataService.js) (Data service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_routes["Route dispatcher<br/>[AppRoutes.jsx]"]
  node_auth_pages["Authentication pages"]
  node_auth_context["Authentication state<br/>[AuthContext.jsx]"]
  node_auth_service["Auth service<br/>[authService.js]"]
  node_dashboard_layout["Dashboard shell"]
end

subgraph group_care["Clinical operations"]
  node_patients["Patient records and history"]
  node_appointments["Appointment scheduling"]
  node_doctors["Doctor directory"]
  node_prescriptions["Prescriptions"]
  node_my_appointments["Patient appointments"]
end

subgraph group_administration["Hospital administration"]
  node_inventory["Medication inventory"]
  node_billing["Billing and invoices"]
  node_staff["Staff management<br/>[StaffPage.jsx]"]
  node_reports["Reports and analytics<br/>[ReportsPage.jsx]"]
  node_dashboard["Dashboard analytics<br/>[DashboardPage.jsx]"]
end

subgraph group_runtime["Shared runtime and data"]
  node_app["Application shell<br/>[App.jsx]"]
  node_data_context["Domain data context<br/>[DataContext.jsx]"]
  node_data_service["Data service<br/>[dataService.js]"]
  node_supabase[("Supabase backend")]
  node_local_storage[("Browser local storage")]
end

node_user(("Hospital user"))

node_user -->|"opens pages"| node_routes
node_app -->|"renders routes"| node_routes
node_routes -->|"dispatches public routes"| node_auth_pages
node_auth_pages -->|"uses auth state"| node_auth_context
node_auth_context -->|"calls auth operations"| node_auth_service
node_auth_service -->|"authenticates and reads profiles"| node_supabase
node_auth_service -.->|"stores fallback data"| node_local_storage
node_routes -->|"guards dashboard"| node_dashboard_layout
node_dashboard_layout -->|"hosts patient routes"| node_patients
node_dashboard_layout -->|"hosts appointment routes"| node_appointments
node_dashboard_layout -->|"hosts doctor routes"| node_doctors
node_dashboard_layout -->|"hosts prescription routes"| node_prescriptions
node_dashboard_layout -->|"hosts patient route"| node_my_appointments
node_dashboard_layout -->|"hosts inventory route"| node_inventory
node_dashboard_layout -->|"hosts billing routes"| node_billing
node_dashboard_layout -->|"hosts staff route"| node_staff
node_dashboard_layout -->|"hosts reports route"| node_reports
node_dashboard_layout -->|"hosts dashboard route"| node_dashboard
node_app -->|"provides domain data"| node_data_context
node_data_context -->|"loads and mutates data"| node_data_service
node_data_service -->|"reads and writes entities"| node_supabase
node_data_service -.->|"persists demo entities"| node_local_storage

click node_app "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/App.jsx"
click node_routes "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/routes/AppRoutes.jsx"
click node_auth_pages "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/auth"
click node_auth_context "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/context/AuthContext.jsx"
click node_auth_service "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/authService.js"
click node_dashboard_layout "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/layouts/DashboardLayout.jsx"
click node_patients "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/patients"
click node_appointments "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/appointments"
click node_doctors "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/doctors"
click node_prescriptions "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/prescriptions"
click node_my_appointments "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/MyAppointmentsPage.jsx"
click node_inventory "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/inventory"
click node_billing "https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/billing"
click node_staff "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/staff/StaffPage.jsx"
click node_reports "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/reports/ReportsPage.jsx"
click node_dashboard "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/DashboardPage.jsx"
click node_data_context "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/context/DataContext.jsx"
click node_data_service "https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/dataService.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_routes,node_auth_pages,node_auth_context,node_auth_service,node_dashboard_layout,node_user toneBlue
class node_patients,node_appointments,node_doctors,node_prescriptions,node_my_appointments toneAmber
class node_inventory,node_billing,node_staff,node_reports,node_dashboard toneMint
class node_app,node_data_context,node_data_service,node_supabase,node_local_storage toneRose
```

## Components

### Access and navigation

- [Route dispatcher](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/routes/AppRoutes.jsx): `src/routes/AppRoutes.jsx`
- [Authentication pages](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/auth): `src/pages/auth`
- [Authentication state](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Auth service](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/authService.js): `src/services/authService.js`
- [Dashboard shell](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/layouts/DashboardLayout.jsx): `src/layouts/DashboardLayout.jsx`

### Clinical operations

- [Patient records and history](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/patients): `src/pages/dashboard/patients`
- [Appointment scheduling](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/appointments): `src/pages/dashboard/appointments`
- [Doctor directory](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/doctors): `src/pages/dashboard/doctors`
- [Prescriptions](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/prescriptions): `src/pages/dashboard/prescriptions`
- [Patient appointments](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/MyAppointmentsPage.jsx): `src/pages/dashboard/MyAppointmentsPage.jsx`

### Hospital administration

- [Medication inventory](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/inventory): `src/pages/dashboard/inventory`
- [Billing and invoices](https://github.com/syedmurtaza15/subhan-care-hms-supabase/tree/main/src/pages/dashboard/billing): `src/pages/dashboard/billing`
- [Staff management](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/staff/StaffPage.jsx): `src/pages/dashboard/staff/StaffPage.jsx`
- [Reports and analytics](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/reports/ReportsPage.jsx): `src/pages/dashboard/reports/ReportsPage.jsx`
- [Dashboard analytics](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/pages/dashboard/DashboardPage.jsx): `src/pages/dashboard/DashboardPage.jsx`

### Shared runtime and data

- [Application shell](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/App.jsx): `src/App.jsx`
- [Domain data context](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/context/DataContext.jsx): `src/context/DataContext.jsx`
- [Data service](https://github.com/syedmurtaza15/subhan-care-hms-supabase/blob/main/src/services/dataService.js): `src/services/dataService.js`
- **Supabase backend**
- **Browser local storage**

### Other components

- **Hospital user**

## Connections

- Hospital user → Route dispatcher: opens pages
- Application shell → Route dispatcher: renders routes
- Route dispatcher → Authentication pages: dispatches public routes
- Authentication pages → Authentication state: uses auth state
- Authentication state → Auth service: calls auth operations
- Auth service → Supabase backend: authenticates and reads profiles
- Auth service → Browser local storage: stores fallback data
- Route dispatcher → Dashboard shell: guards dashboard
- Dashboard shell → Patient records and history: hosts patient routes
- Dashboard shell → Appointment scheduling: hosts appointment routes
- Dashboard shell → Doctor directory: hosts doctor routes
- Dashboard shell → Prescriptions: hosts prescription routes
- Dashboard shell → Patient appointments: hosts patient route
- Dashboard shell → Medication inventory: hosts inventory route
- Dashboard shell → Billing and invoices: hosts billing routes
- Dashboard shell → Staff management: hosts staff route
- Dashboard shell → Reports and analytics: hosts reports route
- Dashboard shell → Dashboard analytics: hosts dashboard route
- Application shell → Domain data context: provides domain data
- Domain data context → Data service: loads and mutates data
- Data service → Supabase backend: reads and writes entities
- Data service → Browser local storage: persists demo entities
