A full-stack, dual-dashboard Hospital Management System built with Django, featuring real-time Google Calendar synchronization and an independent Node.js serverless microservice for automated email notifications.
- Dual Dashboards: Custom role-based interfaces for Doctors and Patients.
- Smart Scheduling: Doctors can generate hourly time slots; booked slots dynamically disappear from the available pool.
- Google Calendar Integration: Secure OAuth2 + PKCE flow to automatically create Google Calendar events for both the Patient and the Doctor upon booking.
- Serverless Email Microservice: A decoupled Node.js service using the Serverless Framework and Resend API to deliver asynchronous HTML confirmation emails.
Before you begin, ensure you have the following installed on your Windows machine:
- Python 3.x (for the Django Backend)
- PostgreSQL on Docker (for database)
- Node.js & npm (for the Email Microservice)
- Google Cloud Console Account (For Calendar API
credentials.json) - Resend Account (For Email API Key)
/hms_workspace
│
├── /hms # The Django Backend
│ ├── manage.py
│ ├── credentials.json # Google OAuth Keys (User provided)
│ ├── /hms # Core settings
│ └── /core # Main application logic
│
└── /email_service # The Node.js Microservice
├── handler.js # Email sending logic
├── serverless.yml # Microservice configuration
├── package.json
└── test.json # Local testing payload
Follow these steps exactly to get the entire ecosystem running on your local machine.
-
Open a terminal and navigate to your
hmsfolder. -
Create and activate a virtual environment:
python -m venv .venv .\.venv\Scripts\activate -
Install the required Python packages:
pip install -r requirements.txt -
Apply the database migrations:
python manage.py makemigrations python manage.py migrate -
Create an admin account to manage the database:
python manage.py createsuperuser
-
Start the Docker Desktop and run following command on the terminal(NOTE: Replace all values according to you)
docker run --name hms-postgres \ -e POSTGRES_USER=<admin-name> \ -e POSTGRES_PASSWORD=<password> \ -e POSTGRES_DB=<database-name> \ -p 5432:5432 \ -d postgres
- Go to the Google Cloud Console.
- Enable the Google Calendar API.
- Create an External OAuth Consent Screen and add your test Gmail addresses to the Test Users list.
- Create OAuth Client ID credentials (Web Application) with the redirect URI:
http://127.0.0.1:8000/oauth2callback/. - Download the JSON file, rename it to
credentials.json, and place it in the root of yourhmsfolder.
-
Open a new terminal window and navigate to your
email_servicefolder. -
Install the free version of the Serverless Framework globally:
npm install -g serverless@3 -
Install the required local dependencies:
npm install resend serverless-offline@13 --save-dev
Because this project utilizes a microservice architecture, you must run two servers simultaneously in two separate terminal windows.
Open a terminal in the email_service folder. Run the command that matches your terminal type to inject your Resend API key and start the listener on port 3000:
Command Prompt (CMD):
set RESEND_API_KEY=<re_YOUR_KEY_HERE> && serverless offline
PowerShell:
$env:RESEND_API_KEY="re_YOUR_KEY_HERE"; serverless offline
Open a terminal in the hms folder, activate your virtual environment, and run the Django server:
.\.venv\Scripts\activate
python manage.py runserver
- Go to
http://127.0.0.1:8000/adminand ensure your Patient user account's email matches the exact email you registered with Resend (Free Tier requirement). - Go to
http://127.0.0.1:8000/patient/dashboard/. - Click Book Now on an available slot.
- Log into Google when prompted (If warned about unverified apps, click Advanced -> Go to App).
- The system will book the slot, sync to Google Calendar, and trigger the Node.js server to send a confirmation email.
- Check your Google Calendar and your Email Inbox!