# thathsarabandara/healthsphereproject- architecture

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

- Interactive diagram: https://gitdiagram.com/thathsarabandara/healthsphereproject-
- Repository: https://github.com/thathsarabandara/healthsphereproject-

## Overview

HealthSphere is a hospital-management web application for patients, doctors, and administrators. The evidenced patient journey enters through the React router, where patients can browse doctors, request reservations, and access accounts, payments, and prescriptions; the README documents further lab and pharmacy services. Separate doctor and admin areas support clinical work and system operations. The server exposes role-oriented REST routes and uses controllers, authentication middleware, Sequelize models, and MySQL. Edges reflect the sampled router, server entry point, controller reference index, and model imports; unsampled route wiring is not inferred.

Main entry points: [`server/controllers/Patients`](https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Patients) (Patient workflows), [`client/src/App.js`](https://github.com/thathsarabandara/healthsphereproject-/blob/main/client/src/App.js) (React router), [`server/config/db.js`](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/config/db.js) (MySQL database), [`server/index.js`](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/index.js) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_react_app["React router<br/>[App.js]"]
  node_patient_ui["Patient services"]
  node_doctor_ui["Doctor workspace"]
  node_admin_ui["Admin console"]
end

subgraph group_api["Server API"]
  node_patient_routes["Patient routes<br/>[patients.js]"]
  node_doctor_routes["Doctor routes<br/>[doctors.js]"]
  node_admin_routes["Admin routes<br/>[admins.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_server_entry["Express application<br/>[index.js]"]
end

subgraph group_identity["Identity and security"]
  node_auth_logic["Authentication<br/>[AuthController.js]"]
  node_access_control["Role access"]
end

subgraph group_care["Clinical operations"]
  node_patient_logic["Patient workflows"]
  node_doctor_logic["Doctor workflows"]
  node_admin_logic["Admin workflows"]
  node_payment_logic["Payments and refunds"]
end

subgraph group_data["Persistence and messaging"]
  node_mysql[("MySQL database<br/>[db.js]")]
  node_user_model["User accounts<br/>[User.js]"]
  node_token_model["Session tokens<br/>[Token.js]"]
  node_patient_model["Patient records<br/>[Patient.js]"]
  node_doctor_model["Doctor records<br/>[Doctor.js]"]
  node_schedule_model["Schedules<br/>[Schedule.js]"]
  node_reservation_model["Reservations<br/>[Reservation.js]"]
  node_email_service["Email notifications<br/>[emailServices.js]"]
end

node_patient(("Patient"))
node_doctor_actor(("Doctor"))
node_admin_actor(("Administrator"))
node_mail_provider{{"Email transport"}}

node_patient -->|"uses"| node_react_app
node_doctor_actor -->|"uses"| node_react_app
node_admin_actor -->|"uses"| node_react_app
node_react_app -->|"routes to"| node_patient_ui
node_react_app -->|"routes to"| node_doctor_ui
node_react_app -->|"routes to"| node_admin_ui
node_server_entry -->|"mounts"| node_patient_routes
node_server_entry -->|"mounts"| node_doctor_routes
node_server_entry -->|"mounts"| node_admin_routes
node_server_entry -->|"mounts"| node_auth_routes
node_patient_routes -.->|"dispatches"| node_patient_logic
node_doctor_routes -.->|"dispatches"| node_doctor_logic
node_admin_routes -.->|"dispatches"| node_admin_logic
node_auth_routes -->|"dispatches"| node_auth_logic
node_patient_logic -->|"uses records"| node_patient_model
node_patient_logic -->|"queries"| node_doctor_model
node_patient_logic -->|"uses schedules"| node_schedule_model
node_patient_logic -->|"uses bookings"| node_reservation_model
node_patient_logic -->|"handles payment"| node_payment_logic
node_doctor_logic -->|"queries"| node_doctor_model
node_admin_logic -->|"manages"| node_doctor_model
node_admin_logic -->|"manages"| node_patient_model
node_admin_logic -->|"uses schedules"| node_schedule_model
node_auth_logic -->|"finds users"| node_user_model
node_auth_logic -->|"creates tokens"| node_token_model
node_access_control -->|"checks tokens"| node_token_model
node_user_model -->|"persists"| node_mysql
node_token_model -->|"persists"| node_mysql
node_patient_model -->|"persists"| node_mysql
node_doctor_model -->|"persists"| node_mysql
node_schedule_model -->|"persists"| node_mysql
node_reservation_model -->|"persists"| node_mysql
node_payment_logic -->|"sends notices"| node_email_service
node_email_service -->|"sends mail"| node_mail_provider

click node_react_app "https://github.com/thathsarabandara/healthsphereproject-/blob/main/client/src/App.js"
click node_patient_ui "https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/User"
click node_doctor_ui "https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/doctor"
click node_admin_ui "https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/admin"
click node_patient_routes "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/patients.js"
click node_doctor_routes "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/doctors.js"
click node_admin_routes "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/admins.js"
click node_auth_routes "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/auth.js"
click node_patient_logic "https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Patients"
click node_doctor_logic "https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Doctors"
click node_admin_logic "https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Admins"
click node_auth_logic "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/controllers/auth/AuthController.js"
click node_access_control "https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/middleware/auth"
click node_mysql "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/config/db.js"
click node_user_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/auth/User.js"
click node_token_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/auth/Token.js"
click node_patient_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Patient.js"
click node_doctor_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Doctor.js"
click node_schedule_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Schedule.js"
click node_reservation_model "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Reservation.js"
click node_payment_logic "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/controllers/Patients/paymentController.js"
click node_email_service "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/services/emailServices.js"
click node_server_entry "https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/index.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_react_app,node_patient_ui,node_doctor_ui,node_admin_ui toneBlue
class node_patient_routes,node_doctor_routes,node_admin_routes,node_auth_routes,node_server_entry toneAmber
class node_auth_logic,node_access_control toneMint
class node_patient_logic,node_doctor_logic,node_admin_logic,node_payment_logic toneRose
class node_mysql,node_user_model,node_token_model,node_patient_model,node_doctor_model,node_schedule_model,node_reservation_model,node_email_service,node_patient,node_doctor_actor,node_admin_actor,node_mail_provider toneIndigo
```

## Components

### Web application

- [React router](https://github.com/thathsarabandara/healthsphereproject-/blob/main/client/src/App.js): `client/src/App.js`
- [Patient services](https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/User): `client/src/pages/User`
- [Doctor workspace](https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/doctor): `client/src/pages/doctor`
- [Admin console](https://github.com/thathsarabandara/healthsphereproject-/tree/main/client/src/pages/admin): `client/src/pages/admin`

### Server API

- [Patient routes](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/patients.js): `server/routes/patients.js`
- [Doctor routes](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/doctors.js): `server/routes/doctors.js`
- [Admin routes](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/admins.js): `server/routes/admins.js`
- [Auth routes](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Express application](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/index.js): `server/index.js`

### Identity and security

- [Authentication](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/controllers/auth/AuthController.js): `server/controllers/auth/AuthController.js`
- [Role access](https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/middleware/auth): `server/middleware/auth`

### Clinical operations

- [Patient workflows](https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Patients): `server/controllers/Patients`
- [Doctor workflows](https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Doctors): `server/controllers/Doctors`
- [Admin workflows](https://github.com/thathsarabandara/healthsphereproject-/tree/main/server/controllers/Admins): `server/controllers/Admins`
- [Payments and refunds](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/controllers/Patients/paymentController.js): `server/controllers/Patients/paymentController.js`

### Persistence and messaging

- [MySQL database](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/config/db.js): `server/config/db.js`
- [User accounts](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/auth/User.js): `server/models/auth/User.js`
- [Session tokens](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/auth/Token.js): `server/models/auth/Token.js`
- [Patient records](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Patient.js): `server/models/healthcare/Patient.js`
- [Doctor records](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Doctor.js): `server/models/healthcare/Doctor.js`
- [Schedules](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Schedule.js): `server/models/healthcare/Schedule.js`
- [Reservations](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/models/healthcare/Reservation.js): `server/models/healthcare/Reservation.js`
- [Email notifications](https://github.com/thathsarabandara/healthsphereproject-/blob/main/server/services/emailServices.js): `server/services/emailServices.js`

### Other components

- **Patient**
- **Doctor**
- **Administrator**
- **Email transport**

## Connections

- Patient → React router: uses
- Doctor → React router: uses
- Administrator → React router: uses
- React router → Patient services: routes to (evidence: `client/src/App.js`)
- React router → Doctor workspace: routes to (evidence: `client/src/App.js`)
- React router → Admin console: routes to (evidence: `client/src/App.js`)
- Express application → Patient routes: mounts (evidence: `server/index.js`)
- Express application → Doctor routes: mounts (evidence: `server/index.js`)
- Express application → Admin routes: mounts (evidence: `server/index.js`)
- Express application → Auth routes: mounts (evidence: `server/index.js`)
- Patient routes → Patient workflows: dispatches
- Doctor routes → Doctor workflows: dispatches
- Admin routes → Admin workflows: dispatches
- Auth routes → Authentication: dispatches (evidence: `server/routes/auth.js`)
- Patient workflows → Patient records: uses records (evidence: `server/controllers/Patients/conditionController.js`)
- Patient workflows → Doctor records: queries (evidence: `server/controllers/Patients/paymentController.js`)
- Patient workflows → Schedules: uses schedules (evidence: `server/controllers/Patients/paymentController.js`)
- Patient workflows → Reservations: uses bookings (evidence: `server/controllers/Patients/paymentController.js`)
- Patient workflows → Payments and refunds: handles payment
- Doctor workflows → Doctor records: queries (evidence: `server/controllers/Doctors/loginController.js`)
- Admin workflows → Doctor records: manages (evidence: `server/controllers/Admins/doctorAndStaffManagementController.js`)
- Admin workflows → Patient records: manages (evidence: `server/controllers/Admins/patientmanagementcontroller.js`)
- Admin workflows → Schedules: uses schedules (evidence: `server/controllers/Admins/doctorAndStaffManagementController.js`)
- Authentication → User accounts: finds users (evidence: `server/controllers/auth/AuthController.js`)
- Authentication → Session tokens: creates tokens (evidence: `server/controllers/auth/AuthController.js`)
- Role access → Session tokens: checks tokens (evidence: `server/middleware/auth/authorizeDoctor.js`)
- User accounts → MySQL database: persists (evidence: `server/models/auth/User.js`)
- Session tokens → MySQL database: persists (evidence: `server/models/auth/Token.js`)
- Patient records → MySQL database: persists (evidence: `server/models/healthcare/Patient.js`)
- Doctor records → MySQL database: persists (evidence: `server/models/healthcare/Doctor.js`)
- Schedules → MySQL database: persists (evidence: `server/models/healthcare/Schedule.js`)
- Reservations → MySQL database: persists (evidence: `server/models/healthcare/Reservation.js`)
- Payments and refunds → Email notifications: sends notices (evidence: `server/controllers/Patients/paymentController.js`)
- Email notifications → Email transport: sends mail (evidence: `server/services/emailServices.js`)
