Notification Service API
βοΈ
A comprehensive notification management REST API built with Java, Spring Boot, and PostgreSQL. Delivers notifications via email, SMS, push notifications, and in-app messages with templating and scheduling support.
Features
| Feature | Description | Icon |
|---|---|---|
| Multi-Channel Delivery | Send via email, SMS, push notifications, and in-app messages | π¨ |
| Template Management | Create and manage notification templates with variables | π |
| Scheduling | Schedule notifications for future delivery | β° |
| Delivery Tracking | Track delivery status and user interactions | π |
| Unsubscribe Management | Respect user preferences and unsubscribe requests | π« |
| Rate Limiting | Prevent notification spam with configurable limits | β‘ |
| Multi-Tenant Support | Isolate notifications per tenant | π’ |
Architecture Overview
flowchart TD
A[Client] -->|REST API| B(NotificationController)
B --> C[NotificationService]
C --> D[TemplateService]
C --> E[ChannelService]
D --> F[TemplateRepository]
E --> G[EmailProvider]
E --> H[SMSProvider]
E --> I[PushProvider]
F --> J[(PostgreSQL)]
C --> K[Message Queue]
Hold "Alt" / "Option" to enable pan & zoom
API Endpoints
Note: Real API endpoints to be provided and included here.
| Method | Endpoint | Description | Notes/Parameters |
|---|---|---|---|
| POST | /api/v1/notifications/send |
Send notification immediately | tenantId header, notification data |
| POST | /api/v1/notifications/schedule |
Schedule notification for later | Scheduled time, notification data |
| GET | /api/v1/notifications/{id} |
Get notification details | |
| POST | /api/v1/templates |
Create notification template | Template name, body, variables |
Sequence: Send Scheduled Notification
sequenceDiagram
participant U as User
participant API as NotificationController
participant N as NotificationService
participant T as TemplateService
participant Q as Message Queue
participant C as ChannelService
U->>API: POST /notifications/schedule (template, time)
API->>N: validate notification
N->>T: load template
T-->>N: template loaded
N->>Q: queue scheduled notification
Q-->>N: queued
N-->>API: NotificationResponse
API-->>U: 201 Created + notification details
Note over Q,C: At scheduled time...
Q->>N: trigger notification
N->>C: send via channels
C->>C: email + SMS
C-->>N: delivery confirmed
Hold "Alt" / "Option" to enable pan & zoom
Database Schema
erDiagram
notifications {
UUID id PK
UUID tenant_id
VARCHAR notification_type
VARCHAR recipient
VARCHAR channel
VARCHAR status
TIMESTAMP scheduled_at
TIMESTAMP sent_at
TIMESTAMP created
TIMESTAMP updated
}
notification_templates {
UUID id PK
UUID tenant_id
VARCHAR template_name
VARCHAR template_type
TEXT template_body
TEXT subject
JSON variables
TIMESTAMP created
TIMESTAMP updated
}
user_preferences {
UUID id PK
UUID user_id
UUID tenant_id
BOOLEAN email_enabled
BOOLEAN sms_enabled
BOOLEAN push_enabled
BOOLEAN in_app_enabled
TIMESTAMP updated
}
delivery_logs {
UUID id PK
UUID notification_id FK
VARCHAR delivery_channel
VARCHAR delivery_status
TEXT error_message
TIMESTAMP delivered_at
TIMESTAMP created
}
notifications ||--o{ delivery_logs : "tracked_by"
Hold "Alt" / "Option" to enable pan & zoom
Getting Started
Prerequisites
- Java 17+
- PostgreSQL
- Gradle
- Message Queue (RabbitMQ/Kafka)
Setup
git clone https://github.com/Olanna-tech/notification-service-java.git
cd notification-service-java
./gradlew build
Database
- Configure your PostgreSQL credentials in
src/main/resources/application.yml. - Run Flyway migrations (auto on startup).
Run
./gradlew bootRun
Configuration
Set the following environment variables in application.yml:
notification:
email-provider: sendgrid
sendgrid-api-key: your-api-key
sms-provider: twilio
push-provider: firebase
rate-limit-per-user-per-day: 100
queue-type: rabbitmq
Contributing
Pull requests are welcome! For major changes, please open an issue first.
License
Contact
- Olanna
- support@Olanna.tech