This is a scalable, microservices-based system for multi-channel notifications (email & push).
The solution is composed of the following services:
api-gateway(Laravel): Main entrypoint & orchestrator.user-service(NestJS): Manages user profiles, contact info, notification preferences.template-service(NestJS): Manages notification templates, variable rendering.email-service(NestJS): Delivers email notifications.push-service(NestJS): Delivers push notifications.rabbitmq: Queue broker powering async delivery and retries.postgres: Data storage for gateway/service state.redis: Caching and idempotency for notifications.nginx: Reverse proxy and static asset handler.
See system-design.png for full diagram.
Main Flow:
- Client/system sends notification request to API Gateway.
- Gateway validates data, checks idempotency, fetches user info.
- Notification details are stored in DB and published to RabbitMQ.
- Email and Push services consume queue messages, fetch templates, personalize, deliver notifications.
- Services post delivery status updates to API Gateway, which updates notification records.
- Monitoring endpoints and logs provide visibility into system health and operations.
- Idempotency and duplicate prevention.
- Horizontal scaling of API and delivery services.
- Dead letter queues and retry strategies for failed messages.
- Real-time queue monitoring via RabbitMQ UI (localhost:15672).
- Centralized health checks for all dependencies.
- Docker (and docker-compose)
- NodeJS / npm
- PHP >= 8.2
- Composer
-
Clone repository
git clone <repo-url> cd distributed-notification-system -
Start all services
docker-compose up --build -
Access API Gateway
- Via Nginx:
http://localhost:8000
- Via Nginx:
-
RabbitMQ management
http://localhost:15672(guest/guest)
-
Run tests
- API Gateway:
cd api-gateway php artisan test
- API Gateway:
| Service | Port | Description |
|---|---|---|
| api-gateway | 8000 | Main API |
| user-service | 4000 | User profiles & preferences |
| template-service | 4100 | Template management |
| email-service | 4200 | Email delivery |
| push-service | 4300 | Push delivery |
| rabbitmq | 5672/15672 | Queue broker / Management UI |
| postgres | 5432 | Database |
| redis | 6379 | Cache |
distributed-notification-system/ ├── api-gateway/ ├── user-service/ ├── email-service/ ├── push-service/ ├── template-service/ ├── nginx.conf ├── docker-compose.yml └── system-design.png
- All environment variables for each service are managed in their respective
.envfiles. - Make sure to adjust connection strings, secrets, and ports as needed per environment.
- The system supports horizontal scaling for stateless services.
- Queued message ingestion auto-scales with consumers.
- Can be deployed to any cloud or on-premise environment supporting Docker.
- Check logs (
docker-compose logs <service>). - Use health endpoints (
/v1/health, etc.). - Access RabbitMQ management for message queue diagnostics.
MIT