POST /notifications/preferences/{userId} body:{notificationType: string; isEnabled:boolean} - with this endpoint, the users can turn on/off specific notifications receival
GET /analytics/notifications for admins to track user engagements with notifications
POST /analytics/action/user/{userId}/notification/{notificationId} - used when user clicks on notifications, in order to saved the action to db
GET /analytics/notifications/{userId} for admins to track a user engagements with notifications (clicks,dismisses)
GET /notifications/preferences/{userId} - gets all notification preferences for a specific user if provided or for all users
GET /notifications/{userId} - gets all received notifications for a user or all users - used by admins
POST /send/notification body:{userId:string; message:string; type:SMS | mail | APNS | FCM} used to create the notification entry on our side and calls the third party provider for sending the notification
GET /notifications/{notificationId} - gets the info for a specific notification (status, sentAt, userId, type) about its delivery status, when was it sent, etc
POST /send/notifications body:{userIds:JSON; message:string; type:SMS | mail | APNS | FCM} used to create the notification entries on our side and calls the third party provider for sending the same notification to multiple users at once - eg for updates or global messages
updating user notification preferences flow:
sending notifications flow:
scheduled notifications flow:
service calls notification servers, which can be scaled out during high spikes automatically using kubernetes (it increases the number of pods when in need);
then based on notification type (iOS, android, web) it is mapped to the corresponding queue (iOS PN queue, FCM PN queue or web queue), then each queue gets consumed from by workers. and then the workers call the corresponding delivery service with the notification message: APN, FCM and web push api which push notifications to devices.
in case of failures, notification sending is being retried by pushing the message back to queues to be reprocessed. no notification is sent twice because it is saved in the db with its status and in case a second thread also tries to deliver it, it firstly checks the db to make sure the notificaton isnt already being processed.
during high traffic notifications cant be lost because they are pushed to queues, we can increase the number fo queues if they reach 90% capacity; and workers consume from them at their own pace, so even if the notifications are delivered with a delay, they are surely delivered.