# rinnshanzuki/pmed-aid architecture

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

- Interactive diagram: https://gitdiagram.com/rinnshanzuki/pmed-aid
- Repository: https://github.com/rinnshanzuki/pmed-aid

## Overview

PMED-AID is a role-based patient and medication management system with browser and mobile clients backed by an Express API and relational database. Users authenticate, enter role-specific workflows, and use the API for patient records, admissions, consultations, prescriptions, medication administration and monitoring, QR workflows, billing, analytics, and notifications. The graph includes those documented capabilities, plus the backend persistence and realtime/adherence layers. Several feature modules were not excerpted, so their internal calls are omitted; dashed client-to-API links indicate the HTTP boundary is not shown in the excerpts.

Main entry points: [`backend/src/routes/index.js`](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/routes/index.js) (API route dispatch), [`backend/src/models/index.js`](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/models/index.js) (Domain models), [`backend/src/server.js`](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/server.js) (HTTP server startup), [`backend/src/controllers/consultationController.js`](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/consultationController.js) (Clinical consultations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web_app["Browser app<br/>[App.jsx]"]
  node_web_auth["Browser authentication<br/>[AuthPage.jsx]"]
  node_web_auth_state["Browser auth state<br/>[AuthContext.jsx]"]
  node_web_api["Browser API client<br/>[api.js]"]
  node_web_workflows["Browser role workflows"]
  node_mobile_app["Mobile app<br/>[App.tsx]"]
  node_mobile_nav["Mobile role workflows"]
  node_mobile_auth["Mobile authentication<br/>[AuthContext.tsx]"]
  node_mobile_api_config["Mobile API configuration<br/>[api.config.ts]"]
  node_mobile_api["Mobile API client<br/>[api.ts]"]
end

subgraph group_api["API and workflows"]
  node_server["HTTP server startup<br/>[server.js]"]
  node_http_app["HTTP application<br/>[app.js]"]
  node_routes["API route dispatch<br/>[index.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_admissions["Admissions and discharge"]
  node_consultations["Clinical consultations"]
  node_info_desk["Info desk workflows"]
  node_prescriptions["Prescription workflows"]
  node_schedules["Medication schedules"]
  node_other_domains["Other API domains"]
end

subgraph group_persistence["Persistence"]
  node_models["Domain models<br/>[index.js]"]
  node_database[("Relational database<br/>[db.js]")]
end

subgraph group_realtime["Realtime and monitoring"]
  node_notifications["Notification helper"]
  node_socket["Socket service<br/>[socket.js]"]
  node_adherence["Adherence monitor"]
end

node_staff_patient(("Staff and patients"))

node_staff_patient -->|"uses"| node_web_app
node_web_app -->|"routes to"| node_web_auth
node_web_app -->|"routes to"| node_web_workflows
node_web_auth -->|"uses"| node_web_auth_state
node_web_auth_state -->|"calls"| node_web_api
node_web_workflows -.->|"calls"| node_web_api
node_staff_patient -->|"uses"| node_mobile_app
node_mobile_app -->|"renders"| node_mobile_nav
node_mobile_nav -.->|"uses"| node_mobile_auth
node_mobile_auth -->|"calls"| node_mobile_api
node_mobile_api -.->|"configures"| node_mobile_api_config
node_mobile_nav -.->|"calls"| node_mobile_api
node_server -->|"starts"| node_http_app
node_server -->|"initializes"| node_models
node_server -->|"starts"| node_adherence
node_server -->|"initializes"| node_socket
node_http_app -->|"mounts"| node_routes
node_routes -->|"dispatches"| node_auth
node_routes -->|"dispatches"| node_admissions
node_routes -->|"dispatches"| node_consultations
node_routes -->|"dispatches"| node_info_desk
node_routes -->|"dispatches"| node_prescriptions
node_routes -->|"dispatches"| node_schedules
node_routes -->|"dispatches"| node_other_domains
node_auth -->|"queries"| node_models
node_admissions -->|"queries"| node_models
node_consultations -->|"queries"| node_models
node_info_desk -->|"queries"| node_models
node_info_desk -->|"notifies"| node_notifications
node_admissions -->|"notifies"| node_notifications
node_consultations -->|"notifies"| node_notifications
node_consultations -->|"emits"| node_socket
node_adherence -->|"queries"| node_models
node_models -->|"uses"| node_database
node_web_api -.->|"requests"| node_http_app
node_mobile_api -.->|"requests"| node_http_app

click node_web_app "https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/App.jsx"
click node_web_auth "https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/pages/AuthPage.jsx"
click node_web_auth_state "https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/contexts/AuthContext.jsx"
click node_web_api "https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/services/api.js"
click node_web_workflows "https://github.com/rinnshanzuki/pmed-aid/tree/main/frontend/src/pages"
click node_mobile_app "https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/App.tsx"
click node_mobile_nav "https://github.com/rinnshanzuki/pmed-aid/tree/main/mobile/src/navigation"
click node_mobile_auth "https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/contexts/AuthContext.tsx"
click node_mobile_api_config "https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/config/api.config.ts"
click node_mobile_api "https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/services/api.ts"
click node_server "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/server.js"
click node_http_app "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/app.js"
click node_routes "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/routes/index.js"
click node_auth "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/authController.js"
click node_admissions "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/admissionController.js"
click node_consultations "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/consultationController.js"
click node_info_desk "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/infoDeskController.js"
click node_prescriptions "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/prescriptionController.js"
click node_schedules "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/scheduleController.js"
click node_other_domains "https://github.com/rinnshanzuki/pmed-aid/tree/main/backend/src/controllers"
click node_models "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/models/index.js"
click node_database "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/config/db.js"
click node_notifications "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/utils/notificationHelper.js"
click node_socket "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/socket.js"
click node_adherence "https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/cron/adherenceMonitor.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_web_app,node_web_auth,node_web_auth_state,node_web_api,node_web_workflows,node_mobile_app,node_mobile_nav,node_mobile_auth,node_mobile_api_config,node_mobile_api toneBlue
class node_server,node_http_app,node_routes,node_auth,node_admissions,node_consultations,node_info_desk,node_prescriptions,node_schedules,node_other_domains toneAmber
class node_models,node_database toneMint
class node_notifications,node_socket,node_adherence toneRose
class node_staff_patient toneIndigo
```

## Components

### User clients

- [Browser app](https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Browser authentication](https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/pages/AuthPage.jsx): `frontend/src/pages/AuthPage.jsx`
- [Browser auth state](https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/contexts/AuthContext.jsx): `frontend/src/contexts/AuthContext.jsx`
- [Browser API client](https://github.com/rinnshanzuki/pmed-aid/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Browser role workflows](https://github.com/rinnshanzuki/pmed-aid/tree/main/frontend/src/pages): `frontend/src/pages`
- [Mobile app](https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/App.tsx): `mobile/App.tsx`
- [Mobile role workflows](https://github.com/rinnshanzuki/pmed-aid/tree/main/mobile/src/navigation): `mobile/src/navigation`
- [Mobile authentication](https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/contexts/AuthContext.tsx): `mobile/src/contexts/AuthContext.tsx`
- [Mobile API configuration](https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/config/api.config.ts): `mobile/src/config/api.config.ts`
- [Mobile API client](https://github.com/rinnshanzuki/pmed-aid/blob/main/mobile/src/services/api.ts): `mobile/src/services/api.ts`

### API and workflows

- [HTTP server startup](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/server.js): `backend/src/server.js`
- [HTTP application](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/app.js): `backend/src/app.js`
- [API route dispatch](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/routes/index.js): `backend/src/routes/index.js`
- [Authentication](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Admissions and discharge](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/admissionController.js): `backend/src/controllers/admissionController.js`
- [Clinical consultations](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/consultationController.js): `backend/src/controllers/consultationController.js`
- [Info desk workflows](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/infoDeskController.js): `backend/src/controllers/infoDeskController.js`
- [Prescription workflows](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/prescriptionController.js): `backend/src/controllers/prescriptionController.js`
- [Medication schedules](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/controllers/scheduleController.js): `backend/src/controllers/scheduleController.js`
- [Other API domains](https://github.com/rinnshanzuki/pmed-aid/tree/main/backend/src/controllers): `backend/src/controllers`

### Persistence

- [Domain models](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/models/index.js): `backend/src/models/index.js`
- [Relational database](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### Realtime and monitoring

- [Notification helper](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/utils/notificationHelper.js): `backend/src/utils/notificationHelper.js`
- [Socket service](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/socket.js): `backend/src/socket.js`
- [Adherence monitor](https://github.com/rinnshanzuki/pmed-aid/blob/main/backend/src/cron/adherenceMonitor.js): `backend/src/cron/adherenceMonitor.js`

### Other components

- **Staff and patients**

## Connections

- Staff and patients → Browser app: uses (evidence: `frontend/src/App.jsx`)
- Browser app → Browser authentication: routes to (evidence: `frontend/src/App.jsx`)
- Browser app → Browser role workflows: routes to (evidence: `frontend/src/App.jsx`)
- Browser authentication → Browser auth state: uses (evidence: `frontend/src/pages/AuthPage.jsx`)
- Browser auth state → Browser API client: calls (evidence: `frontend/src/contexts/AuthContext.jsx`)
- Browser role workflows → Browser API client: calls (evidence: `frontend/src/pages/AuthPage.jsx`)
- Staff and patients → Mobile app: uses (evidence: `mobile/App.tsx`)
- Mobile app → Mobile role workflows: renders (evidence: `mobile/App.tsx`)
- Mobile role workflows → Mobile authentication: uses
- Mobile authentication → Mobile API client: calls (evidence: `mobile/src/contexts/AuthContext.tsx`)
- Mobile API client → Mobile API configuration: configures
- Mobile role workflows → Mobile API client: calls
- HTTP server startup → HTTP application: starts (evidence: `backend/src/server.js`)
- HTTP server startup → Domain models: initializes (evidence: `backend/src/server.js`)
- HTTP server startup → Adherence monitor: starts (evidence: `backend/src/server.js`)
- HTTP server startup → Socket service: initializes (evidence: `backend/src/server.js`)
- HTTP application → API route dispatch: mounts (evidence: `backend/src/app.js`)
- API route dispatch → Authentication: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Admissions and discharge: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Clinical consultations: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Info desk workflows: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Prescription workflows: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Medication schedules: dispatches (evidence: `backend/src/routes/index.js`)
- API route dispatch → Other API domains: dispatches (evidence: `backend/src/routes/index.js`)
- Authentication → Domain models: queries (evidence: `backend/src/controllers/authController.js`)
- Admissions and discharge → Domain models: queries (evidence: `backend/src/controllers/admissionController.js`)
- Clinical consultations → Domain models: queries (evidence: `backend/src/controllers/consultationController.js`)
- Info desk workflows → Domain models: queries (evidence: `backend/src/controllers/infoDeskController.js`)
- Info desk workflows → Notification helper: notifies (evidence: `backend/src/controllers/infoDeskController.js`)
- Admissions and discharge → Notification helper: notifies (evidence: `backend/src/controllers/admissionController.js`)
- Clinical consultations → Notification helper: notifies (evidence: `backend/src/controllers/consultationController.js`)
- Clinical consultations → Socket service: emits (evidence: `backend/src/controllers/consultationController.js`)
- Adherence monitor → Domain models: queries (evidence: `backend/src/cron/adherenceMonitor.js`)
- Domain models → Relational database: uses (evidence: `backend/src/models/index.js`)
- Browser API client → HTTP application: requests
- Mobile API client → HTTP application: requests
