# sujan-kulal26/smartcare-hms architecture

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

- Interactive diagram: https://gitdiagram.com/sujan-kulal26/smartcare-hms
- Repository: https://github.com/sujan-kulal26/smartcare-hms

## Overview

SmartCare HMS is a web-based hospital management system for patient and doctor records, appointments, billing, and reports. The principal workflow is staff using the web interface to manage records and appointments, then create bills and view revenue reports through the Express API. The backend separates route handlers, JWT/role middleware, and Mongoose models, with MongoDB as persistence. The excerpts show backend routing and model calls; frontend-to-API wiring is not shown, so those links are marked unverified.

Main entry points: [`backend/server.js`](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/server.js) (HTTP server), [`backend/routes/billingRoutes.js`](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/billingRoutes.js) (Billing and reports), [`backend/routes/patientRoutes.js`](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/patientRoutes.js) (Patient operations), [`backend/routes/doctorRoutes.js`](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/doctorRoutes.js) (Doctor operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_ui_app["App interface<br/>[app.js]"]
  node_ui_patients["Patient screens<br/>[patients.js]"]
  node_ui_doctors["Doctor screens<br/>[doctors.js]"]
  node_ui_appointments["Appointment screens<br/>[appointments.js]"]
  node_ui_billing["Billing screens<br/>[billing.js]"]
end

subgraph group_api["API routes"]
  node_server["HTTP server<br/>[server.js]"]
  node_auth_routes["Login and signup<br/>[authRoutes.js]"]
  node_patient_routes["Patient operations<br/>[patientRoutes.js]"]
  node_doctor_routes["Doctor operations<br/>[doctorRoutes.js]"]
  node_appointment_routes["Appointment operations"]
  node_billing_routes["Billing and reports<br/>[billingRoutes.js]"]
end

subgraph group_security["Access control"]
  node_jwt_auth["JWT validation<br/>[auth.js]"]
  node_role_check["Role authorization<br/>[role.js]"]
end

subgraph group_records["Domain records"]
  node_user_model["User records<br/>[User.js]"]
  node_patient_model["Patient records<br/>[Patient.js]"]
  node_doctor_model["Doctor records<br/>[Doctor.js]"]
  node_appointment_model["Appointment records<br/>[Appointment.js]"]
  node_billing_model["Billing records<br/>[Billing.js]"]
end

node_staff(("Hospital staff"))
node_mongodb[("MongoDB")]

node_staff -.->|"uses"| node_ui_app
node_ui_patients -.->|"requests"| node_patient_routes
node_ui_doctors -.->|"requests"| node_doctor_routes
node_ui_appointments -.->|"requests"| node_appointment_routes
node_ui_billing -.->|"requests"| node_billing_routes
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_patient_routes
node_server -->|"mounts"| node_doctor_routes
node_server -->|"mounts"| node_appointment_routes
node_server -->|"mounts"| node_billing_routes
node_server -->|"connects"| node_mongodb
node_auth_routes -->|"queries"| node_user_model
node_patient_routes -->|"queries"| node_patient_model
node_doctor_routes -->|"queries"| node_doctor_model
node_appointment_routes -->|"queries"| node_appointment_model
node_billing_routes -->|"queries"| node_billing_model
node_billing_routes -->|"loads appointment"| node_appointment_model
node_patient_routes -->|"checks token"| node_jwt_auth
node_doctor_routes -->|"checks token"| node_jwt_auth
node_appointment_routes -->|"checks token"| node_jwt_auth
node_billing_routes -->|"checks token"| node_jwt_auth
node_billing_routes -->|"guards reports"| node_role_check

click node_ui_app "https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/app.js"
click node_ui_patients "https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/patients.js"
click node_ui_doctors "https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/doctors.js"
click node_ui_appointments "https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/appointments.js"
click node_ui_billing "https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/billing.js"
click node_server "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/server.js"
click node_auth_routes "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/authRoutes.js"
click node_patient_routes "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/patientRoutes.js"
click node_doctor_routes "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/doctorRoutes.js"
click node_appointment_routes "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/appointmentRoutes.js"
click node_billing_routes "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/billingRoutes.js"
click node_jwt_auth "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/middleware/auth.js"
click node_role_check "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/middleware/role.js"
click node_user_model "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/User.js"
click node_patient_model "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Patient.js"
click node_doctor_model "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Doctor.js"
click node_appointment_model "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Appointment.js"
click node_billing_model "https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Billing.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_ui_app,node_ui_patients,node_ui_doctors,node_ui_appointments,node_ui_billing toneBlue
class node_server,node_auth_routes,node_patient_routes,node_doctor_routes,node_appointment_routes,node_billing_routes,node_mongodb toneAmber
class node_jwt_auth,node_role_check toneMint
class node_user_model,node_patient_model,node_doctor_model,node_appointment_model,node_billing_model toneRose
class node_staff toneIndigo
```

## Components

### Web interface

- [App interface](https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Patient screens](https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/patients.js): `frontend/js/patients.js`
- [Doctor screens](https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/doctors.js): `frontend/js/doctors.js`
- [Appointment screens](https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/appointments.js): `frontend/js/appointments.js`
- [Billing screens](https://github.com/sujan-kulal26/smartcare-hms/blob/main/frontend/js/billing.js): `frontend/js/billing.js`

### API routes

- [HTTP server](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/server.js): `backend/server.js`
- [Login and signup](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Patient operations](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/patientRoutes.js): `backend/routes/patientRoutes.js`
- [Doctor operations](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/doctorRoutes.js): `backend/routes/doctorRoutes.js`
- [Appointment operations](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/appointmentRoutes.js): `backend/routes/appointmentRoutes.js`
- [Billing and reports](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/routes/billingRoutes.js): `backend/routes/billingRoutes.js`

### Access control

- [JWT validation](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Role authorization](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/middleware/role.js): `backend/middleware/role.js`

### Domain records

- [User records](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/User.js): `backend/models/User.js`
- [Patient records](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Patient.js): `backend/models/Patient.js`
- [Doctor records](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Doctor.js): `backend/models/Doctor.js`
- [Appointment records](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Appointment.js): `backend/models/Appointment.js`
- [Billing records](https://github.com/sujan-kulal26/smartcare-hms/blob/main/backend/models/Billing.js): `backend/models/Billing.js`

### Other components

- **Hospital staff**
- **MongoDB**

## Connections

- Hospital staff → App interface: uses
- Patient screens → Patient operations: requests
- Doctor screens → Doctor operations: requests
- Appointment screens → Appointment operations: requests
- Billing screens → Billing and reports: requests
- HTTP server → Login and signup: mounts (evidence: `backend/server.js`)
- HTTP server → Patient operations: mounts (evidence: `backend/server.js`)
- HTTP server → Doctor operations: mounts (evidence: `backend/server.js`)
- HTTP server → Appointment operations: mounts (evidence: `backend/server.js`)
- HTTP server → Billing and reports: mounts (evidence: `backend/server.js`)
- HTTP server → MongoDB: connects (evidence: `backend/server.js`)
- Login and signup → User records: queries (evidence: `backend/routes/authRoutes.js`)
- Patient operations → Patient records: queries (evidence: `backend/routes/patientRoutes.js`)
- Doctor operations → Doctor records: queries (evidence: `backend/routes/doctorRoutes.js`)
- Appointment operations → Appointment records: queries (evidence: `backend/routes/appointmentRoutes.js`)
- Billing and reports → Billing records: queries (evidence: `backend/routes/billingRoutes.js`)
- Billing and reports → Appointment records: loads appointment (evidence: `backend/routes/billingRoutes.js`)
- Patient operations → JWT validation: checks token (evidence: `backend/routes/patientRoutes.js`)
- Doctor operations → JWT validation: checks token (evidence: `backend/routes/doctorRoutes.js`)
- Appointment operations → JWT validation: checks token (evidence: `backend/routes/appointmentRoutes.js`)
- Billing and reports → JWT validation: checks token (evidence: `backend/routes/billingRoutes.js`)
- Billing and reports → Role authorization: guards reports (evidence: `backend/routes/billingRoutes.js`)
