# abdulhamid109/careus-backend architecture

> Architecture diagram of the GitHub repository abdulhamid109/careus-backend, 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/abdulhamid109/careus-backend
- Repository: https://github.com/abdulhamid109/careus-backend

## Overview

Careus Backend is an Express API for guardian-managed patient care, medication schedules, reports, and phone-based medication check-ins. The main workflow is a client request handled by the API routes, which read or update Mongoose-backed records; scheduled medication calls use Twilio and IVR responses update call-related state. The route excerpt is partial, so the graph includes only evidenced route-to-model interactions and documented-in-code integrations. Although a database connector exists, the visible server entry point does not call it.

Main entry points: [`routes/apiroutes.js`](https://github.com/abdulhamid109/careus-backend/blob/main/routes/apiroutes.js) (API routes), [`index.js`](https://github.com/abdulhamid109/careus-backend/blob/main/index.js) (Server entry), [`models/userModal.js`](https://github.com/abdulhamid109/careus-backend/blob/main/models/userModal.js) (Guardian model), [`models/patientModal.js`](https://github.com/abdulhamid109/careus-backend/blob/main/models/patientModal.js) (Patient model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["API server"]
  node_index["Server entry<br/>[index.js]"]
  node_routes["API routes<br/>[apiroutes.js]"]
end

subgraph group_care["Care records"]
  node_user["Guardian model<br/>[userModal.js]"]
  node_patient["Patient model<br/>[patientModal.js]"]
  node_report["Report model<br/>[reportsModal.js]"]
end

subgraph group_medication["Medication reminders"]
  node_slot["Slot model<br/>[slotModal.js]"]
  node_tablet["Tablet model<br/>[tabletsModal.js]"]
  node_ivrmodel["IVR model<br/>[IVRModal.js]"]
  node_cron["Schedule jobs<br/>[apiroutes.js]"]
end

subgraph group_integrations["External services"]
  node_twilio["Twilio voice"]
  node_imagekit["ImageKit storage"]
end

node_client(("API client"))
node_mongo[("MongoDB")]

node_client -->|"sends requests"| node_index
node_index -->|"mounts API"| node_routes
node_routes -->|"queries guardian"| node_user
node_routes -->|"manages patients"| node_patient
node_routes -->|"saves reports"| node_report
node_routes -->|"manages slots"| node_slot
node_routes -->|"manages medication"| node_tablet
node_routes -->|"reads call records"| node_ivrmodel
node_routes -->|"schedules calls"| node_cron
node_routes -->|"places voice calls"| node_twilio
node_twilio -->|"posts call events"| node_routes
node_routes -->|"uploads reports"| node_imagekit
node_user -->|"persists guardian"| node_mongo
node_patient -->|"persists patient"| node_mongo
node_report -->|"persists report"| node_mongo
node_slot -->|"persists slots"| node_mongo
node_tablet -->|"persists schedules"| node_mongo
node_ivrmodel -->|"persists call state"| node_mongo

click node_index "https://github.com/abdulhamid109/careus-backend/blob/main/index.js"
click node_routes "https://github.com/abdulhamid109/careus-backend/blob/main/routes/apiroutes.js"
click node_user "https://github.com/abdulhamid109/careus-backend/blob/main/models/userModal.js"
click node_patient "https://github.com/abdulhamid109/careus-backend/blob/main/models/patientModal.js"
click node_report "https://github.com/abdulhamid109/careus-backend/blob/main/models/reportsModal.js"
click node_slot "https://github.com/abdulhamid109/careus-backend/blob/main/models/slotModal.js"
click node_tablet "https://github.com/abdulhamid109/careus-backend/blob/main/models/tabletsModal.js"
click node_ivrmodel "https://github.com/abdulhamid109/careus-backend/blob/main/models/IVRModal.js"
click node_cron "https://github.com/abdulhamid109/careus-backend/blob/main/routes/apiroutes.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_index,node_routes,node_client toneBlue
class node_user,node_patient,node_report,node_mongo toneAmber
class node_slot,node_tablet,node_ivrmodel,node_cron toneMint
class node_twilio,node_imagekit toneRose
```

## Components

### API server

- [Server entry](https://github.com/abdulhamid109/careus-backend/blob/main/index.js): `index.js`
- [API routes](https://github.com/abdulhamid109/careus-backend/blob/main/routes/apiroutes.js): `routes/apiroutes.js`

### Care records

- [Guardian model](https://github.com/abdulhamid109/careus-backend/blob/main/models/userModal.js): `models/userModal.js`
- [Patient model](https://github.com/abdulhamid109/careus-backend/blob/main/models/patientModal.js): `models/patientModal.js`
- [Report model](https://github.com/abdulhamid109/careus-backend/blob/main/models/reportsModal.js): `models/reportsModal.js`

### Medication reminders

- [Slot model](https://github.com/abdulhamid109/careus-backend/blob/main/models/slotModal.js): `models/slotModal.js`
- [Tablet model](https://github.com/abdulhamid109/careus-backend/blob/main/models/tabletsModal.js): `models/tabletsModal.js`
- [IVR model](https://github.com/abdulhamid109/careus-backend/blob/main/models/IVRModal.js): `models/IVRModal.js`
- [Schedule jobs](https://github.com/abdulhamid109/careus-backend/blob/main/routes/apiroutes.js): `routes/apiroutes.js`

### External services

- **Twilio voice**
- **ImageKit storage**

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Server entry: sends requests
- Server entry → API routes: mounts API
- API routes → Guardian model: queries guardian
- API routes → Patient model: manages patients
- API routes → Report model: saves reports
- API routes → Slot model: manages slots
- API routes → Tablet model: manages medication
- API routes → IVR model: reads call records
- API routes → Schedule jobs: schedules calls
- API routes → Twilio voice: places voice calls
- Twilio voice → API routes: posts call events
- API routes → ImageKit storage: uploads reports
- Guardian model → MongoDB: persists guardian
- Patient model → MongoDB: persists patient
- Report model → MongoDB: persists report
- Slot model → MongoDB: persists slots
- Tablet model → MongoDB: persists schedules
- IVR model → MongoDB: persists call state
