# hajismshenga/healthcare_backend architecture

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

- Interactive diagram: https://gitdiagram.com/hajismshenga/healthcare_backend
- Repository: https://github.com/hajismshenga/healthcare_backend

## Overview

This Spring Boot healthcare backend manages hospitals, doctors, laboratories and patients, then supports lab testing and medication records. Its main workflow is a doctor requesting a lab test for a patient, a laboratory updating its status or submitting results, and users retrieving clinical records. The graph also preserves documented registration, login, listing, invitations, prescriptions and medication-history capabilities. Source excerpts show several service-to-repository calls; other feature coverage relies on README documentation and the source tree, so unsampled wiring is not inferred.

Main entry points: [`src/main/java/com/healthcare/controller/PatientController.java`](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PatientController.java) (Patient API), [`src/main/java/com/healthcare/controller/LabTestController.java`](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/LabTestController.java) (Lab test API), [`src/main/java/com/healthcare/repository/PrescriptionRepository.java`](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/repository/PrescriptionRepository.java) (Prescription records), [`src/main/java/com/healthcare/controller/HospitalController.java`](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/HospitalController.java) (Hospital API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_org["Organizations and access"]
  node_hospital_api["Hospital API"]
  node_hospital_service["Hospital management"]
  node_doctor_api["Doctor API"]
  node_doctor_service["Doctor management<br/>[DoctorService.java]"]
  node_lab_api["Laboratory API"]
  node_lab_service["Laboratory management"]
end

subgraph group_people["Patient relationships"]
  node_patient_api["Patient API"]
  node_patient_service["Patient management"]
  node_invitation_api["Invitation API"]
  node_invitation_service["Patient invitations"]
end

subgraph group_labs["Laboratory workflow"]
  node_labtest_api["Lab test API"]
  node_labtest_service["Lab test workflow"]
  node_labtest_store[("Lab test records")]
end

subgraph group_meds["Medication records"]
  node_prescription_api["Prescription API"]
  node_prescription_service["Prescription management"]
  node_history_service["Medication history"]
  node_prescription_store[("Prescription records")]
end

node_hospital_actor(("Hospital staff"))
node_doctor_actor(("Doctor"))
node_patient_actor(("Patient"))
node_lab_actor(("Laboratory staff"))
node_mysql[("MySQL database")]

node_hospital_actor -->|"registers or logs in"| node_hospital_api
node_hospital_api -->|"delegates to"| node_hospital_service
node_hospital_service -.->|"manages records"| node_mysql
node_hospital_actor -->|"registers doctors"| node_doctor_api
node_doctor_api -->|"delegates to"| node_doctor_service
node_doctor_service -.->|"reads and writes"| node_mysql
node_hospital_actor -->|"registers laboratories"| node_lab_api
node_lab_api -.->|"manages laboratories"| node_lab_service
node_hospital_actor -->|"lists patients"| node_patient_api
node_doctor_actor -->|"registers patients"| node_patient_api
node_patient_api -->|"delegates to"| node_patient_service
node_patient_service -.->|"reads and writes"| node_mysql
node_patient_actor -->|"invites a doctor"| node_invitation_api
node_invitation_api -->|"delegates to"| node_invitation_service
node_doctor_actor -->|"requests a test"| node_labtest_api
node_lab_actor -->|"submits results"| node_labtest_api
node_labtest_api -->|"delegates to"| node_labtest_service
node_labtest_service -->|"queries and saves"| node_labtest_store
node_labtest_store -.->|"persists records"| node_mysql
node_doctor_actor -->|"manages prescriptions"| node_prescription_api
node_prescription_api -.->|"delegates to"| node_prescription_service
node_prescription_service -->|"queries and saves"| node_prescription_store
node_patient_actor -->|"views medication history"| node_history_service
node_history_service -->|"reads prescriptions"| node_prescription_store
node_prescription_store -.->|"persists records"| node_mysql

click node_hospital_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/HospitalController.java"
click node_hospital_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/HospitalService.java"
click node_doctor_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/DoctorController.java"
click node_doctor_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/DoctorService.java"
click node_lab_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/LaboratoryController.java"
click node_lab_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/LaboratoryService.java"
click node_patient_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PatientController.java"
click node_patient_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientService.java"
click node_invitation_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PatientInvitationController.java"
click node_invitation_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientInvitationService.java"
click node_labtest_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/LabTestController.java"
click node_labtest_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/LabTestService.java"
click node_labtest_store "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/repository/LabTestRepository.java"
click node_prescription_api "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PrescriptionController.java"
click node_prescription_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PrescriptionService.java"
click node_history_service "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientMedicationHistoryService.java"
click node_prescription_store "https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/repository/PrescriptionRepository.java"

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_hospital_api,node_hospital_service,node_doctor_api,node_doctor_service,node_lab_api,node_lab_service toneBlue
class node_patient_api,node_patient_service,node_invitation_api,node_invitation_service,node_mysql toneAmber
class node_labtest_api,node_labtest_service,node_labtest_store toneMint
class node_prescription_api,node_prescription_service,node_history_service,node_prescription_store toneRose
class node_hospital_actor,node_doctor_actor,node_patient_actor,node_lab_actor toneIndigo
```

## Components

### Organizations and access

- [Hospital API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/HospitalController.java): `src/main/java/com/healthcare/controller/HospitalController.java`
- [Hospital management](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/HospitalService.java): `src/main/java/com/healthcare/service/HospitalService.java`
- [Doctor API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/DoctorController.java): `src/main/java/com/healthcare/controller/DoctorController.java`
- [Doctor management](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/DoctorService.java): `src/main/java/com/healthcare/service/DoctorService.java`
- [Laboratory API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/LaboratoryController.java): `src/main/java/com/healthcare/controller/LaboratoryController.java`
- [Laboratory management](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/LaboratoryService.java): `src/main/java/com/healthcare/service/LaboratoryService.java`

### Patient relationships

- [Patient API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PatientController.java): `src/main/java/com/healthcare/controller/PatientController.java`
- [Patient management](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientService.java): `src/main/java/com/healthcare/service/PatientService.java`
- [Invitation API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PatientInvitationController.java): `src/main/java/com/healthcare/controller/PatientInvitationController.java`
- [Patient invitations](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientInvitationService.java): `src/main/java/com/healthcare/service/PatientInvitationService.java`

### Laboratory workflow

- [Lab test API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/LabTestController.java): `src/main/java/com/healthcare/controller/LabTestController.java`
- [Lab test workflow](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/LabTestService.java): `src/main/java/com/healthcare/service/LabTestService.java`
- [Lab test records](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/repository/LabTestRepository.java): `src/main/java/com/healthcare/repository/LabTestRepository.java`

### Medication records

- [Prescription API](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/controller/PrescriptionController.java): `src/main/java/com/healthcare/controller/PrescriptionController.java`
- [Prescription management](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PrescriptionService.java): `src/main/java/com/healthcare/service/PrescriptionService.java`
- [Medication history](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/service/PatientMedicationHistoryService.java): `src/main/java/com/healthcare/service/PatientMedicationHistoryService.java`
- [Prescription records](https://github.com/hajismshenga/healthcare_backend/blob/main/src/main/java/com/healthcare/repository/PrescriptionRepository.java): `src/main/java/com/healthcare/repository/PrescriptionRepository.java`

### Other components

- **Hospital staff**
- **Doctor**
- **Patient**
- **Laboratory staff**
- **MySQL database**

## Connections

- Hospital staff → Hospital API: registers or logs in
- Hospital API → Hospital management: delegates to (evidence: `src/main/java/com/healthcare/controller/HospitalController.java`)
- Hospital management → MySQL database: manages records
- Hospital staff → Doctor API: registers doctors
- Doctor API → Doctor management: delegates to (evidence: `src/main/java/com/healthcare/service/DoctorService.java`)
- Doctor management → MySQL database: reads and writes
- Hospital staff → Laboratory API: registers laboratories
- Laboratory API → Laboratory management: manages laboratories
- Hospital staff → Patient API: lists patients
- Doctor → Patient API: registers patients
- Patient API → Patient management: delegates to (evidence: `src/main/java/com/healthcare/controller/PatientController.java`)
- Patient management → MySQL database: reads and writes
- Patient → Invitation API: invites a doctor (evidence: `src/main/java/com/healthcare/controller/PatientInvitationController.java`)
- Invitation API → Patient invitations: delegates to (evidence: `src/main/java/com/healthcare/controller/PatientInvitationController.java`)
- Doctor → Lab test API: requests a test
- Laboratory staff → Lab test API: submits results
- Lab test API → Lab test workflow: delegates to (evidence: `src/main/java/com/healthcare/controller/LabTestController.java`)
- Lab test workflow → Lab test records: queries and saves (evidence: `src/main/java/com/healthcare/service/LabTestService.java`)
- Lab test records → MySQL database: persists records
- Doctor → Prescription API: manages prescriptions
- Prescription API → Prescription management: delegates to
- Prescription management → Prescription records: queries and saves (evidence: `src/main/java/com/healthcare/service/PrescriptionService.java`)
- Patient → Medication history: views medication history
- Medication history → Prescription records: reads prescriptions (evidence: `src/main/java/com/healthcare/service/PatientMedicationHistoryService.java`)
- Prescription records → MySQL database: persists records
