https://github.com/flexycode/healthcare-management-system
๐ค Heathcare Management System
https://github.com/flexycode/healthcare-management-system
express information-security javascript mern-stack mongodb nodejs software-engineering
Last synced: 16 days ago
JSON representation
๐ค Heathcare Management System
- Host: GitHub
- URL: https://github.com/flexycode/healthcare-management-system
- Owner: flexycode
- License: mit
- Created: 2025-12-05T02:05:07.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-02-16T14:13:52.000Z (2 months ago)
- Last Synced: 2026-02-16T22:09:01.969Z (2 months ago)
- Topics: express, information-security, javascript, mern-stack, mongodb, nodejs, software-engineering
- Language: JavaScript
- Homepage:
- Size: 1.94 MB
- Stars: 4
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: docs/SECURITY_AUDIT_REPORT.md
Awesome Lists containing this project
README
# ๐ฅ Healthcare Management System
A comprehensive, full-stack platform for managing patient records, appointments, and medical billing โ built with modern web technologies and enterprise-grade security features.
---
## ๐ Table of Contents
- [Features](#-features)
- [Screenshots](#-screenshots)
- [Frontend UI](#-frontend-ui)
- [Backend โ Data Management](#-backend--data-management)
- [Database โ MongoDB Atlas](#-database--mongodb-atlas)
- [Tech Stack](#๏ธ-tech-stack)
- [Getting Started](#-getting-started)
- [Prerequisites](#-prerequisites)
- [Installation](#-installation)
- [Environment Setup](#๏ธ-environment-setup)
- [Seed Database](#-seed-database)
- [Run Application](#๏ธ-run-application)
- [Access Points](#-access-points)
- [Default Login Credentials](#-default-login-credentials)
- [MongoDB Atlas Setup](#๏ธ-mongodb-atlas-setup)
- [API Documentation](#-api-documentation)
- [Authentication](#-authentication)
- [Patients](#-patients)
- [Appointments](#-appointments)
- [Billing](#-billing)
- [Security Features](#-security-features)
- [Project Structure](#-project-structure)
- [Troubleshooting](#-troubleshooting)
- [Changelog](#-changelog)
- [Contributing](#-contributing)
- [Contributors](#-contributors)
- [License](#-license)
---
## โจ Features
| Feature | Description |
|---------|-------------|
| ๐ฅ **Patient Management** | Full CRUD operations for patient records with search and filtering |
| ๐
**Appointment Scheduling** | Schedule, manage, and track appointments with doctor assignment |
| ๐ฐ **Billing & Invoices** | Generate invoices with line items, track payment status (Pending/Paid) |
| ๐ **Role-Based Access Control** | Granular permissions for Admin, Doctor, and Staff roles |
| ๐ซ **JWT Authentication** | Secure token-based authentication with session management |
| ๐ก๏ธ **Admin Token Gate** | Registration requires a valid admin token to prevent unauthorized signups |
| โฑ๏ธ **Rate Limiting** | Brute-force protection on login and registration endpoints |
| โ
**Input Validation** | Server-side validation with detailed error messages on all endpoints |
| ๐ **Environment Config** | Centralized API URL management via environment variables |
| ๐จ **Modern Dark UI** | Responsive dark sidebar with teal accents and smooth animations |
---
## ๐ธ Screenshots
### ๐ฅ๏ธ Frontend UI
#### Login Page
*Clean, minimal authentication interface with username/password fields and registration link.*
#### Dashboard Overview
*Admin dashboard displaying real-time statistics, quick actions, upcoming appointments, and recent patients.*
#### Appointments Management
*View all scheduled appointments with patient details, dates, status badges, and inline edit/delete actions.*
---
### ๐ Backend โ Data Management
#### Patient Management
*Tabular patient records with search by name/contact. Supports full CRUD with add, edit, and delete actions.*
#### Add New Patient Modal
*Detailed patient registration form capturing full name, age, gender, contact, address, and medical history.*
#### Schedule Appointment Modal
*Appointment booking with patient/doctor dropdowns, date-time picker, and reason field.*
#### Create Invoice Modal
*Invoice creation with dynamic line items, auto-calculated total, and patient selection.*
#### Billing & Invoices โ List View
*Invoice management dashboard with summary cards (Total, Pending, Paid) and status tracking per patient.*
---
### ๐๏ธ Database โ MongoDB Atlas
#### Billing Record (Single Invoice)
*Individual invoice record showing patient name, amount, status badge, date, and action buttons.*
#### Patient Records (2 Entries)
*Patient collection with structured columns: Name, Age, Gender, Contact, and CRUD actions.*
#### Appointments List (Full Data)
*Complete appointments view with all scheduled check-ups, dates, and status badges.*
#### Dashboard (Initial State)
*Fresh dashboard with single patient record and no appointments โ demonstrating clean initial state.*
---
## ๐ ๏ธ Tech Stack
| Layer | Technologies |
|-------|-------------|
| **Frontend** | React, Vite, TailwindCSS, Framer Motion |
| **Backend** | Node.js, Express, MongoDB, Mongoose ODM |
| **Auth** | JWT, bcrypt, RBAC (Admin, Doctor, Staff) |
| **Security** | express-rate-limit, express-validator, Admin Token Gate |
| **Dev Tools** | nodemon, dotenv, cors |
---
## ๐ Getting Started
### ๐ Prerequisites
- Node.js (v18+)
- MongoDB Atlas account (or local MongoDB)
- npm or yarn
### ๐ฆ Installation
```bash
# Clone repository
git clone
cd Healthcare-management-system
# Install server dependencies
cd server && npm install
# Install client dependencies
cd ../client && npm install
```
### โ๏ธ Environment Setup
Create `server/.env`:
```env
PORT=5000
MONGO_URI=mongodb+srv://:@cluster0.xxxxx.mongodb.net/hms_db?appName=Cluster0
JWT_SECRET=your_jwt_secret_key_here
ADMIN_REGISTER_TOKEN=hms_admin_register_2024_!@#
```
Create `client/.env`:
```env
VITE_API_URL=http://localhost:5000/api
```
> โ ๏ธ **Important:** Both `.env` files are excluded from version control via `.gitignore`.
### ๐ฑ Seed Database
```bash
cd server
node seed.js
```
### โถ๏ธ Run Application
| Terminal | Command | Directory |
|----------|---------|-----------|
| 1๏ธโฃ Server | `npm run dev` | `/server` |
| 2๏ธโฃ Client | `npm run dev` | `/client` |
### ๐ Access Points
| Service | URL |
|---------|-----|
| ๐ฅ๏ธ Frontend | http://localhost:5173 |
| โก Backend API | http://localhost:5000 |
---
## ๐ Default Login Credentials
| Username | Password | Role |
|----------|----------|------|
| `admin` | `password123` | ๐ Admin |
| `doctor` | `password123` | ๐ฉบ Doctor |
| `staff` | `password123` | ๐ค Staff |
> ๐ก Run `node seed.js` in the server folder to create these users.
---
## โ๏ธ MongoDB Atlas Setup
1. ๐ Create account at [mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas)
2. ๐๏ธ Create a free M0 cluster
3. ๐ค **Database Access**: Add a database user with read/write permissions
4. ๐ **Network Access**: Whitelist your IP (or `0.0.0.0/0` for development)
5. ๐ **Connect**: Get connection string and update `server/.env`
> โ ๏ธ **Important:** Add `/hms_db` to the connection string before the `?` to specify the database name.
---
## ๐ก API Documentation
### ๐ Authentication
| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/auth/register` | Register new user *(requires `x-admin-token` header)* |
| POST | `/api/auth/login` | Login user *(rate-limited: 10 req/15 min)* |
### ๐ฅ Patients
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/patients` | Get all patients |
| POST | `/api/patients` | Create patient *(validated: name, age, gender, contact)* |
| PUT | `/api/patients/:id` | Update patient |
| DELETE | `/api/patients/:id` | Delete patient |
### ๐
Appointments
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/appointments` | Get all appointments |
| POST | `/api/appointments` | Create appointment *(validated: patient, doctor, date)* |
| PUT | `/api/appointments/:id` | Update appointment |
| DELETE | `/api/appointments/:id` | Delete appointment |
### ๐ณ Billing
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/billing` | Get all invoices |
| POST | `/api/billing` | Create invoice *(validated: patient, amount, status)* |
| PUT | `/api/billing/:id` | Update invoice |
| DELETE | `/api/billing/:id` | Delete invoice |
---
## ๐ก๏ธ Security Features
| Feature | Description |
|---------|-------------|
| **Admin Token Registration** | User registration requires a valid `x-admin-token` header (configured in `server/.env`) |
| **Rate Limiting** | Login: 10 req/15 min ยท Registration: 5 req/15 min per IP |
| **Input Validation** | `express-validator` schemas on all endpoints with detailed error messages |
| **JWT Authentication** | Secure token-based auth with expiration |
| **Role-Based Access** | 3 roles (Admin, Doctor, Staff) with granular permissions |
| **Password Hashing** | bcrypt with salt rounds for secure password storage |
| **Environment Variables** | All secrets isolated in `.env` files (not committed to repo) |
> ๐ก **Admin Token:** Share the `ADMIN_REGISTER_TOKEN` only with authorized personnel who need to create new user accounts.
---
## ๐ Project Structure
```
Healthcare-management-system/
โโโ client/ # React + Vite frontend
โ โโโ src/
โ โ โโโ components/ # Reusable UI components (Sidebar, Layout)
โ โ โโโ config/ # API URL configuration
โ โ โโโ context/ # Auth context (login, register, token)
โ โ โโโ pages/ # Page components (Dashboard, Patients, etc.)
โ โโโ .env # Client environment variables
โ โโโ package.json
โโโ server/ # Node.js + Express backend
โ โโโ controllers/ # Route handlers (auth, patients, etc.)
โ โโโ middleware/ # Auth, rate limiting, validation
โ โโโ models/ # Mongoose schemas (User, Patient, etc.)
โ โโโ routes/ # API route definitions
โ โโโ seed.js # Database seeder for default users
โ โโโ .env # Server environment variables
โ โโโ package.json
โโโ assets/ # Screenshots and design references
โ โโโ Web Application Screen Designs/
โ โโโ Web Application UI/
โ โโโ Database Development/
โโโ README.md
```
---
## ๐ง Troubleshooting
| Error | Solution |
|-------|----------|
| `ECONNREFUSED` | MongoDB not running. Check Atlas connection or start local MongoDB |
| `Authentication failed` | Verify username/password in `server/.env` |
| `IP not whitelisted` | Add your IP in Atlas โ Network Access |
| `User not found` | Run `node seed.js` to create default users |
| `403 - Registration requires admin token` | Provide valid `ADMIN_REGISTER_TOKEN` in the registration form |
| `429 - Too many requests` | Rate limit reached. Wait 15 minutes before retrying |
| `400 - Validation errors` | Check request body matches required field formats |
---
## ๐ Changelog
### v1.2.0 (2026-02-16) โ Security Hardening & Input Validation
- **๐ Security**
- Implemented admin token authentication gate for user registration (`x-admin-token` header)
- Added `express-rate-limit` for login (10 req/15 min) and registration (5 req/15 min)
- Created comprehensive input validation with `express-validator` for all API endpoints
- **โจ Features**
- Environment-based API URL configuration with `VITE_API_URL`
- Centralized API config module at `client/src/config/api.js`
- Admin Token field added to the registration UI form
- **๐ง Middleware**
- New: `rateLimiter.js` โ Rate limiting middleware for auth routes
- New: `validators.js` โ Schema validation for auth, patients, appointments, billing
- New: `handleValidation.js` โ Unified validation error response handler
- **๐ Configuration**
- Added `ADMIN_REGISTER_TOKEN` to server environment variables
- Added `VITE_API_URL` to client environment variables
---
### v1.1.0 (2026-01-30) โ Database Integration & Full UI Implementation
- **๐๏ธ Database**
- Connected MongoDB Atlas with production cluster configuration
- Implemented 4 core collections: Users, Patients, Appointments, Invoices
- Added seed script (`seed.js`) for default user accounts
- **๐ธ Documentation**
- Captured frontend UI screenshots (Login, Dashboard, Appointments)
- Captured database/backend screenshots (Patient Management, Billing, Modals)
- Documented MongoDB Atlas setup process
- **๐จ UI Enhancements**
- Finalized responsive design across all dashboard views
- Implemented patient search functionality with real-time filtering
- Enhanced billing invoice management with dynamic line items
- Added appointment scheduling modal with doctor/patient dropdowns
---
### v1.0.1 (2026-01-12) โ UI/UX Modernization
- **๐ Design**
- Implemented modern dark sidebar theme (`Slate-900`) to reduce eye strain
- Added `Teal-400` accents for active navigation states
- Updated main content background to `Slate-50` for better contrast
- **๐ง Fixes**
- Resolved UI brightness uniformity issues
- Improved navigation link visibility and hover states
- Reference: *User Feedback โ "Left side is too bright"*
---
### v1.0.0 (2026-01-05) โ Initial Release
- **๐ Core Features**
- Patient management with full CRUD operations
- Appointment scheduling system with date/time and doctor assignment
- Billing and invoice generation with line items
- JWT-based authentication with token management
- Role-based access control (Admin, Doctor, Staff)
- **๐๏ธ Architecture**
- React frontend with Vite build tool and hot module replacement
- Express backend with RESTful API design
- MongoDB database with Mongoose ODM
- TailwindCSS + Framer Motion for responsive UI animations
- **๐ฆ Initial Setup**
- Project structure, dependencies, and scripts
- Development server with nodemon auto-restart
- Basic README documentation
---
## โจ Screenshots
---
## ๐ค Contributing
Contributions are welcome!
1. ๐ด Fork the repository
2. ๐ฟ Create a feature branch (`git checkout -b feature/AmazingFeature`)
3. ๐พ Commit your changes (`git commit -m 'Add AmazingFeature'`)
4. ๐ค Push to the branch (`git push origin feature/AmazingFeature`)
5. ๐ Open a Pull Request
### ๐ Contributors
### Special thanks to all my groupmates:
* #### ๐ [Jay Arre Talosig](https://github.com/flexycode) - Machine Learning Engineer | Blockchain Developer | Bioinformatics Scientist
* #### ๐ต๏ธ [Alexander Castilo](https://github.com/xandercastillo0305-dev) - Penetration Tester | Software Engineer | Threat Researcher
* #### ๐งโ๐ป [Mark Jhoshua Taberna](https://github.com/MjTaberna) - Digital Forensics Analyst | UI Specialist | Full Stack Engineer
* #### ๐งโ๐ป [Charles Medio](https://github.com/charles41onlyy) - Machine Learning Engineer | Software Engineer
* #### ๐ต๏ธ [Tristan Jhay Salamat](https://github.com/tristanjhay) - Full Stack Engineer | Forensics Analyst | QA Engineer
* #### ๐ต๏ธโโ๏ธ [Rinoah Venedict Dela Rama](https://github.com/Noah-dev2217) - Forensic Analyst | QA Engineer | Data Engineer
* #### ๐ฅท [Nicko Nehcterg Dalida](https://github.com/nicknicndin) - Digital Forensics Analyst | QA Engineer | Smart Contract Auditor
---
## ๐ License
This project is licensed under the **[MIT License](LICENSE)**.
> The MIT License is a permissive license that is short and to the point. It lets people do anything they want with your code as long as they provide attribution back to you and don't hold you liable.
**Permissions**: โ
Commercial use, โ
Modification, โ
Distribution, โ
Private use
**Limitations**: โ Liability, โ Warranty
#### Git Commit Message: ๐ฅ Healthcare Management System
---
Made with โค๏ธ by flexycode
---
