A production-grade event-driven notification system built with Go that demonstrates asynchronous processing, reliable message delivery, real-time notifications, and a scalable microservice architecture.
The system is built around independent services communicating through Redis Streams and Redis Pub/Sub, making it easy to extend with additional notification channels.
- Overview
- Architecture
- Notification Flow
- Features
- Project Structure
- Tech Stack
- Running the Project
- Reliability & Observability
- Future Improvements
EDNS is composed of three independent services:
- API Service
- Worker Service
- WebSocket Service
Notifications are created through the REST API, processed asynchronously by workers, and delivered through multiple notification channels.
Client
│
▼
API Service
│
PostgreSQL + Redis Streams
│
▼
Worker Service
│ │
▼ ▼
SMTP Email Redis Pub/Sub
│
▼
WebSocket Service
│
▼
Connected Clients
- Client creates a notification through the REST API.
- API stores notification data in PostgreSQL.
- Notification ID is published to Redis Streams.
- Worker consumes the message using Redis Consumer Groups.
- Worker processes each delivery channel.
- Email notifications are sent through SMTP.
- WebSocket notifications are published through Redis Pub/Sub.
- WebSocket Service pushes notifications to all connected user sessions.
- Failed deliveries are retried and eventually moved to the Dead Letter Queue (DLQ).
- REST API
- PostgreSQL Persistence
- Repository-Service Architecture
- Configuration Management
- Docker & Docker Compose
- Redis Streams
- Redis Consumer Groups
- Reliable Message Acknowledgement
- Automatic Retry Logic
- Dead Letter Queue (DLQ)
- Pending Message Recovery (
XAUTOCLAIM) - Multiple Worker Support
- Email Notifications (SMTP)
- WebSocket Notifications
- Redis Pub/Sub
- Multiple Active Connections Per User
- Structured Logging (Zap)
- Health Checks
- Readiness Checks
- Prometheus Metrics
- Graceful Shutdown
- Fault Tolerant Workers
- Delivery Status Tracking
- Notification Status Synchronization
api-service/
worker-service/
websocket-service/
internal/
├── config/
├── events/
├── logger/
├── models/
├── observability/
├── repository/
├── stream/
└── validation/
configs/
deploy/
migrations/
Language
- Go
Framework
- Gin
Database
- PostgreSQL
- pgx
Messaging
- Redis Streams
- Redis Pub/Sub
Real-Time Communication
- Gorilla WebSocket
- SMTP
- Mailpit
Observability
- Prometheus
- Grafana
- Zap Logger
Containerization
- Docker
- Docker Compose
Production
make docker-up-prodDevelopment
make docker-up-devAvailable services:
| Service | Address |
|---|---|
| API | http://localhost:8080 |
| Worker | http://localhost:8081 |
| WebSocket | ws://localhost:8082/api/ws |
| Mailpit | http://localhost:8025 |
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3001 |
- Redis Consumer Groups
- Automatic Retries
- Dead Letter Queue
- Pending Message Recovery
- Graceful Shutdown
- Multiple Worker Support
- Structured Logging
- Health Endpoint
- Readiness Endpoint
- Prometheus Metrics
- Event-Driven Architecture
- Producer-Consumer Pattern
- Repository Pattern
- Service Layer
- Distributed Workers
- Redis Streams
- Redis Consumer Groups
- Redis Pub/Sub
- Dead Letter Queue
- Retry Mechanism
- WebSocket Connection Management
- Fault Tolerance
- Horizontal Scalability
- Unit & Integration Tests
- Grafana Dashboards
- OpenTelemetry Tracing
- CI/CD Pipeline
- Kubernetes Deployment
- Authentication & Authorization
- Rate Limiting
- Additional Notification Channels