# kartik-h6/pmas architecture

> Architecture diagram of the GitHub repository kartik-h6/pmas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kartik-h6/pmas
- Repository: https://github.com/kartik-h6/pmas

## Overview

PMAS is an offline-first, pharmacist-led medication adherence and counselling platform. Patients provide consent, manage medication plans, record dose adherence and symptoms, and receive reminders; the app calculates summaries and can export de-identified research data. Pharmacists enrol patients, assign plans, and monitor adherence through a portal, with the backend supporting authenticated patient, pharmacist, and admin workflows. The repository includes dedicated local-storage, adherence, multilingual, export, and sync modules. Backend excerpts are partial, and the portal implementation was not sampled, so its internal behavior is not expanded here.

Main entry points: [`patient-app/demo/js/app.js`](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/app.js) (App Workflows), [`backend/main.py`](https://github.com/kartik-h6/pmas/blob/main/backend/main.py) (API Workflows), [`patient-app/demo/js/export.js`](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/export.js) (Patient and Research Export), [`patient-app/demo/index.html`](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/index.html) (Patient App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patient["Patient PWA"]
  node_patient_app["Patient App<br/>[index.html]"]
  node_app_logic["App Workflows<br/>[app.js]"]
  node_local_db[("Local Data<br/>[db.js]")]
  node_adherence["Adherence Metrics<br/>[adherence.js]"]
  node_translations["Counselling Languages<br/>[i18n.js]"]
  node_reminders["Dose Reminders<br/>[reminders.js]"]
  node_offline_worker["Offline PWA<br/>[sw.js]"]
  node_sync["API Sync<br/>[api.js]"]
end

subgraph group_backend["Backend Service"]
  node_backend_api["API Workflows<br/>[main.py]"]
  node_auth["Authentication and Roles<br/>[auth.py]"]
  node_contracts["API Contracts<br/>[schemas.py]"]
  node_vaults[("Dual-Vault Data<br/>[database.py]")]
end

subgraph group_care["Pharmacist Care"]
  node_portal["Pharmacist Portal<br/>[index.html]"]
end

subgraph group_research["Research Outputs"]
  node_export["Patient and Research Export<br/>[export.js]"]
end

node_patient_actor(("Patient"))
node_notifications(("Browser Notifications"))
node_pharmacist_actor(("Pharmacist"))
node_admin_actor(("Administrator"))
node_researcher(("Researcher"))

node_patient_actor -->|"uses"| node_patient_app
node_patient_app -->|"loads"| node_app_logic
node_app_logic -->|"reads and writes"| node_local_db
node_app_logic -->|"calculates"| node_adherence
node_app_logic -->|"checks doses"| node_reminders
node_reminders -->|"reads plans"| node_local_db
node_reminders -.->|"dispatches"| node_notifications
node_app_logic -->|"renders strings"| node_translations
node_patient_app -->|"registers"| node_offline_worker
node_app_logic -->|"requests reports"| node_export
node_export -->|"reads records"| node_local_db
node_export -->|"gets summaries"| node_adherence
node_app_logic -->|"requests sync"| node_sync
node_sync -.->|"sends API requests"| node_backend_api
node_pharmacist_actor -->|"uses"| node_portal
node_portal -.->|"requests care workflows"| node_backend_api
node_admin_actor -->|"manages accounts"| node_backend_api
node_backend_api -->|"checks identity and role"| node_auth
node_backend_api -->|"validates payloads"| node_contracts
node_backend_api -->|"reads and writes"| node_vaults
node_researcher -->|"receives export"| node_export

click node_patient_app "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/index.html"
click node_app_logic "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/app.js"
click node_local_db "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/db.js"
click node_adherence "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/adherence.js"
click node_translations "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/i18n.js"
click node_reminders "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/reminders.js"
click node_offline_worker "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/sw.js"
click node_export "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/export.js"
click node_sync "https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/api.js"
click node_portal "https://github.com/kartik-h6/pmas/blob/main/pharmacist-portal/index.html"
click node_backend_api "https://github.com/kartik-h6/pmas/blob/main/backend/main.py"
click node_auth "https://github.com/kartik-h6/pmas/blob/main/backend/auth.py"
click node_contracts "https://github.com/kartik-h6/pmas/blob/main/backend/schemas.py"
click node_vaults "https://github.com/kartik-h6/pmas/blob/main/backend/database.py"

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_app_logic,node_local_db,node_adherence,node_translations,node_reminders,node_offline_worker,node_sync,node_notifications toneBlue
class node_backend_api,node_auth,node_contracts,node_vaults toneAmber
class node_portal toneMint
class node_export toneRose
class node_patient_actor,node_pharmacist_actor,node_admin_actor,node_researcher toneIndigo
```

## Components

### Patient PWA

- [Patient App](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/index.html): `patient-app/demo/index.html`
- [App Workflows](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/app.js): `patient-app/demo/js/app.js`
- [Local Data](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/db.js): `patient-app/demo/js/db.js`
- [Adherence Metrics](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/adherence.js): `patient-app/demo/js/adherence.js`
- [Counselling Languages](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/i18n.js): `patient-app/demo/js/i18n.js`
- [Dose Reminders](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/reminders.js): `patient-app/demo/js/reminders.js`
- [Offline PWA](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/sw.js): `patient-app/demo/sw.js`
- [API Sync](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/api.js): `patient-app/demo/js/api.js`

### Backend Service

- [API Workflows](https://github.com/kartik-h6/pmas/blob/main/backend/main.py): `backend/main.py`
- [Authentication and Roles](https://github.com/kartik-h6/pmas/blob/main/backend/auth.py): `backend/auth.py`
- [API Contracts](https://github.com/kartik-h6/pmas/blob/main/backend/schemas.py): `backend/schemas.py`
- [Dual-Vault Data](https://github.com/kartik-h6/pmas/blob/main/backend/database.py): `backend/database.py`

### Pharmacist Care

- [Pharmacist Portal](https://github.com/kartik-h6/pmas/blob/main/pharmacist-portal/index.html): `pharmacist-portal/index.html`

### Research Outputs

- [Patient and Research Export](https://github.com/kartik-h6/pmas/blob/main/patient-app/demo/js/export.js): `patient-app/demo/js/export.js`

### Other components

- **Patient**
- **Browser Notifications**
- **Pharmacist**
- **Administrator**
- **Researcher**

## Connections

- Patient → Patient App: uses
- Patient App → App Workflows: loads
- App Workflows → Local Data: reads and writes
- App Workflows → Adherence Metrics: calculates
- App Workflows → Dose Reminders: checks doses
- Dose Reminders → Local Data: reads plans
- Dose Reminders → Browser Notifications: dispatches
- App Workflows → Counselling Languages: renders strings
- Patient App → Offline PWA: registers
- App Workflows → Patient and Research Export: requests reports
- Patient and Research Export → Local Data: reads records
- Patient and Research Export → Adherence Metrics: gets summaries
- App Workflows → API Sync: requests sync
- API Sync → API Workflows: sends API requests
- Pharmacist → Pharmacist Portal: uses
- Pharmacist Portal → API Workflows: requests care workflows
- Administrator → API Workflows: manages accounts
- API Workflows → Authentication and Roles: checks identity and role
- API Workflows → API Contracts: validates payloads
- API Workflows → Dual-Vault Data: reads and writes
- Researcher → Patient and Research Export: receives export
