This repository contains the codebase for a notification system, designed for PME's photo editing and ordering app. Our notification system consists of several components working together to deliver notifications to users over three channels (SMS, Email, Push). The system is built using JavaScript and leverages cloud services for scalability and reliability.
https://www.notion.so/PME-notification-service-API-specification-f25d5da025c4453bb6f73db22a93f354
- Emmanuel Adebayo
- Oludayo
- Emmanuel Bolaji
We are implementing the web-queue-worker architecture for building reliable services, our setup would look like this:
- Built using Node.js with Express framework.
- Receives notification requests from upstream services via HTTP POST requests.
- Builds the notification, reads user preferences and enqueues notification on the messaging queue.
- Queue triggered functions consume messages from a message queue and send notifications to the recipient over any of their preferred channels.
- Written in Node.js, utilising a cloud function that triggers every time a new message arrives on the queue.
- Stores notification metadata and user preferences.
- Maintains information about sent notifications, including status, retries, and timestamps.
- Reads the notification table and re enqueues failed notifications with retry count less than 3.
- Upstream services (e.g., other microservices, scripts, cron jobs) trigger notifications by sending requests to the Notification Microservice's HTTP POST endpoint.
- The Notification Microservice receives the notification requests and enqueues them into a message queue.
- Serverless functions consume messages from the queue and send notifications using third-party services providers.
- Notification status and metadata are logged in the database for tracking and retry purposes.
npm run start
curl -X POST http://localhost:3000/notifications -H 'Content-Type: application/json' -d '{
"userId": "user1",
"message": [
{
"sms": "Hello from SMS",
"phoneNumber": 1234567890
},
{
"email": "Hello from Email",
"emailAddress": "[email protected]"
},
{
"pushText": "Hello from Push",
"deviceType": "Android"
}
],
"status": "Pending",
"retryCount": 0
}'