1- # HMS Backend ( Node.js)
1+ Production-oriented Node.js backend for a Hospital Management System (HMS), built with structured role-based access control and real operational workflows in mind.
22
3- Open-source Node.js backend for a Hospital Management System (HMS), designed around real hospital workflows and production constraints.
4-
5- This repository contains ** only the Node.js / Express backend** .
3+ This repository contains ** only the backend API layer** built using Express and MongoDB.
64
75---
86
9- ## What’s Included
7+ ## Overview
108
11- * Node.js (Express) backend
12- * JWT-based authentication with Role-Based Access Control (RBAC)
13- * Core HMS APIs (Patient Registration, OPD, Basic IPD, Billing)
14- * MongoDB
15- * Security and validation middleware
16- * ** Docker & Docker Compose support for local development and deployment**
9+ The system supports:
1710
18- ---
11+ * Authentication with JWT
12+ * Role-Based Access Control (RBAC)
13+ * Doctor, Patient, Appointment management
14+ * Billing and Payment lifecycle
15+ * Admin analytics dashboard
16+ * Role-based reporting
17+ * Docker-based deployment
1918
20- ## Not Included
19+ The architecture follows a layered approach:
2120
22- * Java Spring Boot backend
23- * Advanced reporting and analytics
24- * Proprietary or hospital-specific business logic
21+ ```
22+ Routes → Controllers → Services → Models → MongoDB
23+ ```
2524
2625---
2726
28- ## Tech Stack
27+ ## Roles
28+
29+ The system supports the following roles:
30+
31+ * ** Admin (Superuser)**
32+ * ** Doctor**
33+ * ** Receptionist**
34+ * ** Billing Staff**
35+
36+ Access control is enforced at middleware level.
37+
38+ Detailed RBAC specification is available in:
2939
30- * ** Node.js** , ** Express**
31- * ** MongoDB**
32- * ` bcrypt ` , ` jsonwebtoken ` , ` helmet ` , ` cors `
33- * ` dotenv ` , ` morgan ` , ` express-validator `
34- * ** Docker** , ** Docker Compose**
40+ ```
41+ RBAC_SPEC.md
42+ ```
3543
3644---
3745
46+ ## Core Modules
47+
48+ * Authentication
49+ * User Management
50+ * Doctors
51+ * Patients
52+ * Departments
53+ * Appointments (with conflict prevention)
54+ * Billing (pending → paid lifecycle)
55+ * Payments
56+ * Admin Dashboard
57+ * Reports
58+
59+ ## Tech Stack
60+
61+ * Node.js
62+ * Express
63+ * MongoDB (Mongoose)
64+ * JWT Authentication
65+ * express-validator
66+ * Razorpay integration
67+ * Docker & Docker Compose
68+
3869## Project Structure
3970
4071```
4475 ├── services/
4576 ├── routes/
4677 ├── models/
47- ├── middlewares /
78+ ├── middleware /
4879 ├── utils/
4980 └── app.js
5081```
5182
5283---
5384
54- ## Authentication
85+ ## Key Features
86+
87+ ### Authentication
88+
89+ * JWT-based authentication
90+ * Bearer token authorization
91+ * Role enforcement middleware
92+
93+ ### Appointment Safety
5594
56- * JWT (HttpOnly cookies)
57- * Role-Based Access Control
95+ * Double-booking prevention
96+ * Status lifecycle enforcement
5897
59- Roles:
98+ ### Billing System
6099
61- * Admin
62- * Doctor
63- * Reception
64- * Billing staff
100+ * Amount tracking
101+ * Payment status (pending / paid)
102+ * Revenue aggregation
103+ * Financial reporting
65104
66- RBAC is enforced at the middleware level.
105+ ### Admin Dashboard
106+
107+ Provides:
108+
109+ * Total doctors
110+ * Total patients
111+ * Total appointments
112+ * Total revenue
113+ * Pending revenue
114+ * Today’s appointments
67115
68116---
69117
70118## Running the Project
71119
72- ### Option 1: Local Setup (Without Docker)
120+ ### Local Setup
73121
74122``` bash
75123git clone https://github.com/hms-int/hms-backend-node.git
@@ -87,72 +135,45 @@ http://localhost:5000
87135
88136---
89137
90- ### Option 2: Docker Compose (Recommended)
91-
92- The project now supports running the complete backend stack using ** Docker Compose** , including MongoDB.
93-
94- #### Prerequisites
95-
96- * Docker
97- * Docker Compose
98-
99- #### Steps
138+ ### Docker Setup
100139
101140``` bash
102- git clone https://github.com/hms-int/hms-backend-node.git
103- cd hms-backend-node
104- cp .env.example .env
105141docker compose up --build
106142```
107143
108- This will:
109-
110- * Build the Node.js backend image
111- * Start the API server
112- * Start MongoDB
113- * Configure internal networking between services
144+ This starts:
114145
115- Once running, the API will be available at:
116-
117- ```
118- http://localhost:5000
119- ```
146+ * Node.js backend
147+ * MongoDB
120148
121- To stop the containers :
149+ To stop:
122150
123151``` bash
124152docker compose down
125153```
126154
127155---
128156
129- ## API Design Principles
157+ ## API Principles
130158
131- * REST-based APIs
132- * Stateless services
133- * Validation at request entry points
134- * Business logic isolated in services
135- * Database access abstracted from controllers
159+ * REST-based
160+ * Stateless
161+ * Structured response format
162+ * Centralized error handling
163+ * Role-based route protection
136164
137165---
138166
139- ## Contributions
167+ ## Health Check
140168
141- Contributions are welcome and expected to follow basic discipline.
142-
143- * Fork the repository
144- * Create a feature or fix branch
145- * Make clear, atomic commits
146- * Open a Pull Request with a concise explanation
147-
148- Keep changes minimal, readable, and documented.
169+ ```
170+ GET /health
171+ ```
149172
150173---
151174
152- ## License & Disclaimer
153-
154- This repository is open source.
175+ ## License
155176
156- Closed -source and proprietary components are intentionally excluded .
177+ Open -source.
157178
158- Ensure compliance with local medical data protection and healthcare regulations before any production deployment.
179+ Ensure compliance with medical data regulations before production deployment.
0 commit comments