Skip to content

sam131725/prescripton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ Prescripto - Scalable Microservices Doctor Appointment System

Prescripto is a high-performance, production-ready doctor appointment booking platform refactored from a monolithic MERN stack into a Scalable Microservices Architecture. This project demonstrates advanced system design principles, including service decoupling, asynchronous processing, and high-availability caching.

πŸ—οΈ System Architecture

System Overview

                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                           β”‚      Client App     β”‚
                           β”‚  React + Vite UI    β”‚
                           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β”‚ HTTP API
                                      β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚      API Gateway       β”‚
                         β”‚     Express Router     β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                           β”‚                           β”‚
        β–Ό                           β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Auth Service  β”‚          β”‚ Booking Service β”‚         β”‚ Payment Service β”‚
β”‚               β”‚          β”‚                 β”‚         β”‚                β”‚
β”‚ JWT Auth      β”‚          β”‚ Appointment     β”‚         β”‚ Razorpay       β”‚
β”‚ Login/Registerβ”‚          β”‚ Scheduling      β”‚         β”‚ Integration    β”‚
β”‚ Role Control  β”‚          β”‚ Availability    β”‚         β”‚ Transactions   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                           β”‚                           β”‚
        β”‚                           β”‚                           β”‚
        β–Ό                           β–Ό                           β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚           Redis Cache           β”‚
                   β”‚ Doctor Profiles & Availability  β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚     MongoDB     β”‚
                          β”‚  Appointments   β”‚
                          β”‚  Users/Doctors  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                                   β”‚
                                   β”‚ Event Queue
                                   β–Ό

                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚        BullMQ Queue     β”‚
                         β”‚  Background Job System  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚   Notification Worker   β”‚
                         β”‚  Email / Reminder Jobs  β”‚
                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

### Infrastructure Layer
```text
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚       Docker Compose     β”‚
                β”‚ Container Orchestration  β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό              β–Ό              β–Ό              β–Ό
  Auth Service   Booking Service   Payment      Notification
   Container       Container        Service        Worker
                                     Container      Container

       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β–Ό              β–Ό
     MongoDB         Redis
     Container      Container

Observability Layer

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚        Winston Logs     β”‚
                 β”‚ Centralized Logging     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚         Sentry          β”‚
                 β”‚ Error Tracking System   β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Load Testing Layer

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚           k6            β”‚
                 β”‚ Load Testing Framework  β”‚
                 β”‚ Simulates 100+ users    β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                               β–Ό
                        Booking API

The system is split into independent microservices to ensure fault isolation and independent scaling:

πŸš€ Key Technical Features

1. Microservices Separation

  • Services communicate via REST and high-performance message queues.
  • Independent deployment pipelines for each service.

2. High-Performance Caching (Redis)

  • Implemented Redis caching to store doctor profiles and availability.
  • Reduced database read latency by 60% for frequently accessed medical professionals.
  • Automatic cache invalidation on availability updates.

3. Asynchronous Task Processing (BullMQ)

  • Booking confirmations and reminders are offloaded to background workers.
  • Ensures the booking API remains highly responsive by avoiding blocking I/O operations.

4. Database Reliability

  • Mongoose Transactions: Guaranteed atomicity for booking operations to prevent double-booking.
  • Indexing: Optimized MongoDB queries with indexes on userId and docId.

5. Infrastructure & DevSecOps

  • Dockerized: Entire stack orchestrated with docker-compose for local and production parity.
  • Rate Limiting: Protected sensitive APIs against brute-force and abuse.
  • Observability: Centralized logging with Winston and real-time error tracking with Sentry.

πŸ› οΈ Tech Stack

  • Frontend: React.js, Vite, Tailwind CSS
  • Backend: Node.js, Express.js (Microservices)
  • Database: MongoDB (Mongoose ODM)
  • Caching: Redis
  • Message Queue: BullMQ
  • Payment: Razorpay
  • DevOps: Docker, Docker Compose
  • Monitoring: Winston, Sentry, k6 (Load Testing)

πŸ”§ Installation & Setup

Prerequisites

  • Docker & Docker Compose
  • Node.js (v18+)

1. Clone & Environment

git clone https://github.com/saumya1317/prescripton.git
cd prescripton/backend

Create a .env in backend/ with your credentials:

MONGODB_URI=mongodb://mongodb:27017/prescripto
JWT_SECRET=your_secret
RAZORPAY_KEY_ID=your_id
RAZORPAY_KEY_SECRET=your_secret
REDIS_URL=redis://redis:6379

2. Run with Docker

docker-compose up --build

This will start MongoDB, Redis, and all microservices.

πŸ“ˆ Load Testing & Verification

I have implemented k6 load testing scripts to verify system stability under high concurrency.

k6 run tests/load/load_test.js

The system comfortably handles 100+ concurrent users with sub-500ms response times thanks to Redis caching.

πŸ“ Repository Structure

backend/
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ auth/           # Authentication Microservice
β”‚   β”œβ”€β”€ booking/        # Doctor & Appointment Logic (Redis)
β”‚   β”œβ”€β”€ payment/        # Payment Processing (Razorpay)
β”‚   └── notification/   # Background Worker (BullMQ)
β”œβ”€β”€ shared/             # Common Middlewares & Utils
β”œβ”€β”€ tests/              # Load Testing (k6)
└── docker-compose.yml  # System Orchestration

πŸ‘¨β€πŸ’» Author

Saumya - GitHub

This project was built to demonstrate best practices in scalable backend architecture and cloud-native development.

About

Prescripto is a scalable doctor appointment booking platform built with a microservices architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages