A comprehensive, real-time hospital management platform that connects patients with healthcare facilities, enabling smart hospital discovery, appointment booking, and live bed availability tracking.
- Features
- Tech Stack
- Architecture
- Getting Started
- API Documentation
- Database Schema
- Environment Variables
- Deployment
- Contributing
- π Smart Hospital Search - Semantic search with autocomplete suggestions
- π Location-Based Discovery - Find nearby hospitals using geolocation
- π¨ Real-Time Bed Availability - Live updates on ICU, Oxygen, and General beds
- β±οΈ ER Wait Times - View current emergency room wait times by severity
- π Appointment Booking - Book appointments via triage or calendar
- β Hospital Ratings - Rate and review hospitals
- π± Virtual Queue - Join virtual waiting lists for emergency care
- π« Booking Management - View and cancel appointments
- π Dashboard - Comprehensive overview of hospital operations
- ποΈ Inventory Management - Update bed counts and doctor availability
- π Booking Management - View and manage all appointments (triage + calendar)
- β° ER Wait Time Updates - Manage emergency room wait times
- π₯ Facility Management - Update specializations, diagnostics, and accreditations
- π Real-Time Notifications - Instant alerts for new bookings via WebSocket
- π Profile Completeness - Track and improve hospital profile quality
- β Hospital Verification - Approve/reject hospital registrations
- π System Analytics - View platform statistics and metrics
- π₯ Hospital Management - Activate/deactivate hospitals
- π₯ User Management - Monitor platform users
- Runtime: Node.js (Express.js v5.1.0)
- Database: PostgreSQL with Prisma ORM (v6.18.0)
- Authentication: JWT + Google OAuth 2.0 (Passport.js)
- Real-Time: Socket.io (v4.8.1)
- Security: bcryptjs, express-session
- API: RESTful architecture
- Framework: React (v19.1.1)
- Build Tool: Vite (v7.1.7)
- Routing: React Router DOM (v7.9.5)
- Styling: Tailwind CSS (v4.1.17)
- Maps: Leaflet + React Leaflet
- Animations: Framer Motion (v12.23.24)
- Icons: Lucide React
- Real-Time: Socket.io Client
- Hosting: Vercel (Frontend) + Render/Railway (Backend)
- Database: PostgreSQL (Cloud)
- Version Control: Git
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Patient β β Hospital β β Admin β β Auth β β
β βDashboard β βDashboard β βDashboard β β Pages β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β HTTP/WebSocket
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend (Express + Socket.io) β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Auth β β Patient β β Hospital β β Admin β β
β β Routes β β Routes β β Routes β β Routes β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β Search β β Auth β β Socket β β
β βControllerβ βMiddlewareβ β Events β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Prisma ORM
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PostgreSQL Database β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Users β βHospitals β β Bookings β β Ratings β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β ββββββββββββ ββββββββββββ β
β β Queue β β Tokens β β
β ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Node.js (v18 or higher)
- PostgreSQL (v14 or higher)
- npm or yarn
- Git
git clone https://github.com/yourusername/medqueue.git
cd medqueuecd backend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration (see Environment Variables section)
# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate deploy
# (Optional) Seed database with sample data
npx prisma db seed
# Start development server
npm run devThe backend will run on http://localhost:5001
cd ../frontend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your backend URL
# Start development server
npm run devThe frontend will run on http://localhost:5173
# Coming soon
docker-compose up- Development:
http://localhost:5001/api - Production:
https://your-backend-url.com/api
All authenticated endpoints require a Bearer token in the Authorization header:
Authorization: Bearer <your_jwt_token>
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "securePassword123",
"role": "PATIENT | HOSPITAL | ADMIN",
"fullName": "John Doe",
"phone": "+1234567890",
// Required if role is HOSPITAL
"hospitalName": "City General Hospital",
"address": "123 Main St",
"city": "New York",
"latitude": 40.7128,
"longitude": -74.0060
}Response:
{
"message": "User registered successfully",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "refresh_token_here",
"user": {
"id": 1,
"email": "user@example.com",
"role": "PATIENT",
"fullName": "John Doe"
}
}POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "securePassword123"
}Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "refresh_token_here",
"user": {
"id": 1,
"email": "user@example.com",
"role": "PATIENT",
"fullName": "John Doe"
}
}GET /api/auth/googleRedirects to Google OAuth consent screen.
POST /api/auth/refresh-token
Content-Type: application/json
{
"refreshToken": "your_refresh_token"
}POST /api/auth/logout
Content-Type: application/json
{
"refreshToken": "your_refresh_token"
}GET /api/auth/me
Authorization: Bearer <token>GET /api/patient/hospitals?lat=40.7128&lng=-74.0060&specialization=Cardiology&page=1&limit=10&sortBy=distance&order=asc&bedType=ICU&minRating=4Query Parameters:
lat(optional): User latitudelng(optional): User longitudespecialization(optional): Filter by departmentpage(default: 1): Page numberlimit(default: 10): Results per pagesortBy(default: distance): Sort bydistance,rating,name, oravailabilityorder(default: asc):ascordescbedType(optional): Filter byICU,Oxygen,Ventilator, orGeneralminRating(optional): Minimum average rating
Response:
{
"hospitals": [
{
"id": 1,
"name": "City General Hospital",
"address": "123 Main St",
"city": "New York",
"latitude": 40.7128,
"longitude": -74.0060,
"phone": "+1234567890",
"bedsGeneral": 50,
"bedsICU": 20,
"bedsOxygen": 15,
"doctorsActive": 30,
"distance": 2.5,
"totalBeds": 85,
"viabilityScore": 837.5,
"averageRating": 4.5,
"totalRatings": 120,
"erWaitTimes": {
"critical": { "avgWaitMinutes": 10, "currentQueue": 2, "status": "Available" },
"moderate": { "avgWaitMinutes": 45, "currentQueue": 5, "status": "Busy" },
"nonUrgent": { "avgWaitMinutes": 120, "currentQueue": 10, "status": "Available" }
}
}
],
"pagination": {
"total": 25,
"page": 1,
"limit": 10,
"totalPages": 3
}
}GET /api/patient/hospitals/:idGET /api/patient/hospitals/:id/facilitiesResponse:
{
"hospital": { /* full hospital object */ },
"facilities": {
"specializations": [
{ "department": "Cardiology", "specialists": 5, "beds": 20 }
],
"diagnostics": {
"mri": true,
"ctScan": true,
"xray": true
},
"criticalCare": {
"ventilators": 10,
"dialysis": true,
"bloodBank": true
},
"supportServices": {
"pharmacy": true,
"cafeteria": true,
"parking": true
},
"accreditations": [
{ "name": "NABH", "validUntil": "2025-12-31" }
]
},
"profileCompleteness": 85
}POST /api/patient/bookings
Content-Type: application/json
{
"hospitalId": 1,
"patientName": "John Doe",
"patientPhone": "+1234567890",
"condition": "Chest Pain",
"severity": "CRITICAL | MODERATE | LOW",
"source": "TRIAGE | CALENDAR | WALK_IN",
"status": "INCOMING | SCHEDULED",
"appointmentTime": "2024-12-10T14:00:00Z", // Optional, for calendar bookings
"userId": 1 // Optional, for authenticated users
}Response:
{
"message": "Booking created successfully",
"booking": {
"id": 1,
"hospitalId": 1,
"patientName": "John Doe",
"condition": "Chest Pain",
"severity": "CRITICAL",
"status": "INCOMING",
"source": "TRIAGE",
"createdAt": "2024-12-03T18:30:00Z"
}
}GET /api/patient/my-bookings
Authorization: Bearer <token>DELETE /api/patient/bookings/:id
Authorization: Bearer <token>POST /api/patient/hospitals/:id/rate
Authorization: Bearer <token>
Content-Type: application/json
{
"value": 5, // 1-5
"comment": "Excellent service and care!"
}GET /api/patient/hospitals/:id/er-wait-timesPOST /api/patient/hospitals/:id/virtual-queue
Content-Type: application/json
{
"patientName": "John Doe",
"severity": "CRITICAL | MODERATE | LOW",
"userId": 1 // Optional
}Response:
{
"message": "Successfully joined virtual queue",
"queueEntry": {
"id": 1,
"hospitalId": 1,
"patientName": "John Doe",
"severity": "MODERATE",
"status": "WAITING",
"checkInTime": "2024-12-03T18:30:00Z"
},
"position": 5
}GET /api/patient/hospitals/:id/virtual-queue/:entryIdAll routes require authentication with HOSPITAL role
GET /api/hospital/profile
Authorization: Bearer <token>PATCH /api/hospital/inventory
Authorization: Bearer <token>
Content-Type: application/json
{
"bedsGeneral": 50,
"bedsICU": 20,
"bedsOxygen": 15,
"doctorsActive": 30
}GET /api/hospital/bookings?status=INCOMING&source=TRIAGE
Authorization: Bearer <token>Query Parameters:
status(optional): Filter byINCOMING,ADMITTED,DIVERTED,CANCELLED,SCHEDULED,COMPLETED,NO_SHOW, orALLsource(optional): Filter byTRIAGE,CALENDAR,WALK_IN, orALLhId(optional): Hospital ID (if not using authenticated manager)
PATCH /api/hospital/bookings/:id/status
Authorization: Bearer <token>
Content-Type: application/json
{
"status": "ADMITTED | DIVERTED | CANCELLED | COMPLETED | NO_SHOW"
}PUT /api/hospital/er-wait-times
Authorization: Bearer <token>
Content-Type: application/json
{
"critical": {
"avgWaitMinutes": 10,
"currentQueue": 2,
"status": "Available"
},
"moderate": {
"avgWaitMinutes": 45,
"currentQueue": 5,
"status": "Busy"
},
"nonUrgent": {
"avgWaitMinutes": 120,
"currentQueue": 10,
"status": "Available"
}
}GET /api/hospital/virtual-queue
Authorization: Bearer <token>PATCH /api/hospital/virtual-queue/:id/status
Authorization: Bearer <token>
Content-Type: application/json
{
"status": "WAITING | CALLED | COMPLETED | EXPIRED | CANCELLED"
}DELETE /api/hospital/virtual-queue/:id
Authorization: Bearer <token>PUT /api/hospital/facilities
Authorization: Bearer <token>
Content-Type: application/json
{
"specializations": [
{ "department": "Cardiology", "specialists": 5, "beds": 20 }
],
"diagnostics": {
"mri": true,
"ctScan": true
},
"criticalCare": {
"ventilators": 10,
"dialysis": true
},
"supportServices": {
"pharmacy": true
},
"accreditations": [
{ "name": "NABH", "validUntil": "2025-12-31" }
]
}GET /api/admin/statsResponse:
{
"totalHospitals": 150,
"activeHospitals": 120,
"pendingHospitals": 30,
"totalUsers": 5000,
"totalBeds": 12500,
"systemHealth": "Excellent"
}GET /api/admin/hospitals/pendingGET /api/admin/hospitals/allPATCH /api/admin/hospitals/:id/verify
Content-Type: application/json
{
"isVerified": true // true to approve, false to reject
}GET /api/search?q=hospitals with ICU beds near me&lat=40.7128&lng=-74.0060&page=1&limit=10Query Parameters:
q(required): Search query (supports natural language)lat,lng(optional): User coordinatespage,limit(optional): Pagination
Supported Search Patterns:
- "hospitals with ICU beds"
- "cardiac care near me"
- "emergency room in New York"
- "pediatric hospital with ventilators"
GET /api/search/suggestions?q=cardResponse:
{
"hospitals": [
{ "name": "Cardiac Care Center", "id": 5 }
],
"specializations": ["Cardiology"],
"facilities": ["Cardiac ICU"],
"bedTypes": ["ICU Beds"]
}GET /api/search/trendingReturns top 5 hospitals by average rating.
GET /api/search/recommendedReturns 3 recommended hospitals with reasons.
// Join hospital room for real-time updates
socket.emit('join_hospital', hospitalId);// New booking received
socket.on('new_booking', (booking) => { /* ... */ });
// Booking status updated
socket.on('booking_updated', (booking) => { /* ... */ });
// Hospital inventory updated
socket.on('hospital_updated', (hospital) => { /* ... */ });
// Public hospital update (for patient dashboard)
socket.on('hospital_updated_public', (hospital) => { /* ... */ });
// ER wait times updated
socket.on('er_wait_times_updated', (data) => { /* ... */ });
// Queue entry updated
socket.on('queue_entry_updated', (entry) => { /* ... */ });
// Queue entry removed
socket.on('queue_entry_removed', (data) => { /* ... */ });βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β User ββββββββββΆβ Hospital βββββββββββ Booking β
β β manages β β receivesβ β
β - id β β - id β β - id β
β - email β β - name β β - userId β
β - password β β - address β β - hospitalIdβ
β - role β β - latitude β β - condition β
β - fullName β β - longitude β β - severity β
β - phone β β - bedsGeneralβ β - status β
β - googleId β β - bedsICU β β - source β
βββββββββββββββ β - bedsOxygen β βββββββββββββββ
β β - managerId β β
β ββββββββββββββββ β
β β β
β β β
βΌ βΌ βΌ
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Rating β βVirtualQueue β βRefreshToken β
β β β β β β
β - id β β - id β β - id β
β - value β β - hospitalId β β - token β
β - comment β β - patientNameβ β - userId β
β - userId β β - severity β β - expiresAt β
β - hospitalIdβ β - status β β - revoked β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
- Roles:
PATIENT,HOSPITAL,ADMIN - Authentication: Email/Password + Google OAuth
- Relations: Can manage one hospital, create multiple bookings and ratings
- Verification: Admin approval required (
isVerified) - Live Inventory: Real-time bed counts and doctor availability
- Facilities: JSON fields for specializations, diagnostics, critical care, support services, accreditations
- Profile Completeness: Calculated score (0-100)
- Sources:
TRIAGE(emergency),CALENDAR(scheduled),WALK_IN - Statuses:
INCOMING,ADMITTED,DIVERTED,CANCELLED,SCHEDULED,COMPLETED,NO_SHOW - Severity:
LOW,MODERATE,CRITICAL
- Statuses:
WAITING,CALLED,COMPLETED,EXPIRED,CANCELLED - Ordering: By severity (CRITICAL first) then check-in time
# Server Configuration
PORT=5001
NODE_ENV=development
FRONTEND_URL=http://localhost:5173
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/medqueue?schema=public"
# JWT Authentication
JWT_SECRET=your_super_secret_jwt_key_here_change_in_production
JWT_EXPIRES_IN=1h
REFRESH_TOKEN_EXPIRES_IN=7d
# Session
SESSION_SECRET=your_session_secret_here
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:5001/api/auth/google/callback
# CORS
ALLOWED_ORIGINS=http://localhost:5173,https://med-queue.vercel.app# Backend API
VITE_API_URL=http://localhost:5001/api
VITE_SOCKET_URL=http://localhost:5001
# Google Maps (if using)
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key-
Create PostgreSQL Database
- Set up a PostgreSQL instance
- Copy the connection string
-
Deploy Backend
# On Render/Railway - Connect your GitHub repository - Set build command: npm install && npx prisma generate && npx prisma migrate deploy - Set start command: npm start - Add all environment variables
-
Run Migrations
npx prisma migrate deploy
-
Connect Repository
- Import your GitHub repository to Vercel
-
Configure Build Settings
- Framework: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
-
Set Environment Variables
- Add
VITE_API_URLwith your backend URL - Add
VITE_SOCKET_URLwith your backend URL
- Add
-
Deploy
vercel --prod
cd backend
npm testcd frontend
npm test- User registration and login
- Google OAuth flow
- Hospital search with filters
- Booking creation and cancellation
- Real-time bed updates
- Hospital manager dashboard
- Admin approval workflow
- Rating submission
- Virtual queue functionality
- Database Indexing: Indexes on
latitude,longitude,isVerified,userId,hospitalId - Pagination: All list endpoints support pagination
- Caching: Consider Redis for frequently accessed data
- WebSocket: Real-time updates without polling
- Image Optimization: Use CDN for hospital images
- Code Splitting: React lazy loading for routes
- β JWT-based authentication
- β Password hashing with bcryptjs
- β CORS protection
- β SQL injection prevention (Prisma ORM)
- β XSS protection
- β Rate limiting (recommended: express-rate-limit)
- β HTTPS in production
- β Environment variable protection
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow ESLint configuration
- Use Prettier for formatting
- Write meaningful commit messages
- Add comments for complex logic
This project is licensed under the ISC License.
- Mansi Agarwal - Initial work - GitHub
- React and Vite communities
- Prisma team for excellent ORM
- Socket.io for real-time capabilities
- Leaflet for mapping functionality
- All contributors and testers
For support, email support@medqueue.com or open an issue on GitHub.
- Mobile app (React Native)
- SMS notifications
- Multi-language support
- Advanced analytics dashboard
- AI-powered hospital recommendations
- Telemedicine integration
- Insurance verification
- Payment gateway integration
Built with β€οΈ for better healthcare accessibility