HealthNexa digitises the complete patient journey β from AI-powered symptom analysis and geo-based hospital/pharmacy discovery, through slot-based appointment booking, QR code check-in, and live queue tracking.
Six distinct user roles β each with their own isolated dashboard and API surface β make HealthNexa a complete ecosystem for patients, hospitals, and pharmacies alike.
Secure authentication and profile management with image upload
Book appointments with available doctors via smart slot scheduling
View upcoming and historical appointments with unique QR code per booking
AI-powered symptom checker (Google Gemini) with full history tracking
Find nearest hospitals and pharmacies on an interactive map
Real-time live queue token tracking
π¨ββοΈ Doctor Portal
Live queue dashboard β see today's patient list in real time
Call next patient with one click β broadcasts instantly via Socket.IO
Mark appointments as complete
View patient and appointment details
π₯ Hospital Administration
Hospital profile and image management
Add, edit, and remove doctors (with Cloudinary image upload)
Add and manage receptionists
Operational dashboard with key stats
π§βπΌ Receptionist Portal
QR code scanner β scan patient's appointment QR to instantly check in
Insert checked-in patient into the priority queue
Recall skipped patients
Real-time queue workflow support
Pharmacy profile and image management
Medicine inventory management (add, edit, delete, stock, price)
Submit new medicine listing requests to admin
Pharmacy dashboard overview
Google Gemini AI symptom analysis β possible conditions, emergency level, recommended departments, red flags, home-care advice
Results cached in Redis by SHA-256 request hash β zero repeat API cost
Full symptom history stored per patient
Socket.IO room-based live queue updates (queue:{doctorId}:{date})
Live token tracking β patients, receptionists, and doctors all see the same state
No polling β all updates pushed via WebSocket broadcast
π Security & Access Control
JWT stored in HTTP-only cookies (XSS-safe)
6 role-based middleware guards β strict API isolation per role
Redis-backed session verification (5-min TTL)
Secure bcrypt password hashing
OTP email verification via Brevo for registration and password reset
Admin approval workflow β hospitals, pharmacies, and medicines require review before going live
Technology
Purpose
Next.js 16.2 (App Router)
Framework, SSR/SSG
React 19 + TypeScript 5
UI + type safety
Tailwind CSS 4
Styling
Redux Toolkit
Global state management (per-role slices)
React Hook Form
Form handling & validation
Framer Motion
Animations & transitions
Socket.IO Client
Real-time queue updates
Leaflet / React-Leaflet
Interactive geo maps
Axios
HTTP client
@yudiel/react-qr-scanner
QR code scanning (receptionist)
Lucide React
Icon library
Technology
Purpose
Node.js (ESM) + Express 5
REST API server
Socket.IO 4
Real-time WebSocket server
Mongoose 9
MongoDB ODM
bcryptjs + jsonwebtoken
Auth β hashing + JWT
express-validator
Input validation & sanitisation
multer
File upload handling
qrcode
Appointment QR generation
Technology
Purpose
MongoDB 7
Primary data store with 2dsphere geo-indexes
Redis 7 (ioredis)
Session cache + AI result cache
RedisInsight
Redis GUI (included in Docker)
Service
Purpose
Google Gemini (@google/generative-ai)
AI symptom analysis
Cloudinary v2
Image storage & CDN
Brevo SMTP API
Transactional OTP emails
Tool
Purpose
Docker + Docker Compose
Containerised full-stack deployment
ποΈ System Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β Next.js 16 (App Router) β port 3000 β
β Redux Toolkit Β· React Hook Form Β· Socket.IO Client β
β Leaflet Maps Β· QR Scanner Β· Framer Motion β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β HTTP REST + WebSocket
ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β API LAYER β
β Express 5 + Socket.IO β port 5000 β
β protect β role guards β controllers β helpers β
ββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββ
β β
ββββββββΌβββββββ ββββββββββΌβββββββββ
β MongoDB 7 β β Redis 7 β
β Mongoose β β Session cache β
β 2dsphere β β AI result cache β
β geo-index β β 5-min TTL β
βββββββββββββββ βββββββββββββββββββ
External Services:
βββ Cloudinary β image storage & CDN
βββ Brevo β OTP transactional email
βββ Google Gemini β AI symptom analysis
Role
Capabilities
π‘οΈ Admin
Approve/reject hospital, pharmacy & medicine requests; platform dashboard
π€ Patient
Book appointments, AI symptom checker, live queue tracking, pharmacy discovery
π¨ββοΈ Doctor
View today's queue, call next patient, mark appointments complete
π§βπΌ Receptionist
QR check-in, insert patient into queue, recall skipped patients
π₯ Hospital Admin
Manage doctors and receptionists, hospital profile
π Pharmacy Owner
Manage medicine inventory, submit listing requests, pharmacy profile
HealthNexa/
β
βββ π client/ # Next.js 16 frontend
β βββ src/
β βββ app/
β β βββ (auth)/ # Login, Register, Forget Password
β β βββ (patient)/ # Dashboard, Appointments, Symptoms
β β βββ admin/ # Registration request management
β β βββ hospital-admin/ # Doctor & receptionist management
β β βββ doctor/ # Live queue dashboard
β β βββ receptionist/ # Check-in & recall
β β βββ pharmacy/ # Inventory & profile
β β βββ emergency/ # Emergency info
β βββ components/ # Shared UI components
β βββ store/slice/ # Redux slices (one per role)
β βββ providers/ # Context providers (one per role)
β βββ hooks/ # useSocket, GetUser
β βββ Types/ # TypeScript interfaces
β
βββ π server/ # Node.js / Express backend
β βββ src/
β βββ controller/ # Business logic (one per role)
β βββ routes/ # Express routers (one per role)
β βββ models/ # Mongoose schemas
β βββ middlewares/ # protect, 6x role guards, upload
β βββ config/ # DB, Redis, Cloudinary, Gemini, Socket
β βββ helpers/ # ApiErrors, ApiResponse, AsyncHandler
β
βββ π³ docker-compose.yml
βββ π .env.docker
βββ π LICENCE
The entire stack is fully containerised. One command starts everything.
Container
Service
client
Next.js frontend
server
Express + Socket.IO API
mongo
MongoDB 7
redis
Redis 7
redisinsight
Redis GUI
# Start all services (with build)
docker compose up --build
# Run in background
docker compose up -d --build
# Stop all services
docker compose down
Service
Port
Frontend
3000
Backend
5000
MongoDB
27018
Redis
6380
RedisInsight
5540
Node.js >= 18
Docker + Docker Compose or local MongoDB + Redis
git clone https://github.com/Foridul35962/HealthNexa.git
cd HealthNexa
cd server
npm install
cp .env.example .env
# Fill in all environment variable values
Create server/.env:
# Server
CORS_ORIGIN = http://localhost:3000
# Authentication
TOKEN_SECRET = your_super_secret_jwt_key
TOKEN_EXPIRY = 7d
# Database
MONGODB_URI = mongodb://localhost:27017/healthnexa
# Redis
REDIS_URL = redis://localhost:6379
REDIS_PREFIX = healthNexa
# Cloudinary
CLOUDINARY_CLOUD_NAME = your_cloud_name
CLOUDINARY_API_KEY = your_api_key
CLOUDINARY_API_SECRET = your_api_secret
# Brevo (Email OTP)
SENDER_EMAIL = your_sender@example.com
BREVO_API_KEY = your_brevo_api_key
# Google Gemini AI
GEMINI_API_KEY = your_gemini_api_key
βΆοΈ Running the Project
cp .env.example .env.docker # fill in values
docker compose up --build
# Terminal 1 β Backend
cd server && npm start
# Terminal 2 β Frontend
cd client && npm run dev
Base URL: http://localhost:5000/api
Protected routes require a valid JWT (set as HTTP-only cookie on login).
π Authentication β /api/auth
Method
Endpoint
Description
Auth
POST
/patient-registration
Register patient + OTP email
Public
POST
/verify-regi
Verify registration OTP
Public
POST
/hospital-registration
Submit hospital registration request
Public
POST
/pharmacy-registration
Submit pharmacy registration request
Public
POST
/login
Login β sets JWT cookie
Public
GET
/logout
Clear JWT cookie
Public
POST
/forget-pass
Send password reset OTP
Public
POST
/verify-forget-pass
Validate reset OTP
Public
PATCH
/reset-pass
Set new password
Public
POST
/resend-otp
Resend OTP
Public
GET
/user
Get authenticated user
π Protected
π‘οΈ Admin β /api/admin
Method
Endpoint
Description
GET
/request-hospital
List pending hospital requests
POST
/add-hospital
Approve & create hospital
DELETE
/request-hospital/:id
Reject hospital request
GET
/request-pharmacy
List pending pharmacy requests
POST
/add-pharmacy
Approve & create pharmacy
GET
/request-medicine
List pending medicine requests
POST
/add-medicine
Approve & add medicine to catalogue
GET
/dashboard
Platform-wide admin dashboard
π€ Patient β /api/patient
Method
Endpoint
Description
POST
/add-appointment
Book an appointment
GET
/upcomming-appointment
Upcoming appointments
GET
/appointment-history
Full appointment history
GET
/appointment/:id
Single appointment detail
DELETE
/appointment/:id
Cancel appointment
GET
/doctor-token/:doctorId/:date
Current live queue token
GET
/all-symptoms
All AI symptom check results
GET
/symptom/:id
Single symptom check result
DELETE
/symptom/:id
Delete symptom check
PATCH
/update-patient
Update profile + image
Method
Endpoint
Description
POST
/check-symptoms
Gemini AI symptom analysis (Redis cached)
Request Body:
{
"age" : 28 ,
"gender" : " male" ,
"symptoms" : [" headache" , " fever" , " fatigue" ],
"duration" : " 3 days" ,
"temperature" : " 38.5Β°C" ,
"bloodPressure" : " 120/80" ,
"conditions" : [],
"medications" : [],
"allergies" : [],
"notes" : " Started after getting wet in the rain"
}
π¨ββοΈ Doctor β /api/doctor
Method
Endpoint
Description
GET
/dashboard
Today's queue and stats
GET
/call-next
Advance queue to next patient
PATCH
/appointment-complete
Mark current appointment complete
π§βπΌ Receptionist β /api/receptionist
Method
Endpoint
Description
POST
/checkIn
QR scan β insert patient into queue
PATCH
/recallPatient
Recall a skipped patient
GET
/dashboard
Receptionist dashboard
π₯ Hospital Admin β /api/hospital-admin
Method
Endpoint
Description
POST
/add-doctor
Add doctor with image upload
PATCH
/edit-doctor/:id
Edit doctor details
DELETE
/delete-doctor/:id
Remove doctor
POST
/add-receptionist
Add receptionist
GET
/dashboard
Hospital admin stats
π Pharmacy β /api/pharmacy
Method
Endpoint
Description
POST
/req-medicine
Request new medicine listing
POST
/add-medishop
Add approved medicine to inventory
PATCH
/edit-medishop/:id
Edit medicine in shop
DELETE
/pharMedi/:id
Remove medicine from shop
GET
/all-pharMedi
All medicines in inventory
GET
/dashboard
Pharmacy dashboard
PATCH
/edit-pharma
Edit pharmacy profile + image
π Public β /api/public
Method
Endpoint
Description
POST
/nearest-hospital
Nearest hospitals by coordinates
POST
/nearest-pharmacy
Nearest pharmacies by coordinates
GET
/get-doctors/:params
Search doctors by filters
GET
/get-doctor/:id
Single doctor detail
GET
/get-hospital/:id
Hospital detail
GET
/search-medicine
Search medicines by name
GET
/get-medicine/:id
Single medicine detail
Click to expand β all collections
Collection
Key Fields
users
fullName, email, phone, password (bcrypt), image, role, staffRole, hospitalId, pharmacyId
doctors
userId, hospitalId, department, chamberNumber, consultationFee, slotDuration, schedule[]
hospitals
name, address, contactNumber, specialties[], image, location (GeoJSON Point)
pharmacies
name, address, contactNumber, image, location (GeoJSON Point)
appointments
patientId, doctorId, hospitalId, date, slotStart, slotEnd, status, qrHash, tokenNumber, isSkipped, checkedIn
queues
appointmentId, doctorId, date, tokenNumber, priority, status, checkedInAt, calledAt, completedAt
medicines
name, genericName, brandName, manufacturer, medicineType, strength, category, requiresPrescription, sideEffects[]
pharmacymedicines
Junction: pharmacyId <-> medicineId with stock & price
symptomcheckers
userId, patientInfo, input (symptoms/vitals), aiResult (conditions/emergency/recommendations)
requesthospitals
Pending hospital registration requests
requestpharmacies
Pending pharmacy registration requests
requestmedicines
Pending medicine listing requests
Notable Indexes:
appointments β unique on (doctorId, date, slotStart) β prevents double-booking
queues β unique on (doctorId, date, tokenNumber) β sequential tokens guaranteed
hospitals, pharmacies β 2dsphere on location β enables geo-spatial queries
π Authentication & Security
Client β POST /api/auth/login
β Set-Cookie: token=<JWT>; HttpOnly; Secure; SameSite=Strict
Every protected request:
protect middleware
β decode JWT
β check Redis cache (5-min TTL)
β fallback to MongoDB lookup
β attach user to req.user
β role guard middleware
β controller
β
JWT in HTTP-only cookies β XSS-safe, no JS access
β
6 role-based middleware guards β strict server-side isolation
β
bcrypt password hashing
β
express-validator input sanitisation
β
OTP email verification via Brevo
β
Admin approval workflow β no unverified entity enters production data
β
Unique QR hash per appointment β cannot be guessed or reused
Home
Patient Dashboard
AI Symptom Checker
Doctor Queue
Receptionist Check-In
Admin Panel
Building HealthNexa was a deep dive into:
Full-Stack Architecture β designing clean separation between client, API, and data layers
Real-Time Systems β Socket.IO room-based queue broadcasting without polling
Redis Caching β session caching and AI result deduplication using SHA-256 input hashing
Geo-Spatial Queries β MongoDB 2dsphere indexes for efficient nearest-location discovery
AI Integration β prompting Gemini for structured JSON clinical output
Multi-Role RBAC β building scalable access control with discrete middleware guards
Docker Containerisation β orchestrating a 5-service stack with Docker Compose
Database Modelling β designing schemas with integrity constraints for healthcare workflows
Contributions, suggestions, and feedback are welcome!
Fork the repository
Create a feature branch (git checkout -b feature/your-feature)
Commit your changes (git commit -m 'Add your feature')
Push your branch (git push origin feature/your-feature)
Open a Pull Request
Foridul Ibne Qauser
Software Engineering Enthusiast Β· Full-Stack Developer
This project is licensed under the ISC License β see the LICENCE file for details.
β€οΈ Built to improve healthcare accessibility through technology.
β Star this repo if you found it helpful!