# tan123-del/hospital-backend architecture

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

- Interactive diagram: https://gitdiagram.com/tan123-del/hospital-backend
- Repository: https://github.com/tan123-del/hospital-backend

## Overview

Smart Hospital Network is a multi-role hospital discovery and operations application. The visible product surfaces are the main React app and separate patient, hospital-staff, and admin dashboards; backend capabilities include account verification and login, hospital records, appointments, live queues, and platform administration. The backend server mounts these route modules, which perform operations on MongoDB models. The main app and most dashboard source were not excerpted, so frontend-to-API calls and dashboard-specific flows are not asserted; the README describes only the Vite template.

Main entry points: [`backend/server.js`](https://github.com/tan123-del/hospital-backend/blob/main/backend/server.js) (API server), [`backend/routes/adminRoutes.js`](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/adminRoutes.js) (Admin operations), [`src/App.jsx`](https://github.com/tan123-del/hospital-backend/blob/main/src/App.jsx) (React app), [`backend/routes/authRoutes.js`](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/authRoutes.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["React app<br/>[App.jsx]"]
  node_patient["Patient dashboard"]
  node_staff["Staff dashboard"]
  node_adminui["Admin dashboard<br/>[AdminDashboard.jsx]"]
end

subgraph group_api["Backend API"]
  node_server["API server<br/>[server.js]"]
  node_auth["Authentication<br/>[authRoutes.js]"]
  node_userrecords[("User records<br/>[User.js]")]
end

subgraph group_care["Care operations"]
  node_hospitals["Hospital directory<br/>[hospitalRoutes.js]"]
  node_appointments["Appointments"]
  node_queue["Live queue<br/>[QueueRoutes.js]"]
  node_hospitalrecords[("Hospital records<br/>[Hospital.js]")]
  node_appointmentrecords[("Appointment records<br/>[Appointment.js]")]
  node_queuerecords[("Queue records<br/>[Queue.js]")]
end

subgraph group_admin["Platform administration"]
  node_administration["Admin operations<br/>[adminRoutes.js]"]
  node_auditrecords[("Audit records<br/>[auditlog.js]")]
end

node_user(("User"))
node_resend["Resend email"]
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_app
node_app -.-> node_patient
node_app -.-> node_staff
node_app -.-> node_adminui
node_server -->|"mounts"| node_auth
node_server -->|"mounts"| node_hospitals
node_server -->|"mounts"| node_queue
node_server -->|"mounts"| node_appointments
node_server -->|"mounts"| node_administration
node_auth -->|"reads and writes"| node_userrecords
node_auth -->|"reads and writes"| node_hospitalrecords
node_auth -->|"sends verification"| node_resend
node_hospitals -->|"reads and writes"| node_hospitalrecords
node_appointments -->|"reads and writes"| node_appointmentrecords
node_queue -->|"reads and writes"| node_queuerecords
node_queue -->|"updates counts"| node_hospitalrecords
node_administration -->|"reads and updates"| node_userrecords
node_administration -->|"reads and updates"| node_hospitalrecords
node_administration -->|"counts"| node_appointmentrecords
node_administration -->|"writes and reads"| node_auditrecords
node_server -->|"connects"| node_mongodb

click node_app "https://github.com/tan123-del/hospital-backend/blob/main/src/App.jsx"
click node_patient "https://github.com/tan123-del/hospital-backend/blob/main/src/pages/PatientDashboard.jsx"
click node_staff "https://github.com/tan123-del/hospital-backend/blob/main/src/pages/HospitalStaffDashboard.jsx"
click node_adminui "https://github.com/tan123-del/hospital-backend/blob/main/src/pages/AdminDashboard.jsx"
click node_server "https://github.com/tan123-del/hospital-backend/blob/main/backend/server.js"
click node_auth "https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/authRoutes.js"
click node_hospitals "https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/hospitalRoutes.js"
click node_appointments "https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/appointmentRoutes.js"
click node_queue "https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/QueueRoutes.js"
click node_administration "https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/adminRoutes.js"
click node_userrecords "https://github.com/tan123-del/hospital-backend/blob/main/backend/models/User.js"
click node_hospitalrecords "https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Hospital.js"
click node_appointmentrecords "https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Appointment.js"
click node_queuerecords "https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Queue.js"
click node_auditrecords "https://github.com/tan123-del/hospital-backend/blob/main/backend/models/auditlog.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_app,node_patient,node_staff,node_adminui,node_user toneBlue
class node_server,node_auth,node_userrecords,node_mongodb toneAmber
class node_hospitals,node_appointments,node_queue,node_hospitalrecords,node_appointmentrecords,node_queuerecords toneMint
class node_administration,node_auditrecords toneRose
class node_resend toneIndigo
```

## Components

### Web application

- [React app](https://github.com/tan123-del/hospital-backend/blob/main/src/App.jsx): `src/App.jsx`
- [Patient dashboard](https://github.com/tan123-del/hospital-backend/blob/main/src/pages/PatientDashboard.jsx): `src/pages/PatientDashboard.jsx`
- [Staff dashboard](https://github.com/tan123-del/hospital-backend/blob/main/src/pages/HospitalStaffDashboard.jsx): `src/pages/HospitalStaffDashboard.jsx`
- [Admin dashboard](https://github.com/tan123-del/hospital-backend/blob/main/src/pages/AdminDashboard.jsx): `src/pages/AdminDashboard.jsx`

### Backend API

- [API server](https://github.com/tan123-del/hospital-backend/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [User records](https://github.com/tan123-del/hospital-backend/blob/main/backend/models/User.js): `backend/models/User.js`

### Care operations

- [Hospital directory](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/hospitalRoutes.js): `backend/routes/hospitalRoutes.js`
- [Appointments](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/appointmentRoutes.js): `backend/routes/appointmentRoutes.js`
- [Live queue](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/QueueRoutes.js): `backend/routes/QueueRoutes.js`
- [Hospital records](https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Hospital.js): `backend/models/Hospital.js`
- [Appointment records](https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Appointment.js): `backend/models/Appointment.js`
- [Queue records](https://github.com/tan123-del/hospital-backend/blob/main/backend/models/Queue.js): `backend/models/Queue.js`

### Platform administration

- [Admin operations](https://github.com/tan123-del/hospital-backend/blob/main/backend/routes/adminRoutes.js): `backend/routes/adminRoutes.js`
- [Audit records](https://github.com/tan123-del/hospital-backend/blob/main/backend/models/auditlog.js): `backend/models/auditlog.js`

### Other components

- **User**
- **Resend email**
- **MongoDB**

## Connections

- User → React app: uses
- React app → Patient dashboard
- React app → Staff dashboard
- React app → Admin dashboard
- API server → Authentication: mounts (evidence: `backend/server.js`)
- API server → Hospital directory: mounts (evidence: `backend/server.js`)
- API server → Live queue: mounts (evidence: `backend/server.js`)
- API server → Appointments: mounts (evidence: `backend/server.js`)
- API server → Admin operations: mounts (evidence: `backend/server.js`)
- Authentication → User records: reads and writes (evidence: `backend/routes/authRoutes.js`)
- Authentication → Hospital records: reads and writes (evidence: `backend/routes/authRoutes.js`)
- Authentication → Resend email: sends verification (evidence: `backend/routes/authRoutes.js`)
- Hospital directory → Hospital records: reads and writes (evidence: `backend/routes/hospitalRoutes.js`)
- Appointments → Appointment records: reads and writes (evidence: `backend/routes/appointmentRoutes.js`)
- Live queue → Queue records: reads and writes (evidence: `backend/routes/QueueRoutes.js`)
- Live queue → Hospital records: updates counts (evidence: `backend/routes/QueueRoutes.js`)
- Admin operations → User records: reads and updates (evidence: `backend/routes/adminRoutes.js`)
- Admin operations → Hospital records: reads and updates (evidence: `backend/routes/adminRoutes.js`)
- Admin operations → Appointment records: counts (evidence: `backend/routes/adminRoutes.js`)
- Admin operations → Audit records: writes and reads (evidence: `backend/routes/adminRoutes.js`)
- API server → MongoDB: connects (evidence: `backend/server.js`)
