A high-performance, fault-tolerant microservice for enterprise notification management
- Overview
- Key Features
- Architecture
- Technology Stack
- Use Cases
- Getting Started
- API Documentation
- Deployment
- Monitoring & Logging
- Contributing
The Notification System is a production-ready microservice designed to centralize and streamline all notification operations for enterprise backends. Built with Java Spring Boot and powered by Apache Kafka, this system provides asynchronous, scalable, and reliable notification delivery across multiple channels including Email, SMS, Push Notifications, and Webhooks.
- Decouple notification logic from your core application
- Scale independently to handle millions of notifications
- Guarantee delivery with fault-tolerant architecture
- Track and audit every notification lifecycle
- Reduce development time by reusing notification infrastructure
- Email - SMTP-based email delivery with HTML template support
- SMS - SMS gateway integration for text notifications
- Push Notifications - Mobile and web push notification delivery
- Webhooks - HTTP callback integration for external systems
- Apache Kafka integration for asynchronous, distributed message processing
- Event-driven architecture ensuring non-blocking operations
- Automatic retry mechanism with configurable retry policies
- Dead Letter Queue (DLQ) for failed message handling
- Priority-based delivery (LOW, MEDIUM, HIGH, URGENT)
- Scheduled notifications with precise timing control
- Template management for reusable notification formats
- User preference management for channel-specific opt-in/opt-out
- Broadcast notifications to all users simultaneously
- Comprehensive tracking with delivery status and audit trails
- Real-time statistics and analytics dashboard
- Admin panel for notification monitoring and management
- Quiet hours support respecting user time zones
- Frequency limiting to prevent notification fatigue
- Docker & Docker Compose ready for containerized deployment
- Jenkins pipeline for CI/CD automation
- MongoDB for flexible data persistence
- Health checks and monitoring endpoints
- Structured logging with Logback integration
The system follows a microservices architecture pattern with event-driven communication:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Client App │─────▶│ REST API │─────▶│ Kafka Producer │
│ (Your Backend) │ │ (Controller) │ │ │
└─────────────────┘ └──────────────────┘ └────────┬────────┘
│
▼
┌──────────────────────────────────────────┐
│ Apache Kafka Topic │
│ (notification-events) │
└────────┬─────────────────────────────────┘
│
▼
┌──────────────────┐
│ Kafka Consumer │
│ (Event Handler) │
└────────┬─────────┘
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Email Channel│ │ SMS Channel │ │ Push Channel │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
└─────────────────┴──────────────────┘
│
▼
┌──────────────────┐
│ MongoDB │
│ (Persistence) │
└──────────────────┘
- REST API Layer - Spring Boot controllers exposing notification endpoints
- Kafka Producer - Publishes notification events to Kafka topics
- Kafka Consumer - Processes events asynchronously and routes to channels
- Channel Registry - Strategy pattern implementation for pluggable notification channels
- MongoDB Repository - Stores notification data, user preferences, and audit logs
- Admin Service - Management interface for monitoring and operations
| Component | Technology | Version |
|---|---|---|
| Runtime | Java | 17+ |
| Framework | Spring Boot | 3.x |
| Message Broker | Apache Kafka | 7.4.0 (KRaft mode) |
| Database | MongoDB | 6.0 |
| JavaMail API | - | |
| Build Tool | Maven | 3.x |
| Containerization | Docker & Docker Compose | - |
| CI/CD | Jenkins | - |
| Logging | Logback | - |
- Order confirmation emails
- Shipping notifications via SMS
- Abandoned cart reminders
- Flash sale push notifications
- Transaction alerts via SMS
- Account activity emails
- Payment reminders
- Security alerts (high priority)
- User onboarding emails
- Feature announcements
- System maintenance notifications
- Usage limit warnings
- Appointment reminders
- Lab result notifications
- Medication reminders
- Emergency alerts
- Comment and mention notifications
- Friend requests
- Content moderation alerts
- Daily digest emails
Before running the application, ensure you have the following installed:
git clone https://github.com/siddhantkore/Notification-System. git
cd Notification-SystemStart MongoDB and Kafka using Docker Compose:
docker-compose up -dThis will start:
- Apache Kafka on
localhost:9092(KRaft mode, no Zookeeper required) - MongoDB on
localhost:27017(credentials:admin/password123)
Verify services are running:
docker-compose ps./mvnw clean install./mvnw spring-boot:runOr use the convenience script:
chmod +x local-run.sh
./local-run. shThe application will start on http://localhost:8080
Create src/main/resources/application. properties or application.yml with your configuration:
# Server Configuration
server.port=8080
# MongoDB Configuration
spring.data.mongodb. host=localhost
spring.data.mongodb.port=27017
spring. data.mongodb.database=notification
spring.data.mongodb.username=admin
spring.data.mongodb.password=password123
spring.data.mongodb.authentication-database=admin
# Kafka Configuration
spring.kafka.bootstrap-servers=localhost:9092
spring.kafka.producer.key-serializer=org.apache. kafka.common.serialization.StringSerializer
spring.kafka.producer. value-serializer=org.springframework.kafka.support.serializer. JsonSerializer
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.springframework. kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.group-id=notification-consumer-group
spring.kafka.consumer.auto-offset-reset=earliest
# Email Configuration (Update with your SMTP settings)
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your-email@gmail.com
spring. mail.password=your-app-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
# Logging
logging.level.com.jetnotifier=INFO
logging.level. org.apache.kafka=WARN
logging.level.org. springframework.kafka=WARNAlternatively, configure using environment variables:
export MONGODB_HOST=localhost
export MONGODB_PORT=27017
export KAFKA_BOOTSTRAP_SERVERS=localhost:9092
export SMTP_HOST=smtp.gmail.com
export SMTP_PORT=587
export SMTP_USERNAME=your-email@gmail.com
export SMTP_PASSWORD=your-app-passwordEndpoint: POST /api/notifications
Request Body:
{
"userId": "user123",
"title": "Order Shipped",
"message": "Your order #12345 has been shipped! ",
"type": "EMAIL",
"priority": "HIGH",
"metadata": {
"orderId": "12345",
"trackingNumber": "TRK-9876"
}
}Response:
{
"id": "notification-id",
"status": "PENDING",
"createdAt": "2026-01-20T10:30:00"
}Endpoint: GET /api/notifications/user/{userId}
Query Parameters:
page- Page number (default: 0)size- Page size (default: 20)status- Filter by status (PENDING, SENT, FAILED)
Endpoint: GET /api/notifications/{id}
Response:
{
"id": "notification-id",
"userId": "user123",
"title": "Order Shipped",
"type": "EMAIL",
"status": "SENT",
"sentAt": "2026-01-20T10:31:05",
"retryCount": 0
}Endpoint: POST /api/admin/broadcast
Send notification to all users:
{
"title": "System Maintenance",
"message": "Scheduled maintenance on Jan 25, 2026",
"type": "EMAIL",
"priority": "MEDIUM"
}Endpoint: GET /api/admin/stats
Response:
{
"total": 15420,
"sent": 14892,
"failed": 123,
"pending": 405,
"successRate": 96.58
}Endpoint: PUT /api/users/{userId}/preferences
{
"emailEnabled": true,
"smsEnabled": false,
"pushEnabled": true,
"quietHoursStart": "22:00",
"quietHoursEnd": "08:00",
"timezone": "America/New_York"
}docker build -t notification-system: latest .The application includes a complete docker-compose.yml for production deployment:
docker-compose up -dThis orchestrates:
- Notification System application
- Apache Kafka (KRaft mode)
- MongoDB
environment:
- SPRING_DATA_MONGODB_HOST=mongodb
- SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:29092
- SPRING_MAIL_HOST=smtp.gmail.com
- SPRING_MAIL_USERNAME=${SMTP_USERNAME}
- SPRING_MAIL_PASSWORD=${SMTP_PASSWORD}- Application Health:
GET /actuator/health - Kafka Health: Auto-configured via Docker healthcheck
- MongoDB Health: Auto-configured via Docker healthcheck
Logs are stored in logs/application.log with daily rotation:
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/archived/notification_system_%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>Access the admin dashboard at http://localhost:8080/ for:
- Real-time notification statistics
- Success/failure rates
- Channel-wise metrics
- User engagement analytics
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Siddhant Kore
- Email: Siddhant Kore
- GitHub: @siddhantkore
- Project Link: https://github.com/siddhantkore/Notification-System
Built using Spring Boot and Apache Kafka
⭐ Star this repository if you find it helpful!