This project is a production-style distributed notification system built with NestJS and RabbitMQ.
It demonstrates how modern backend systems handle asynchronous communication, event-driven architecture, and reliable message delivery for Email, SMS, and Push notifications.
- Showcase RabbitMQ messaging patterns used in real production systems
- Demonstrate event-driven microservice architecture
- Implement reliable notification delivery with retries and Dead Letter Queues (DLQ)
- Separate responsibilities using publisher–consumer design
- Gain hands-on experience with NestJS, message queues, Docker, and Prisma
✔ Event-driven communication using RabbitMQ Topic Exchanges
✔ Asynchronous Email / SMS / Push notification processing
✔ Retry mechanism with Dead Letter Queues (DLQ)
✔ Message acknowledgment & failure handling
✔ Email templating with Handlebars
🚧 Persistent notification logs using PostgreSQL + Prisma
✔ Dockerized local development environment
✔ Clean, extensible backend architecture
- NestJS / Node.js
- RabbitMQ (AMQP)
- PostgreSQL
- Prisma ORM
- Nodemailer (Email)
- Handlebars (Email templates)
- Docker & Docker Compose
- RabbitMQ Management UI
- Postman (API testing)
flowchart TB
%% Clients
C[Client / Frontend / External Service]
%% API Gateway
C -->|HTTP REST| API[API Gateway<br/>NestJS]
%% Exchange
API -->|Publish Event<br/>routingKey| EX((RabbitMQ<br/>Topic Exchange<br/>notifications.topic))
%% Routing
EX -->|user.signup.email<br/>order.completed.email| QEMAIL[Queue: queue.email]
EX -->|notify.sms| QSMS[Queue: queue.sms]
EX -->|notify.push| QPUSH[Queue: queue.push]
%% Consumers
QEMAIL --> EMAIL[Email Consumer<br/>Notification Service]
QSMS --> SMS[SMS Consumer<br/>Notification Service]
QPUSH --> PUSH[Push Consumer<br/>Notification Service]
%% Retry Logic
EMAIL -->|ACK success| ACK1[(Ack)]
EMAIL -->|Fail + Retry <= 3| RETRY1[Requeue with attempt++]
EMAIL -->|Fail after max retries| DLQEMAIL[Email DLQ]
SMS -->|Fail| DLQSMS[SMS DLQ]
PUSH -->|Fail| DLQPUSH[Push DLQ]
%% External Providers
EMAIL --> SMTP[SMTP / SendGrid]
SMS --> TWILIO[Twilio / Mock SMS]
PUSH --> FCM[Firebase FCM]
%% Database
EMAIL --> DB[(PostgreSQL<br/>Notification Logs)]
SMS --> DB
PUSH --> DB
%% Monitoring
API --> METRICS[/Metrics Endpoint/]
EMAIL --> METRICS
The API Gateway exposes REST endpoints such as:
/signup/order/notify
When an API request is received:
- Input is validated
- An event message is created
- The message is published to RabbitMQ using a topic exchange
- The API responds immediately (non-blocking)
➡️ The API never sends notifications directly
- Uses a Topic Exchange:
notifications.topic - Routes messages using routing keys such as:
user.signup.emailorder.completed.emailnotify.sms
RabbitMQ ensures:
- Message durability
- Loose coupling between services
- Horizontal scalability
The Notification Service listens to queues:
queue.emailqueue.smsqueue.push
For each message:
- Message is consumed
- Business logic is executed (send email/SMS/etc.)
- Result is logged to database
- Message is acknowledged (
ACK) on success
If message processing fails:
- The message is retried up to 3 times
- Retry count is tracked via headers
- After max retries → message is sent to DLQ
This prevents:
- Infinite retry loops
- Queue blocking
- Silent message loss
- Emails are rendered using Handlebars
- Templates are reusable and data-driven
- Allows clean separation of content and logic
Example:
Each notification attempt is persisted with:
- Event type
- Channel (email/sms/push)
- Status (success / failed)
- Retry count
- Payload snapshot
- Timestamp
This enables:
- Auditing
- Debugging
- Metrics & analytics
docker-compose up -dhttp://localhost:15672
username: guest
password: guest
- Import the provided Postman collection
- Or run:
bash curl_examples.sh- Uses real backend patterns, not tutorials
- Demonstrates production RabbitMQ concepts
- Shows system design thinking
- Easily extensible to Kafka or cloud messaging
- Clear separation of concerns and scalability
- Kafka implementation for comparison
- Prometheus + Grafana monitoring
- Rate limiting & deduplication
- Webhook notifications
- Admin dashboard for logs
Built as a backend-focused project to demonstrate event-driven systems, messaging reliability, and scalable notification architecture.