# abd523/hms-backend architecture

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

- Interactive diagram: https://gitdiagram.com/abd523/hms-backend
- Repository: https://github.com/abd523/hms-backend

## Overview

This repository is a Django REST API for hospital operations. A user sends requests through the central URL router to resource endpoints for patients, doctors, appointments, billing, laboratory work, pharmacy, prescriptions, medical records, and notifications; endpoints expose model-backed CRUD, with analytics and dashboard summaries as additional results. The model layer represents the persistent domain. The sampled routing and view code supports the main API paths; unsampled app endpoints are included where the central router documents them, but their internal behavior is not inferred.

Main entry points: [`core/urls.py`](https://github.com/abd523/hms-backend/blob/master/core/urls.py) (API router), [`accounts/views.py`](https://github.com/abd523/hms-backend/blob/master/accounts/views.py) (Dashboard stats), [`appointments/models.py`](https://github.com/abd523/hms-backend/blob/master/appointments/models.py) (Appointments), [`patients/models.py`](https://github.com/abd523/hms-backend/blob/master/patients/models.py) (Patient records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and oversight"]
  node_account_views["Accounts API<br/>[views.py]"]
  node_accounts[("Users and audit log<br/>[models.py]")]
  node_dashboard["Dashboard stats<br/>[views.py]"]
  node_notifications_api["Notifications API<br/>[views.py]"]
  node_notifications[("Notifications<br/>[models.py]")]
end

subgraph group_care["Care operations"]
  node_patients_api["Patient API<br/>[views.py]"]
  node_patients[("Patient records<br/>[models.py]")]
  node_doctors_api["Doctor API<br/>[views.py]"]
  node_doctors[("Doctor profiles<br/>[models.py]")]
  node_appointments_api["Appointments API<br/>[views.py]"]
  node_appointments[("Appointments<br/>[models.py]")]
  node_appointment_serializers["Appointment serializers<br/>[serializers.py]"]
end

subgraph group_clinical["Clinical services"]
  node_lab_api["Laboratory API<br/>[views.py]"]
  node_lab[("Lab requests and tests<br/>[models.py]")]
  node_pharmacy_api["Pharmacy API<br/>[views.py]"]
  node_pharmacy[("Medicines<br/>[models.py]")]
  node_records_api["Records and prescriptions API<br/>[views.py]"]
  node_prescriptions[("Medical records and prescriptions<br/>[models.py]")]
end

subgraph group_platform["API and reporting"]
  node_router["API router<br/>[urls.py]"]
  node_billing_api["Billing API<br/>[views.py]"]
  node_billing[("Invoices<br/>[models.py]")]
  node_analytics["Revenue analytics<br/>[views.py]"]
end

node_user(("API user"))

node_user -->|"sends requests"| node_router
node_router -->|"routes accounts"| node_account_views
node_router -->|"routes invoices"| node_billing_api
node_router -->|"routes analytics"| node_analytics
node_router -->|"routes medicines"| node_pharmacy_api
node_router -->|"routes lab work"| node_lab_api
node_router -->|"routes appointments"| node_appointments_api
node_router -->|"routes patients"| node_patients_api
node_router -->|"routes doctors"| node_doctors_api
node_router -->|"routes notifications"| node_notifications_api
node_router -->|"routes records"| node_records_api
node_router -->|"routes prescriptions"| node_records_api
node_account_views -->|"reads and manages"| node_accounts
node_account_views -->|"serves dashboard"| node_dashboard
node_dashboard -->|"counts patients"| node_patients
node_dashboard -->|"counts doctors"| node_doctors
node_dashboard -->|"counts appointments"| node_appointments
node_dashboard -->|"sums paid invoices"| node_billing
node_patients_api -->|"reads and writes"| node_patients
node_patients_api -->|"logs registration"| node_accounts
node_doctors_api -->|"reads and writes"| node_doctors
node_appointments_api -->|"reads and writes"| node_appointments
node_appointments_api -->|"serializes data"| node_appointment_serializers
node_appointments -->|"references patient"| node_patients
node_appointments -->|"references doctor"| node_doctors
node_billing_api -->|"reads and writes"| node_billing
node_billing_api -->|"logs payment"| node_accounts
node_analytics -->|"aggregates revenue"| node_billing
node_analytics -->|"aggregates demographics"| node_patients
node_lab_api -->|"reads and writes"| node_lab
node_pharmacy_api -->|"reads and writes"| node_pharmacy
node_records_api -->|"reads and writes"| node_prescriptions
node_notifications_api -->|"reads and writes"| node_notifications

click node_router "https://github.com/abd523/hms-backend/blob/master/core/urls.py"
click node_account_views "https://github.com/abd523/hms-backend/blob/master/accounts/views.py"
click node_accounts "https://github.com/abd523/hms-backend/blob/master/accounts/models.py"
click node_dashboard "https://github.com/abd523/hms-backend/blob/master/accounts/views.py"
click node_patients_api "https://github.com/abd523/hms-backend/blob/master/patients/views.py"
click node_patients "https://github.com/abd523/hms-backend/blob/master/patients/models.py"
click node_doctors_api "https://github.com/abd523/hms-backend/blob/master/doctors/views.py"
click node_doctors "https://github.com/abd523/hms-backend/blob/master/doctors/models.py"
click node_appointments_api "https://github.com/abd523/hms-backend/blob/master/appointments/views.py"
click node_appointments "https://github.com/abd523/hms-backend/blob/master/appointments/models.py"
click node_appointment_serializers "https://github.com/abd523/hms-backend/blob/master/appointments/serializers.py"
click node_billing_api "https://github.com/abd523/hms-backend/blob/master/billing/views.py"
click node_billing "https://github.com/abd523/hms-backend/blob/master/billing/models.py"
click node_analytics "https://github.com/abd523/hms-backend/blob/master/billing/views.py"
click node_lab_api "https://github.com/abd523/hms-backend/blob/master/laboratory/views.py"
click node_lab "https://github.com/abd523/hms-backend/blob/master/laboratory/models.py"
click node_pharmacy_api "https://github.com/abd523/hms-backend/blob/master/pharmacy/views.py"
click node_pharmacy "https://github.com/abd523/hms-backend/blob/master/pharmacy/models.py"
click node_records_api "https://github.com/abd523/hms-backend/blob/master/prescriptions/views.py"
click node_prescriptions "https://github.com/abd523/hms-backend/blob/master/prescriptions/models.py"
click node_notifications_api "https://github.com/abd523/hms-backend/blob/master/notifications/views.py"
click node_notifications "https://github.com/abd523/hms-backend/blob/master/notifications/models.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_account_views,node_accounts,node_dashboard,node_notifications_api,node_notifications,node_user toneBlue
class node_patients_api,node_patients,node_doctors_api,node_doctors,node_appointments_api,node_appointments,node_appointment_serializers toneAmber
class node_lab_api,node_lab,node_pharmacy_api,node_pharmacy,node_records_api,node_prescriptions toneMint
class node_router,node_billing_api,node_billing,node_analytics toneRose
```

## Components

### Identity and oversight

- [Accounts API](https://github.com/abd523/hms-backend/blob/master/accounts/views.py): `accounts/views.py`
- [Users and audit log](https://github.com/abd523/hms-backend/blob/master/accounts/models.py): `accounts/models.py`
- [Dashboard stats](https://github.com/abd523/hms-backend/blob/master/accounts/views.py): `accounts/views.py`
- [Notifications API](https://github.com/abd523/hms-backend/blob/master/notifications/views.py): `notifications/views.py`
- [Notifications](https://github.com/abd523/hms-backend/blob/master/notifications/models.py): `notifications/models.py`

### Care operations

- [Patient API](https://github.com/abd523/hms-backend/blob/master/patients/views.py): `patients/views.py`
- [Patient records](https://github.com/abd523/hms-backend/blob/master/patients/models.py): `patients/models.py`
- [Doctor API](https://github.com/abd523/hms-backend/blob/master/doctors/views.py): `doctors/views.py`
- [Doctor profiles](https://github.com/abd523/hms-backend/blob/master/doctors/models.py): `doctors/models.py`
- [Appointments API](https://github.com/abd523/hms-backend/blob/master/appointments/views.py): `appointments/views.py`
- [Appointments](https://github.com/abd523/hms-backend/blob/master/appointments/models.py): `appointments/models.py`
- [Appointment serializers](https://github.com/abd523/hms-backend/blob/master/appointments/serializers.py): `appointments/serializers.py`

### Clinical services

- [Laboratory API](https://github.com/abd523/hms-backend/blob/master/laboratory/views.py): `laboratory/views.py`
- [Lab requests and tests](https://github.com/abd523/hms-backend/blob/master/laboratory/models.py): `laboratory/models.py`
- [Pharmacy API](https://github.com/abd523/hms-backend/blob/master/pharmacy/views.py): `pharmacy/views.py`
- [Medicines](https://github.com/abd523/hms-backend/blob/master/pharmacy/models.py): `pharmacy/models.py`
- [Records and prescriptions API](https://github.com/abd523/hms-backend/blob/master/prescriptions/views.py): `prescriptions/views.py`
- [Medical records and prescriptions](https://github.com/abd523/hms-backend/blob/master/prescriptions/models.py): `prescriptions/models.py`

### API and reporting

- [API router](https://github.com/abd523/hms-backend/blob/master/core/urls.py): `core/urls.py`
- [Billing API](https://github.com/abd523/hms-backend/blob/master/billing/views.py): `billing/views.py`
- [Invoices](https://github.com/abd523/hms-backend/blob/master/billing/models.py): `billing/models.py`
- [Revenue analytics](https://github.com/abd523/hms-backend/blob/master/billing/views.py): `billing/views.py`

### Other components

- **API user**

## Connections

- API user → API router: sends requests
- API router → Accounts API: routes accounts (evidence: `core/urls.py`)
- API router → Billing API: routes invoices (evidence: `core/urls.py`)
- API router → Revenue analytics: routes analytics (evidence: `core/urls.py`)
- API router → Pharmacy API: routes medicines (evidence: `core/urls.py`)
- API router → Laboratory API: routes lab work (evidence: `core/urls.py`)
- API router → Appointments API: routes appointments (evidence: `core/urls.py`)
- API router → Patient API: routes patients (evidence: `core/urls.py`)
- API router → Doctor API: routes doctors (evidence: `core/urls.py`)
- API router → Notifications API: routes notifications (evidence: `core/urls.py`)
- API router → Records and prescriptions API: routes records (evidence: `core/urls.py`)
- API router → Records and prescriptions API: routes prescriptions (evidence: `core/urls.py`)
- Accounts API → Users and audit log: reads and manages (evidence: `accounts/views.py`)
- Accounts API → Dashboard stats: serves dashboard (evidence: `accounts/views.py`)
- Dashboard stats → Patient records: counts patients (evidence: `accounts/views.py`)
- Dashboard stats → Doctor profiles: counts doctors (evidence: `accounts/views.py`)
- Dashboard stats → Appointments: counts appointments (evidence: `accounts/views.py`)
- Dashboard stats → Invoices: sums paid invoices (evidence: `accounts/views.py`)
- Patient API → Patient records: reads and writes (evidence: `patients/views.py`)
- Patient API → Users and audit log: logs registration (evidence: `patients/views.py`)
- Doctor API → Doctor profiles: reads and writes (evidence: `doctors/views.py`)
- Appointments API → Appointments: reads and writes (evidence: `appointments/views.py`)
- Appointments API → Appointment serializers: serializes data (evidence: `appointments/views.py`)
- Appointments → Patient records: references patient (evidence: `appointments/models.py`)
- Appointments → Doctor profiles: references doctor (evidence: `appointments/models.py`)
- Billing API → Invoices: reads and writes (evidence: `billing/views.py`)
- Billing API → Users and audit log: logs payment (evidence: `billing/views.py`)
- Revenue analytics → Invoices: aggregates revenue (evidence: `billing/views.py`)
- Revenue analytics → Patient records: aggregates demographics (evidence: `billing/views.py`)
- Laboratory API → Lab requests and tests: reads and writes (evidence: `laboratory/views.py`)
- Pharmacy API → Medicines: reads and writes (evidence: `pharmacy/views.py`)
- Records and prescriptions API → Medical records and prescriptions: reads and writes (evidence: `prescriptions/views.py`)
- Notifications API → Notifications: reads and writes (evidence: `notifications/views.py`)
