Cura is a scalable healthcare backend server built with Node.js and Express. It manages patients, doctors, appointments, and Electronic Medical Records (EMR) — with role-based access control, concurrent-safe timeslot booking, and asynchronous notifications, all orchestrated through a Docker microservices architecture.
- Authentication & Authorization — JWT-based auth with separate roles for
PatientandDoctor. Access to resources is strictly scoped by role. - Electronic Medical Records (EMR) — Each patient has a dedicated EMR stored in MongoDB. Records and files (stored via GridFS) are only accessible to the doctor who owns the booked timeslot for that patient.
- Timeslot Booking — Race-condition-safe appointment booking via a dedicated
BookingServiceusing a request/response message pattern over RabbitMQ. - Notifications & Email — Asynchronous email delivery on signup, booking confirmation, and cancellation via
MailingAndNotificationServiceusing a pub/sub pattern over RabbitMQ.
| Category | Technology |
|---|---|
| Runtime | Node.js, Express |
| Relational DB | MySQL + Sequelize (ORM) |
| Document DB | MongoDB + Mongoose (ODM) |
| Message Queue | RabbitMQ |
| Containerization | Docker |
| Orchestration | docker-compose |
| Nodemailer | |
| Auth | JWT (access + refresh tokens) |
| Security | bcrypt |
| CI/CD | CircleCI |
Cura uses two databases with distinct responsibilities:
| Database | ORM/ODM | Stores |
|---|---|---|
| MySQL | Sequelize | Users (patients & doctors), timeslots, appointments, relational data |
| MongoDB | Mongoose | EMR documents and files per patient (files via GridFS) |
A doctor can only access a patient's EMR if they own the timeslot that was booked by that patient. This is enforced at the service layer — not just at the route level — so no doctor can query another doctor's patient records.
The primary entry point for all CRUD operations, authentication, authorization, and EMR access. Follows the MVC pattern with a Controller → Service → Repository → Model layering structure. Issues and validates JWTs for both Patient and Doctor roles, and enforces EMR access rules at the service layer.
Relational database server managed via Sequelize ORM. Stores users (patients and doctors), timeslots, and appointment records.
Document database server managed via Mongoose ODM. Stores each patient's EMR documents and binary files via GridFS.
A dedicated microservice responsible for booking timeslots. It exists specifically to solve race condition problems over shared resources by serializing booking requests through the message queue.
Handles asynchronous side effects that the main server does not need to wait on — such as sending signup confirmation emails, booking confirmations, and cancellation notifications.
The message broker linking all three services. Two messaging patterns are used:
| Pattern | Participants | Behavior |
|---|---|---|
| Publish / Subscribe | Server → MailingAndNotificationService | Server publishes a message and does not wait for a response |
| Request / Response | Server ↔ BookingService | Server sends a booking request and waits for confirmation before proceeding |
The main server follows a strict layered architecture:
src/
├── controllers/ # Route handlers — parse requests, return responses
├── services/ # Business logic layer
├── repositories/ # Data access layer (DB queries)
└── models/ # Sequelize & Mongoose model definitions
- Docker and Docker Compose installed
- Node.js (for local development outside Docker)
openssl(for generating JWT secrets)
git clone https://github.com/your-org/cura.git
cd curaEach service that needs configuration has its own .env.docker file. Create them before starting the containers:
./Server/.env.docker./BookingService/.env.docker
# Server
PORT=
NODE_ENV=
# MySQL — dev environment
DATABASE_DEV_USERNAME=
DATABASE_DEV_PASSWORD=
DATABASE_DEV_DATABASE=
DATABASE_DEV_HOST=mysql_server # matches the docker-compose service name
DATABASE_DEV_PORT=3306
DATABASE_DEV_DIALECT=mysql
# MySQL — production environment
DATABASE_PROD_USERNAME=
DATABASE_PROD_PASSWORD=
DATABASE_PROD_DATABASE=
DATABASE_PROD_HOST=mysql_server
DATABASE_PROD_PORT=3306
DATABASE_PROD_DIALECT=mysql
# MySQL — test environment
DATABASE_TEST_USERNAME=
DATABASE_TEST_PASSWORD=
DATABASE_TEST_DATABASE=
DATABASE_TEST_HOST=mysql_server
DATABASE_TEST_PORT=3306
DATABASE_TEST_DIALECT=mysql
# MongoDB
MONGODB_URI=mongodb://mongoadmin:mongopasswd@mongo_server:27017/cura_nosql_db?authSource=admin
# RabbitMQ
RABBITMQ_HOST=rabbitmq_c # matches the container name
BOOKINGSERVICE_RABBITMQ_MAINQUEUE= # queue name shared with BookingService
# Nodemailer (SMTP credentials)
USER=
PASSWORD=
# Password hashing
SALT_ROUND=
# JWT secrets — generate with: openssl rand -hex 64
ACCESS_TOKEN_SECRET=
REFRESH_TOKEN_SECRET=openssl rand -hex 64Run this twice — once for ACCESS_TOKEN_SECRET and once for REFRESH_TOKEN_SECRET.
docker compose up --build| Service | Host Port | Notes |
|---|---|---|
| Server | 8080 |
Main API — http://localhost:8080 |
| MySQL | 3307 |
Mapped from container port 3306 |
| MongoDB | 27018 |
Mapped from container port 27017 |
| RabbitMQ Broker | 5672 |
AMQP port |
| RabbitMQ Management UI | 15672 |
http://localhost:15672 |
Note: The
BookingServiceandMailingAndNotificationServicehave no exposed host port — they communicate exclusively through RabbitMQ and are not directly accessible.
Cura uses CircleCI for continuous integration and deployment. The pipeline runs on every push and covers:
- Dependency installation
- Linting and testing
- Docker image build and push
- Deployment





