Notifications API Reference
The faizanGeek/ClaimProcessingSystem leverages a robust notification system to keep users informed about critical updates, primarily focusing on claim status changes. This system is built on Apache Kafka for real-time messaging and utilizes email for delivering notifications directly to users.
This section details the API endpoints available for managing user notification preferences and outlines how claim status updates are delivered.
Overview of the Notification System
The system provides two main types of notification interactions:
- Automated Claim Status Updates: Whenever the status of a claim changes (e.g., from "Submitted" to "Processed" or "Approved"), the system automatically sends an email notification to the associated user. These notifications are critical for keeping claimants informed about the progress of their claims.
- User Subscription Management: Users can subscribe to or unsubscribe from general system notifications, controlling whether they receive broader communications beyond essential claim status updates. These preferences are managed via dedicated API endpoints.
The core of the notification system uses Kafka topics:
claim-status-updates: For broadcasting claim status changes internally.user-notifications: For initiating a user's subscription.unsubscribe-notifications: For signaling a user's request to unsubscribe.
Automated Notifications: Claim Status Updates
The Claim Processing System automatically sends email notifications to users when the status of their submitted claims changes. This is an outbound, event-driven notification that does not require an API call from the user's end to trigger.
How it works:
- When a claim's status is updated within the system (e.g., via the
updateClaimStatusmethod inClaimService), aClaimStatusUpdateMessageis published to the Kafka topic. - A dedicated Kafka consumer (
KafkaConsumerConfig) listens for messages on this topic. - Upon receiving a status update message, the system triggers an email notification to the user associated with the claim, informing them of the new status.
Example Email Notification:
Subject: Claim Status Update - Claim #12345
From: no-reply@example.com
To: user@example.com
Dear User,
Your claim #12345 has been updated to: Approved.
You can log in to the Claim Processing System to view more details.
Thank you,
The Claim Processing TeamAPI Endpoints for User Notification Preferences
These endpoints allow authenticated users to manage their subscription to general system notifications. The userId for these operations is typically derived from the authenticated user's session (e.g., via a JWT token), meaning it is not explicitly passed in the request body.
1. Subscribe to Notifications
Allows an authenticated user to opt-in to receiving general system notifications.
-
URL:
/api/notifications/subscribe -
Method:
POST -
Description: Sends a signal to the notification system to mark the authenticated user as subscribed to general system communications. An internal Kafka message is published (
user-notificationstopic) to process this subscription. -
Authentication: Required (JWT Bearer Token)
-
Request Body: None
-
Successful Response:
- Code:
200 OK - Body:
{"message": "Successfully subscribed to notifications."}
POST /api/notifications/subscribe HTTP/1.1 Host: localhost:8080 Authorization: Bearer <YOUR_JWT_TOKEN> Content-Type: application/json {}{ "message": "Successfully subscribed to notifications." } - Code:
-
Error Response:
- Code:
401 Unauthorized(If authentication fails) - Code:
500 Internal Server Error(If an unexpected error occurs during processing)
- Code:
2. Unsubscribe from Notifications
Allows an authenticated user to opt-out of receiving general system notifications.
-
URL:
/api/notifications/unsubscribe -
Method:
POST -
Description: Sends a signal to the notification system to mark the authenticated user as unsubscribed from general system communications. An internal Kafka message is published (
unsubscribe-notificationstopic) to process this unsubscription. -
Authentication: Required (JWT Bearer Token)
-
Request Body: None
-
Successful Response:
- Code:
200 OK - Body:
{"message": "Successfully unsubscribed from notifications."}
POST /api/notifications/unsubscribe HTTP/1.1 Host: localhost:8080 Authorization: Bearer <YOUR_JWT_TOKEN> Content-Type: application/json {}{ "message": "Successfully unsubscribed from notifications." } - Code:
-
Error Response:
- Code:
401 Unauthorized(If authentication fails) - Code:
500 Internal Server Error(If an unexpected error occurs during processing)
- Code: