Skip to content

This repository contains the codebase for a notification system, designed for PME's photo editing and ordering app.

License

Notifications You must be signed in to change notification settings

ProgrammingMadeEasy-Community/notification-service

Repository files navigation

notification-service overview:

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.

API SPecification:

https://www.notion.so/PME-notification-service-API-specification-f25d5da025c4453bb6f73db22a93f354

Team:

  • Emmanuel Adebayo
  • Oludayo
  • Emmanuel Bolaji

Components:

We are implementing the web-queue-worker architecture for building reliable services, our setup would look like this: image

Notification API:

  • 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.

Serverless functions:

  • 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.

Database:

  • Stores notification metadata and user preferences.
  • Maintains information about sent notifications, including status, retries, and timestamps.

CRON job:

  • Reads the notification table and re enqueues failed notifications with retry count less than 3.

Data Flow:

  • 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.

Sample test:

npm run start

image

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
}'

image

About

This repository contains the codebase for a notification system, designed for PME's photo editing and ordering app.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published