# ymr12-m/ma3ak architecture

> Architecture diagram of the GitHub repository ymr12-m/ma3ak, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ymr12-m/ma3ak
- Repository: https://github.com/ymr12-m/ma3ak

## Overview

MA3ak is a patient-care platform for medication adherence, appointments, health measurements, and caregiver monitoring. Its main documented workflow is a dose reminder that can escalate from a patient alarm to a caregiver alert when a dose is missed or the patient does not respond. The graph includes the documented frontend capability areas and backend domain routes; frontend-to-API wiring is not established by the sampled evidence, so those links are omitted.

Main entry points: [`backend/db.js`](https://github.com/ymr12-m/ma3ak/blob/main/backend/db.js) (MySQL), [`backend/utils/notify.js`](https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/notify.js) (Notification delivery policy), [`backend/utils/push.js`](https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/push.js) (Web Push delivery), [`backend/routes/doses.js`](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/doses.js) (Dose records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Patient and caregiver app"]
  node_patient_ui["Patient experience<br/>[PatientHome.jsx]"]
  node_medication_ui["Medication management<br/>[Medications.jsx]"]
  node_alarm_ui["Dose alarm<br/>[Alarm.jsx]"]
  node_appointment_ui["Appointments<br/>[Appointments.jsx]"]
  node_vitals_ui["Health measurements<br/>[Vitals.jsx]"]
  node_adherence_ui["Adherence history<br/>[Adherence.jsx]"]
  node_notification_ui["Notifications<br/>[Notifications.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_service_worker["Background alarm delivery<br/>[sw.js]"]
end

subgraph group_api["Care and account API"]
  node_auth_routes["Authentication<br/>[auth.js]"]
  node_patient_routes["Patient and caregiver links<br/>[patients.js]"]
  node_medication_routes["Medication schedules<br/>[medications.js]"]
  node_dose_routes["Dose records<br/>[doses.js]"]
  node_appointment_routes["Appointment records<br/>[appointments.js]"]
  node_vitals_routes["Vital records<br/>[vitals.js]"]
  node_notification_routes["Notification records<br/>[notifications.js]"]
end

subgraph group_reminders["Reminder and notification services"]
  node_scheduler["Dose escalation scheduler<br/>[scheduler.js]"]
  node_notify["Notification delivery policy<br/>[notify.js]"]
  node_push["Web Push delivery<br/>[push.js]"]
end

subgraph group_data["Persistence and access"]
  node_access["Patient access checks<br/>[access.js]"]
  node_database[("MySQL<br/>[db.js]")]
end

node_patient(("Patient"))
node_caregiver(("Caregiver"))
node_push_service{{"Browser push service"}}

node_patient -->|"receives reminders"| node_alarm_ui
node_caregiver -->|"monitors patient"| node_patient_ui
node_scheduler -->|"creates alerts"| node_notify
node_dose_routes -->|"creates alerts"| node_notify
node_notify -->|"dispatches push"| node_push
node_push -->|"sends notifications"| node_push_service
node_notify -->|"stores notifications"| node_database
node_push -->|"reads subscriptions"| node_database
node_access -->|"checks links"| node_database
node_auth_routes -->|"reads and writes"| node_database
node_patient_routes -->|"reads and writes"| node_database
node_medication_routes -->|"reads and writes"| node_database
node_dose_routes -->|"reads and writes"| node_database
node_appointment_routes -->|"reads and writes"| node_database
node_vitals_routes -->|"reads and writes"| node_database
node_notification_routes -->|"reads and writes"| node_database

click node_patient_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/PatientHome.jsx"
click node_medication_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Medications.jsx"
click node_alarm_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Alarm.jsx"
click node_appointment_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Appointments.jsx"
click node_vitals_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Vitals.jsx"
click node_adherence_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Adherence.jsx"
click node_notification_ui "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Notifications.jsx"
click node_api_client "https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/api.js"
click node_auth_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/auth.js"
click node_patient_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/patients.js"
click node_medication_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/medications.js"
click node_dose_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/doses.js"
click node_appointment_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/appointments.js"
click node_vitals_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/vitals.js"
click node_notification_routes "https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/notifications.js"
click node_scheduler "https://github.com/ymr12-m/ma3ak/blob/main/backend/scheduler.js"
click node_notify "https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/notify.js"
click node_push "https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/push.js"
click node_service_worker "https://github.com/ymr12-m/ma3ak/blob/main/frontend/sw.js"
click node_access "https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/access.js"
click node_database "https://github.com/ymr12-m/ma3ak/blob/main/backend/db.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_patient_ui,node_medication_ui,node_alarm_ui,node_appointment_ui,node_vitals_ui,node_adherence_ui,node_notification_ui,node_api_client,node_service_worker,node_push_service toneBlue
class node_auth_routes,node_patient_routes,node_medication_routes,node_dose_routes,node_appointment_routes,node_vitals_routes,node_notification_routes toneAmber
class node_scheduler,node_notify,node_push toneMint
class node_access,node_database toneRose
class node_patient,node_caregiver toneIndigo
```

## Components

### Patient and caregiver app

- [Patient experience](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/PatientHome.jsx): `frontend/js/components/PatientHome.jsx`
- [Medication management](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Medications.jsx): `frontend/js/components/Medications.jsx`
- [Dose alarm](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Alarm.jsx): `frontend/js/components/Alarm.jsx`
- [Appointments](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Appointments.jsx): `frontend/js/components/Appointments.jsx`
- [Health measurements](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Vitals.jsx): `frontend/js/components/Vitals.jsx`
- [Adherence history](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Adherence.jsx): `frontend/js/components/Adherence.jsx`
- [Notifications](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/components/Notifications.jsx): `frontend/js/components/Notifications.jsx`
- [API client](https://github.com/ymr12-m/ma3ak/blob/main/frontend/js/api.js): `frontend/js/api.js`
- [Background alarm delivery](https://github.com/ymr12-m/ma3ak/blob/main/frontend/sw.js): `frontend/sw.js`

### Care and account API

- [Authentication](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Patient and caregiver links](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/patients.js): `backend/routes/patients.js`
- [Medication schedules](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/medications.js): `backend/routes/medications.js`
- [Dose records](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/doses.js): `backend/routes/doses.js`
- [Appointment records](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/appointments.js): `backend/routes/appointments.js`
- [Vital records](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/vitals.js): `backend/routes/vitals.js`
- [Notification records](https://github.com/ymr12-m/ma3ak/blob/main/backend/routes/notifications.js): `backend/routes/notifications.js`

### Reminder and notification services

- [Dose escalation scheduler](https://github.com/ymr12-m/ma3ak/blob/main/backend/scheduler.js): `backend/scheduler.js`
- [Notification delivery policy](https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/notify.js): `backend/utils/notify.js`
- [Web Push delivery](https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/push.js): `backend/utils/push.js`

### Persistence and access

- [Patient access checks](https://github.com/ymr12-m/ma3ak/blob/main/backend/utils/access.js): `backend/utils/access.js`
- [MySQL](https://github.com/ymr12-m/ma3ak/blob/main/backend/db.js): `backend/db.js`

### Other components

- **Patient**
- **Caregiver**
- **Browser push service**

## Connections

- Patient → Dose alarm: receives reminders
- Caregiver → Patient experience: monitors patient
- Dose escalation scheduler → Notification delivery policy: creates alerts (evidence: `backend/scheduler.js`)
- Dose records → Notification delivery policy: creates alerts (evidence: `backend/routes/doses.js`)
- Notification delivery policy → Web Push delivery: dispatches push (evidence: `backend/utils/notify.js`)
- Web Push delivery → Browser push service: sends notifications (evidence: `backend/utils/push.js`)
- Notification delivery policy → MySQL: stores notifications (evidence: `backend/utils/notify.js`)
- Web Push delivery → MySQL: reads subscriptions (evidence: `backend/utils/push.js`)
- Patient access checks → MySQL: checks links (evidence: `backend/utils/access.js`)
- Authentication → MySQL: reads and writes (evidence: `backend/routes/auth.js`)
- Patient and caregiver links → MySQL: reads and writes (evidence: `backend/routes/patients.js`)
- Medication schedules → MySQL: reads and writes (evidence: `backend/routes/medications.js`)
- Dose records → MySQL: reads and writes (evidence: `backend/routes/doses.js`)
- Appointment records → MySQL: reads and writes (evidence: `backend/routes/appointments.js`)
- Vital records → MySQL: reads and writes (evidence: `backend/routes/vitals.js`)
- Notification records → MySQL: reads and writes (evidence: `backend/routes/notifications.js`)
