# yagna-gajjar/healthmate-api architecture

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

- Interactive diagram: https://gitdiagram.com/yagna-gajjar/healthmate-api
- Repository: https://github.com/yagna-gajjar/healthmate-api

## Overview

Healthmate is a TypeScript/Express backend for healthcare administration and care workflows. Users access its API to manage accounts and permissions, patient and clinician records, appointments and prescriptions, and related operational work such as billing, staffing, and notifications. The sampled authentication code shows patient registration coordinating user, address, patient, and document creation in a transaction; the sampled route files show authenticated and permission-checked endpoints for several domains. Many modules are present in the tree but were not sampled, so their internal calls and cross-domain wiring are not inferred.

Main entry points: [`src/controllers/auth.controller.ts`](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/controllers/auth.controller.ts) (Authentication controller), [`src/services/auth.service.ts`](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/services/auth.service.ts) (Authentication service), [`src/routes/auth.route.ts`](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/routes/auth.route.ts) (Authentication routes), [`src/index.ts`](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/index.ts) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and administration"]
  node_auth_routes["Authentication routes<br/>[auth.route.ts]"]
  node_auth_controller["Authentication controller<br/>[auth.controller.ts]"]
  node_auth_service["Authentication service<br/>[auth.service.ts]"]
  node_rbac["Role permissions<br/>[index.ts]"]
  node_rbac_service["RBAC service<br/>[rbac.service.ts]"]
  node_rbac_repo["RBAC repository<br/>[rbac.repository.ts]"]
end

subgraph group_care["Care workflows"]
  node_patient["Patient records"]
  node_doctor["Doctor records<br/>[doctor.routes.ts]"]
  node_appointments["Appointments"]
  node_prescriptions["Prescriptions"]
  node_prescription_items["Prescription items"]
  node_documents["Documents<br/>[document.routes.ts]"]
end

subgraph group_operations["Operations"]
  node_billing["Invoices and payments"]
  node_staffing["Staff and shifts"]
  node_notifications["Notifications"]
  node_dashboard["Dashboard"]
end

subgraph group_runtime["API and persistence"]
  node_server["HTTP API<br/>[index.ts]"]
  node_routes["Route registry<br/>[index.ts]"]
  node_auth_repo["User repository<br/>[auth.repository.ts]"]
  node_database[("PostgreSQL database<br/>[data-source.ts]")]
  node_mailer["Gmail mail service"]
end

node_user(("Healthcare user"))

node_user -->|"sends requests"| node_server
node_server -->|"dispatches routes"| node_routes
node_routes -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"invokes handlers"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_controller -->|"checks permissions"| node_rbac_service
node_auth_controller -->|"creates repository"| node_rbac_repo
node_auth_service -->|"queries and updates"| node_auth_repo
node_auth_service -->|"transacts registration"| node_database
node_auth_repo -->|"reads and writes users"| node_database
node_auth_service -.->|"sends email"| node_mailer
node_doctor -->|"invokes appointment handler"| node_appointments

click node_server "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/index.ts"
click node_routes "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/routes/index.ts"
click node_auth_routes "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/routes/auth.route.ts"
click node_auth_controller "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/controllers/auth.controller.ts"
click node_auth_service "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/services/auth.service.ts"
click node_auth_repo "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/repository/auth.repository.ts"
click node_rbac "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/rbac/index.ts"
click node_rbac_service "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/services/rbac.service.ts"
click node_rbac_repo "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/repository/rbac.repository.ts"
click node_patient "https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/patient"
click node_doctor "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/doctor/doctor.routes.ts"
click node_appointments "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/appointment/appointment.routes.ts"
click node_prescriptions "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/prescription/prescription.routes.ts"
click node_prescription_items "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/prescription_item/prescription_item.routes.ts"
click node_documents "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/document/document.routes.ts"
click node_billing "https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/invoice"
click node_staffing "https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/staff"
click node_notifications "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/notification/notification.routes.ts"
click node_dashboard "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/controllers/dashboard.controller.ts"
click node_database "https://github.com/yagna-gajjar/healthmate-api/blob/main/src/config/data-source.ts"

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_auth_routes,node_auth_controller,node_auth_service,node_rbac,node_rbac_service,node_rbac_repo,node_user toneBlue
class node_patient,node_doctor,node_appointments,node_prescriptions,node_prescription_items,node_documents toneAmber
class node_billing,node_staffing,node_notifications,node_dashboard toneMint
class node_server,node_routes,node_auth_repo,node_database,node_mailer toneRose
```

## Components

### Access and administration

- [Authentication routes](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/routes/auth.route.ts): `src/routes/auth.route.ts`
- [Authentication controller](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/controllers/auth.controller.ts): `src/controllers/auth.controller.ts`
- [Authentication service](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/services/auth.service.ts): `src/services/auth.service.ts`
- [Role permissions](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/rbac/index.ts): `src/rbac/index.ts`
- [RBAC service](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/services/rbac.service.ts): `src/services/rbac.service.ts`
- [RBAC repository](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/repository/rbac.repository.ts): `src/repository/rbac.repository.ts`

### Care workflows

- [Patient records](https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/patient): `src/modules/patient`
- [Doctor records](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/doctor/doctor.routes.ts): `src/modules/doctor/doctor.routes.ts`
- [Appointments](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/appointment/appointment.routes.ts): `src/modules/appointment/appointment.routes.ts`
- [Prescriptions](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/prescription/prescription.routes.ts): `src/modules/prescription/prescription.routes.ts`
- [Prescription items](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/prescription_item/prescription_item.routes.ts): `src/modules/prescription_item/prescription_item.routes.ts`
- [Documents](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/document/document.routes.ts): `src/modules/document/document.routes.ts`

### Operations

- [Invoices and payments](https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/invoice): `src/modules/invoice`
- [Staff and shifts](https://github.com/yagna-gajjar/healthmate-api/tree/main/src/modules/staff): `src/modules/staff`
- [Notifications](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/modules/notification/notification.routes.ts): `src/modules/notification/notification.routes.ts`
- [Dashboard](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/controllers/dashboard.controller.ts): `src/controllers/dashboard.controller.ts`

### API and persistence

- [HTTP API](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/index.ts): `src/index.ts`
- [Route registry](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [User repository](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/repository/auth.repository.ts): `src/repository/auth.repository.ts`
- [PostgreSQL database](https://github.com/yagna-gajjar/healthmate-api/blob/main/src/config/data-source.ts): `src/config/data-source.ts`
- **Gmail mail service**

### Other components

- **Healthcare user**

## Connections

- Healthcare user → HTTP API: sends requests
- HTTP API → Route registry: dispatches routes
- Route registry → Authentication routes: mounts routes
- Authentication routes → Authentication controller: invokes handlers
- Authentication controller → Authentication service: calls
- Authentication controller → RBAC service: checks permissions
- Authentication controller → RBAC repository: creates repository
- Authentication service → User repository: queries and updates
- Authentication service → PostgreSQL database: transacts registration
- User repository → PostgreSQL database: reads and writes users
- Authentication service → Gmail mail service: sends email
- Doctor records → Appointments: invokes appointment handler
