AI_PROJECT_INGITHUB

πŸ₯ MediCore Hospital Management System

Complete Setup Guide for VS Code


πŸ“ Project Structure

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

βœ… PREREQUISITES β€” Install These 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 β€”

πŸš€ SETUP IN 4 STEPS


STEP 1 β€” Set Up the Database

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:

βœ… Done when you see: Database setup complete!


STEP 2 β€” Configure Backend

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.


STEP 3 β€” Install & Start Backend

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.


STEP 4 β€” Open Frontend

  1. In VS Code, right-click on frontend/index.html
  2. Click β€œOpen with Live Server”
  3. Browser opens at http://127.0.0.1:5500/index.html

βœ… Done! You should see the MediCore login page.


πŸ”‘ LOGIN CREDENTIALS

Admin

| Field | Value | |β€”β€”-|β€”β€”-| | Email | admin@hospital.com | | Password | Admin@123 | | Role | Admin |

Doctors

| 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 |

Patients

| 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 |

Admin Registration Secret Key

HMS@AdminKey2026

πŸ”— API ENDPOINTS (Backend β€” Port 5000)

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

πŸ› TROUBLESHOOTING

❌ β€œMySQL connection failed”

❌ β€œCORS error” in browser console

❌ Login says β€œNo account found”

❌ β€œnpm install” fails

❌ Live Server not found

❌ Port 5000 already in use


πŸ—οΈ ARCHITECTURE

Browser (Frontend)
        β”‚
        β”‚  HTTP Requests (fetch/AJAX)
        β–Ό
  Node.js + Express (Port 5000)
  backend/src/server.js
        β”‚
        β”‚  SQL Queries (mysql2)
        β–Ό
  MySQL Database
  hospital_db

Authentication Flow:

  1. User logs in β†’ backend verifies credentials β†’ returns JWT token
  2. Frontend stores token in localStorage
  3. Every API request sends Authorization: Bearer <token> header
  4. Backend middleware verifies token and checks role

πŸ“‹ FEATURES BY ROLE

Patient

Doctor

Admin


πŸŽ“ FOR FACULTY PRESENTATION

Recommended demo flow:

  1. Open backend terminal β†’ show npm start β†’ MySQL connected
  2. Open frontend/index.html with Live Server
  3. Click Admin demo button β†’ login β†’ show dashboard stats
  4. Go to Doctors β†’ show all 4 doctors in the database
  5. Logout β†’ click Patient demo button β†’ login as Amit Singh
  6. Click Book Appointment β†’ select Dr. Priya Sharma β†’ pick time β†’ Book
  7. Show success screen β†’ click β€œView My Appointments”
  8. Show the new appointment in the list
  9. Logout β†’ login as Doctor (priya.sharma@hospital.com)
  10. Show the new appointment in Today’s Schedule
  11. Confirm β†’ Complete β†’ write Prescription

MediCore HMS β€” Built with Node.js, Express, MySQL, Vanilla JS