Skip to content

ravikant-pal/notification-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“£ Notification Service - Multi-Channel User Notifications

A lightweight Spring Boot microservice designed to send user notifications across multiple channels:

  • πŸ“§ Email (Plain Text + HTML)
  • πŸ“± SMS (Text Message)
  • πŸ’¬ WhatsApp

Built for scalability and easy integration across microservices, this service enables real-time communication with end users using pluggable notification providers.


πŸ“Œ Overview

This service allows other microservices to send notifications by simply calling an API. It abstracts the channel-specific logic and handles all formatting, templating, and delivery behind the scenes.

Supports:

  • Single or multi-channel delivery
  • Dynamic notification types (account alerts, OTPs, marketing, etc.)
  • HTML templating for rich email content
  • Message queuing or async processing (optional)

πŸš€ Features

βœ… Send notifications via Email, SMS, WhatsApp
βœ… Supports both plain text and rich HTML emails
βœ… Unified notification request format
βœ… Extensible channel-specific handlers
βœ… Easy to integrate with other services via REST or message queue
βœ… Logging and error handling for failed deliveries


πŸ› οΈ Tech Stack

  • Java 17+
  • Spring Boot 3+
  • JavaMail / SMTP for Email
  • Twilio (SMS), WhatsApp Business API (or other providers)
  • Thymeleaf / FreeMarker for HTML email templates
  • RabbitMQ / Kafka (optional async support)
  • Maven or Gradle

πŸ“¦ Installation

git clone https://github.com/ravikant-pal/notification-service.git
cd notification-service
./mvnw spring-boot:run

Update application.yml with SMTP credentials and provider API keys.


πŸ“¨ Notification API

πŸ” Endpoint

Method Endpoint Description
POST /api/v1/notifications/send Sends a notification to a user

πŸ“€ Request Payload

{
  "to": "ravikant@example.com",
  "channel": ["EMAIL", "SMS", "WHATSAPP"],
  "subject": "Welcome to Our Platform",
  "template": "welcome",
  "params": {
    "username": "Ravikant",
    "supportEmail": "support@yourdomain.com"
  },
  "isHtml": true
}
  • to: Receiver's identifier (email, phone, or WhatsApp number)
  • channel: Channels to send through (EMAIL, SMS, WHATSAPP)
  • subject: Subject for email (optional for SMS/WhatsApp)
  • template: HTML template name (for email rendering)
  • params: Dynamic values injected into the template
  • isHtml: Indicates if the email should be rendered as HTML

βœ‰οΈ HTML Email Templates

  • Located in /resources/templates/
  • Uses Thymeleaf or FreeMarker for dynamic content rendering

Sample welcome.html Template

<html>
<body>
    <h1>Welcome, [[${username}]]!</h1>
    <p>We’re glad to have you. If you need help, contact [[${supportEmail}]].</p>
</body>
</html>

πŸ“’ Multi-Channel Support

Each notification is routed through one or more of the following providers:

  • EMAIL: SMTP or SendGrid with HTML support
  • SMS: Twilio or any SMS gateway
  • WHATSAPP: WhatsApp Business API, Cloud API or Twilio

πŸ”§ Sample Integration from Another Service

curl -X POST http://localhost:8080/api/v1/notifications/send \
 -H "Content-Type: application/json" \
 -d '{
    "to": "ravikant@example.com",
    "channel": ["EMAIL"],
    "subject": "Login Alert",
    "template": "login-alert",
    "params": {
        "username": "Ravikant",
        "time": "10:45 PM"
    },
    "isHtml": true
}'

πŸ§ͺ Testing

./mvnw test

Covers:

  • Template rendering
  • Email/SMS/WhatsApp sending
  • Channel dispatching logic
  • Error handling

πŸ›‘οΈ License

This project is licensed under the MIT License. See the LICENSE file.


πŸ‘¨β€πŸ’» Author

Ravikant Pal
Backend Developer | Notifications & Messaging | Microservices
LinkedIn β€’ GitHub


🌟 Feedback / Contributions

Feel free to open an issue or PR:
πŸ‘‰ https://github.com/ravikant-pal/notification-service

About

A lightweight Spring Boot microservice designed to send user notifications across multiple channels: πŸ“§ Email (Plain Text + HTML)

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages