hms-project/
β
βββ frontend/ β Open with Live Server
β βββ index.html β Login page (start here)
β βββ css/
β β βββ style.css β Dashboard styles
β β βββ login.css β Login/register styles
β βββ js/
β β βββ api.js β API service (connects to backend)
β βββ pages/
β βββ register.html β Register page
β βββ patient.html β Patient dashboard
β βββ doctor.html β Doctor dashboard
β βββ admin.html β Admin dashboard
β
βββ backend/ β Node.js REST API
β βββ .env β β Edit your DB password here
β βββ package.json
β βββ src/
β βββ server.js β Entry point (npm start)
β βββ config/
β β βββ db.js β MySQL connection
β βββ middleware/
β β βββ auth.js β JWT auth
β βββ routes/
β βββ auth.js β Login / Register
β βββ doctors.js β Doctor CRUD
β βββ patients.js β Patient CRUD
β βββ appointments.jsβ Appointment booking
β βββ prescriptions.js
β βββ admin.js β Admin dashboard API
β
βββ database/
βββ schema.sql β Run this in MySQL first
| Software | Download Link | Check Version |
|---|---|---|
| Node.js 18+ | https://nodejs.org | node -v |
| MySQL 8.0 | https://dev.mysql.com/downloads/ | mysql --version |
| VS Code | https://code.visualstudio.com | β |
| Live Server (VS Code Extension) | Install from VS Code Extensions tab | β |
Open MySQL Workbench or MySQL Command Line and run:
SOURCE /full/path/to/hms-project/database/schema.sql;
OR copy-paste the contents of database/schema.sql into MySQL Workbench and click βΆ Run.
This creates:
hospital_db databaseβ
Done when you see: Database setup complete!
Open backend/.env in VS Code and update your MySQL password:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=YOUR_MYSQL_PASSWORD_HERE β change this
DB_NAME=hospital_db
PORT=5000
JWT_SECRET=medicore_super_secret_jwt_key_2026
If your MySQL user is not root, also change DB_USER.
Open a new terminal in VS Code (Ctrl + ~) and run:
cd backend
npm install
npm start
β Done when you see:
β
MySQL connected successfully
π₯ MediCore HMS Backend running
http://localhost:5000/api/health
Leave this terminal running.
frontend/index.htmlhttp://127.0.0.1:5500/index.htmlβ Done! You should see the MediCore login page.
| Field | Value |
|ββ-|ββ-|
| Email | admin@hospital.com |
| Password | Admin@123 |
| Role | Admin |
| Name | Email | Password |
|ββ|ββ-|βββ-|
| Dr. Priya Sharma | priya.sharma@hospital.com | Doctor@123 |
| Dr. Rahul Verma | rahul.verma@hospital.com | Doctor@123 |
| Dr. Anjali Patel | anjali.patel@hospital.com | Doctor@123 |
| Dr. Suresh Kumar | suresh.kumar@hospital.com | Doctor@123 |
| Name | Email | Password |
|ββ|ββ-|βββ-|
| Amit Singh | amit.singh@email.com | Patient@123 |
| Sneha Reddy | sneha.reddy@email.com | Patient@123 |
| Vikram Nair | vikram.nair@email.com | Patient@123 |
HMS@AdminKey2026
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/auth/login |
Login (all roles) | None |
| POST | /api/auth/register |
Register patient | None |
| GET | /api/auth/me |
Get current user | JWT |
| GET | /api/doctors |
List all doctors | None |
| GET | /api/doctors/:id/appointments |
Doctorβs appointments | JWT |
| GET | /api/patients |
List all patients | Admin only |
| GET | /api/patients/:id/appointments |
Patientβs appointments | JWT |
| POST | /api/appointments |
Book appointment | Patient/Admin |
| PATCH | /api/appointments/:id/status |
Update status | JWT |
| POST | /api/prescriptions |
Write prescription | Doctor only |
| GET | /api/admin/dashboard |
Admin stats | Admin only |
| GET | /api/admin/billing |
All billing records | Admin only |
| GET | /api/health |
Health check | None |
backend/.envbrew services start mysqlsudo systemctl start mysqlfrontend/js/api.js and confirm: const API = 'http://localhost:5000/api';schema.sql β this creates the seed usersnode -vnpm install --legacy-peer-depsPORT=5001 in backend/.envfrontend/js/api.js: const API = 'http://localhost:5001/api';Browser (Frontend)
β
β HTTP Requests (fetch/AJAX)
βΌ
Node.js + Express (Port 5000)
backend/src/server.js
β
β SQL Queries (mysql2)
βΌ
MySQL Database
hospital_db
Authentication Flow:
Authorization: Bearer <token> headerRecommended demo flow:
npm start β MySQL connectedfrontend/index.html with Live ServerMediCore HMS β Built with Node.js, Express, MySQL, Vanilla JS