# kkshiteej-tiwari/hospital-management-system-mern architecture

> Architecture diagram of the GitHub repository kkshiteej-tiwari/hospital-management-system-mern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kkshiteej-tiwari/hospital-management-system-mern
- Repository: https://github.com/kkshiteej-tiwari/hospital-management-system-mern

## Overview

Meridian HMS is a role-based hospital management system: patients book appointments and access visit records and invoices; doctors manage schedules and clinical records; administrators manage staff, departments, appointments and billing. The frontend routes role-specific pages through a shared API client to an Express API, with MongoDB-backed domain data. README capabilities guide the unsampled branches; detailed service-to-model wiring is shown only where sampled source supports it.

Main entry points: [`backend/src/controllers`](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/controllers) (Resource controllers), [`frontend/src/routes/AppRouter.jsx`](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/routes/AppRouter.jsx) (Role-based routes), [`frontend/src/api`](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/api) (Resource API modules), [`frontend/src/App.jsx`](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/App.jsx) (React application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["React application<br/>[App.jsx]"]
  node_routing["Role-based routes<br/>[AppRouter.jsx]"]
  node_patientpages["Patient portal"]
  node_doctorpages["Doctor portal"]
  node_adminpages["Admin portal"]
  node_authpages["Sign-in and registration"]
  node_authstate["Authentication state<br/>[AuthContext.jsx]"]
  node_apiresources["Resource API modules"]
  node_httpclient["HTTP and token refresh<br/>[axiosClient.js]"]
end

subgraph group_api["API boundary"]
  node_expressapp["Express API<br/>[app.js]"]
  node_routes["Resource routes"]
  node_controllers["Resource controllers"]
  node_guards["Authentication and access guards"]
end

subgraph group_domain["Hospital workflows"]
  node_authservice["Authentication service<br/>[auth.service.js]"]
  node_appointments["Appointment scheduling"]
  node_medical["Clinical records"]
  node_billing["Billing and invoices<br/>[billing.service.js]"]
  node_rbac["Ownership enforcement<br/>[rbac.service.js]"]
end

subgraph group_data["Identity and data"]
  node_models["Domain models"]
  node_database[("MongoDB<br/>[db.js]")]
end

node_patient(("Patient"))
node_doctor(("Doctor"))
node_admin(("Administrator"))

node_patient -->|"uses"| node_webapp
node_doctor -->|"uses"| node_webapp
node_admin -->|"uses"| node_webapp
node_webapp -->|"renders"| node_routing
node_routing -->|"routes"| node_authpages
node_routing -->|"routes"| node_patientpages
node_routing -->|"routes"| node_doctorpages
node_routing -->|"routes"| node_adminpages
node_authpages -->|"uses"| node_authstate
node_patientpages -->|"requests"| node_apiresources
node_doctorpages -->|"requests"| node_apiresources
node_adminpages -->|"requests"| node_apiresources
node_authpages -->|"requests"| node_apiresources
node_apiresources -->|"uses"| node_httpclient
node_httpclient -->|"HTTP requests"| node_expressapp
node_expressapp -->|"dispatches"| node_routes
node_routes -->|"guards routes"| node_guards
node_routes -->|"dispatches"| node_controllers
node_controllers -->|"calls"| node_authservice
node_controllers -->|"calls"| node_appointments
node_controllers -->|"calls"| node_medical
node_controllers -->|"calls"| node_billing
node_controllers -->|"checks access"| node_rbac
node_authservice -->|"reads and writes"| node_models
node_controllers -->|"reads and writes"| node_models
node_models -->|"persists data"| node_database

click node_webapp "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/App.jsx"
click node_routing "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/routes/AppRouter.jsx"
click node_patientpages "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/patient"
click node_doctorpages "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/doctor"
click node_adminpages "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/admin"
click node_authpages "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/auth"
click node_authstate "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/context/AuthContext.jsx"
click node_apiresources "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/api"
click node_httpclient "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/api/axiosClient.js"
click node_expressapp "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/app.js"
click node_routes "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/routes"
click node_controllers "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/controllers"
click node_guards "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/middleware"
click node_authservice "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/auth.service.js"
click node_appointments "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/appointment.service.js"
click node_medical "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/medicalRecord.service.js"
click node_billing "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/billing.service.js"
click node_rbac "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/rbac.service.js"
click node_models "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/models"
click node_database "https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/config/db.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_webapp,node_routing,node_patientpages,node_doctorpages,node_adminpages,node_authpages,node_authstate,node_apiresources,node_httpclient toneBlue
class node_expressapp,node_routes,node_controllers,node_guards toneAmber
class node_authservice,node_appointments,node_medical,node_billing,node_rbac toneMint
class node_models,node_database toneRose
class node_patient,node_doctor,node_admin toneIndigo
```

## Components

### Web client

- [React application](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Role-based routes](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/routes/AppRouter.jsx): `frontend/src/routes/AppRouter.jsx`
- [Patient portal](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/patient): `frontend/src/pages/patient`
- [Doctor portal](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/doctor): `frontend/src/pages/doctor`
- [Admin portal](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Sign-in and registration](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/pages/auth): `frontend/src/pages/auth`
- [Authentication state](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Resource API modules](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/frontend/src/api): `frontend/src/api`
- [HTTP and token refresh](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/frontend/src/api/axiosClient.js): `frontend/src/api/axiosClient.js`

### API boundary

- [Express API](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/app.js): `backend/src/app.js`
- [Resource routes](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/routes): `backend/src/routes`
- [Resource controllers](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/controllers): `backend/src/controllers`
- [Authentication and access guards](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/middleware): `backend/src/middleware`

### Hospital workflows

- [Authentication service](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/auth.service.js): `backend/src/services/auth.service.js`
- [Appointment scheduling](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/appointment.service.js): `backend/src/services/appointment.service.js`
- [Clinical records](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/medicalRecord.service.js): `backend/src/services/medicalRecord.service.js`
- [Billing and invoices](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/billing.service.js): `backend/src/services/billing.service.js`
- [Ownership enforcement](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/services/rbac.service.js): `backend/src/services/rbac.service.js`

### Identity and data

- [Domain models](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/tree/main/backend/src/models): `backend/src/models`
- [MongoDB](https://github.com/kkshiteej-tiwari/hospital-management-system-mern/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### Other components

- **Patient**
- **Doctor**
- **Administrator**

## Connections

- Patient → React application: uses
- Doctor → React application: uses
- Administrator → React application: uses
- React application → Role-based routes: renders
- Role-based routes → Sign-in and registration: routes
- Role-based routes → Patient portal: routes
- Role-based routes → Doctor portal: routes
- Role-based routes → Admin portal: routes
- Sign-in and registration → Authentication state: uses
- Patient portal → Resource API modules: requests
- Doctor portal → Resource API modules: requests
- Admin portal → Resource API modules: requests
- Sign-in and registration → Resource API modules: requests
- Resource API modules → HTTP and token refresh: uses
- HTTP and token refresh → Express API: HTTP requests
- Express API → Resource routes: dispatches
- Resource routes → Authentication and access guards: guards routes
- Resource routes → Resource controllers: dispatches
- Resource controllers → Authentication service: calls
- Resource controllers → Appointment scheduling: calls
- Resource controllers → Clinical records: calls
- Resource controllers → Billing and invoices: calls
- Resource controllers → Ownership enforcement: checks access
- Authentication service → Domain models: reads and writes
- Resource controllers → Domain models: reads and writes
- Domain models → MongoDB: persists data
