You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Star0 (0)You must be signed in to star a repository
About
PH Healthcare System — a digital healthcare platform for online doctor consultations, handling appointment booking, bKash payments, video-call scheduling, and digital prescriptions.
PH Healthcare System is a healthcare platform that enables seamless online consultations between patients and doctors. The system handles the complete lifecycle of healthcare appointments: from doctor registration and approval, schedule management, patient booking, payment processing, video consultations, to digital prescriptions.
Key Capabilities
Multi-role Authentication: Patient, Doctor, Admin, Super Admin with role-based access control
Doctor Onboarding: Application, verification, and approval workflow
Schedule Management: Doctors create and publish availability schedules
Appointment Booking: Real-time slot booking with payment integration
Payment Processing: bKash integration for secure payments
Video Consultations: Meet link integration for online sessions
Digital Prescriptions: PDF generation and email delivery
Analytics Dashboard: Role-specific analytics for patients, doctors, and admins
Email Notifications: Automated emails for registration, appointments, prescriptions, and more
🛠 Tech Stack
Backend
Technology
Version
Purpose
Node.js
20+
Runtime environment
Express.js
5.x
Web framework
TypeScript
7.x
Type-safe development
Prisma ORM
7.x
Database ORM
PostgreSQL
15+
Primary database
Redis
7+
Caching & sessions
JWT
9.x
Authentication tokens
Zod
4.x
Schema validation
bcryptjs
3.x
Password hashing
Services & Integrations
Service
Purpose
bKash
Payment gateway (Bangladesh)
Cloudinary
Image/file storage
Nodemailer
Email delivery
Google Auth
OAuth2 login for patients
PDFKit
PDF generation for prescriptions/invoices
node-cron
Scheduled jobs (cleanup tasks)
🗄 Database Schema
The data model centers on a User that owns either a Patient or Doctor profile. Doctors publish Schedules, patients book Appointments against those schedules, and each appointment has an associated Payment and, once completed, a Prescription.
User ─┬─ Patient ─── Appointment ─┬─ Payment
└─ Doctor ──── Schedule ────┴─ Prescription
Full schema definitions go to Document.md
🔌 API Endpoints
All endpoints are prefixed with /api/v1
Authentication (/auth)
Method
Path
Auth
Body
Description
POST
/register
❌
{name, email, password}
Register new patient
POST
/verify-email
❌
{email, otp}
Verify email with OTP
POST
/login
❌
{email, password}
User login (all roles)
GET
/me
✅ (All)
-
Get current user profile
POST
/refresh-token
❌
-
Refresh access token
POST
/google
❌
{credential}
Google OAuth login (patients only)
POST
/forgot-password
❌
{email}
Request password reset OTP
POST
/reset-password
❌
{email, otp, newPassword}
Reset password with OTP
User (/user)
Method
Path
Auth
Body
Description
PATCH
/profile-image
✅ (All)
multipart/form-data
Upload profile image
Doctor (/doctor)
Method
Path
Auth
Body
Description
POST
/apply-doctor
❌
multipart/form-data
Apply to become a doctor (resume, files)
POST
/apply-doctor/email-verify
❌
{email, otp}
Verify doctor application email
POST
/approved-doctor
✅ (Admin, Super Admin)
{doctorId, status, rejectionReason?}
Approve/reject doctor application
GET
/all-doctors
✅ (Admin, Super Admin)
Query params
Get all doctors (paginated)
PATCH
/update-profile
✅ (Doctor)
{specialization, bio, fee, etc.}
Update doctor profile
GET
/public/available-today
❌
-
Get doctors available today
GET
/public/all-doctors
❌
Query params
Get all approved doctors list
GET
/public/:doctorId
❌
-
Get single doctor public profile
Schedule (/schedule)
Method
Path
Auth
Body
Description
POST
/
✅ (Doctor)
{startDateTime, endDateTime, meetLink}
Create schedule (draft)
GET
/my-schedule
✅ (Doctor)
Query params
Get doctor's own schedules
GET
/all-schedule
✅ (Admin, Super Admin)
Query params
Get all schedules
GET
/todays-schedule
❌
-
Get today's published schedules
PUT
/:scheduleId
✅ (Doctor)
{startDateTime?, endDateTime?, meetLink?}
Update schedule
PATCH
/publish-schedule/:scheduleId
✅ (Doctor)
-
Publish draft schedule
PUT
/delete/:scheduleId
✅ (Doctor)
-
Soft delete schedule
Appointment (/appointment)
Method
Path
Auth
Body
Description
POST
/book-appointment
✅ (Patient)
{scheduleId}
Book appointment & initiate payment
POST
/cancel-appointment
✅ (Patient)
{appointmentId}
Cancel appointment
GET
/book-appointment/payment/callback
❌
Query params
bKash payment callback
GET
/my-appointment
✅ (Patient)
Query params
Get patient's appointments
GET
/my-appointments
✅ (Doctor)
Query params
Get doctor's appointments
PATCH
/update
✅ (Doctor)
{appointmentId, status}
Update appointment status (ongoing/completed)
GET
/all-appointments
✅ (Admin, Super Admin)
Query params
Get all appointments
GET
/:appointmentId
✅ (All)
-
Get single appointment details
Payment (/payment)
Method
Path
Auth
Body
Description
POST
/
✅ (Patient)
{appointmentId}
Create payment for appointment
GET
/my-payment
✅ (Patient)
Query params
Get patient's payment history
GET
/doctor-payment
✅ (Doctor)
Query params
Get doctor's payment history
GET
/all-payment
✅ (Admin, Super Admin)
Query params
Get all payments
Prescription (/prescription)
Method
Path
Auth
Body
Description
POST
/
✅ (Doctor)
{appointmentId, findings, medicines}
Create prescription
GET
/:appointmentId
✅ (All)
-
Get prescription for appointment
Analytics (/analytical)
Method
Path
Auth
Body
Description
GET
/patient-analytics
✅ (Patient)
-
Patient dashboard analytics
GET
/doctor-analytics
✅ (Doctor)
-
Doctor dashboard analytics
GET
/admin-analytics
✅ (Admin, Super Admin)
-
Admin dashboard analytics
✨ Features
Authentication & Authorization
JWT-based auth with access + refresh tokens (httpOnly cookies)
Role-based access control (RBAC) for all endpoints
Google OAuth for patient registration/login
Email OTP verification for self-registration (patient & doctor)
Forgot/Reset password flow with OTP
Password change for logged-in users
Set password for Google-only patients
Appointment Booking
Today-only visibility for patients
Real-time slot availability
Upfront payment required
Serial number assignment
Invoice PDF emailed on booking
Cancellation with refund rules (>1hr before = refund)
GET /api/v1/appointment/all-appointments
GET /api/v1/payment/all-payment
GET /api/v1/schedule/all-schedule
GET /api/v1/analytical/admin-analytics
- Revenue reports
- User growth
- Appointment statistics
- Doctor approval queue
2. Admin Creation (Super Admin only)
Create Admin/Super Admin accounts programmatically
- Organization email (login)
- Personal email (welcome credentials)
- Auto-generated password
- Force password change on first login
🚀 Setup & Installation
Prerequisites
Node.js 20+
PostgreSQL 15+
Redis 7+
bKash Developer Account (for payments)
Cloudinary Account (for file storage)
Gmail/App Password (for emails)
Google Cloud Console (for OAuth)
Installation
# Clone repository
git clone <repository-url>cd PH-Healthcare-System
# Install dependencies
npm install
# Setup environment variables
cp .env.example .env
# Edit .env with your configuration# Generate Prisma Client
npx prisma generate
# Run migrations
npx prisma migrate dev
# (Optional) Seed database
npm run dev # Seeds run on server start# Start development server
npm run dev
PH Healthcare System — a digital healthcare platform for online doctor consultations, handling appointment booking, bKash payments, video-call scheduling, and digital prescriptions.