This project implements a Notification Service that can send Email, Push Notifications, and is designed to be easily extensible to support other notification types like SMS and Slack etc.
The service is designed to be used as a C# class library, which can be plugged into various applications, ensuring easy integration, scalability, and maintainability.
-
Extensible: Easily extendable to support new notification providers (e.g., SMS, Slack, etc.).
-
Non-blocking: The service processes notifications asynchronously, ensuring that the system remains responsive.
-
Error Handling: Handles failure cases gracefully, such as when a notification provider is unreachable.
-
Clean Code: Follows SOLID principles and design patterns (like the Decorator Pattern) for maintainability and flexibility
- NotificationServiceLibrary (C# Class Library)
- Models: Contains models for request and result objects, such as
NotificationRequest
andNotificationResult
. - Services: The core service (
NotificationService
) responsible for managing and sending notifications through registered providers. - Providers: Contains implementations of different notification providers (e.g.,
EmailNotificationProvider
,PushNotificationProvider
).
- NotifyManagerConsole (Test Application – C# Console APP)
A console application to test the notification service library. It simulates the sending of different types of notifications and logs the results
- Testing Multiple Providers
You can test the notification service with multiple providers by creating different NotificationRequest objects and passing them to the NotificationService.
var emailRequest = new NotificationRequest { Type = NotificationType.Email, Recipient = "[email protected]", Message = "Test Email Notification" };
var pushRequest = new NotificationRequest { Type = NotificationType.Push, Recipient = "+923302533681", Message = "Test Push Notification" };
var requests = new List { emailRequest, pushRequest }; var results = await notificationService.SendNotificationsAsync(requests);
- Handling Failures
If a notification fails (e.g., due to a bad recipient or a network issue), the service will catch the exception and return an error in the result.
- Bulk Notifications
You can send a batch of notifications by creating multiple NotificationRequest objects and passing them to the NotificationService.
var bulkRequests = Enumerable.Range(1, 100).Select(i => new NotificationRequest
{
Type = NotificationType.Email,
Recipient =
var results = await notificationService.SendNotificationsAsync(bulkRequests)
- Clone the repository or download the solution.
- Build the solution in Visual Studio.
- Run the Console Application to simulate sending notifications. The console application will show the results of sending different types of notifications (Email, Push) to different recipients.
o Implement new providers such as SMS, Slack, and Webhook.
o Optionally, the notification service can be extended to log results to a database or integrate with external systems.
o Improve error handling to support retry logic, circuit breakers, etc.
This notification service provides a flexible, extensible, and non-blocking architecture for handling different types of notifications (Email, Push, etc.). It is designed to be easily integrated into any system, and its extensibility ensures that additional notification types can be added seamlessly in the future.