3

I'm learning backend and API development and trying to understand how to implement some features from scratch without using any paid third party service.

I want to understand this concept from design as well as implementation pov. Please share if you have any resources where I can learn how to code the below service.


How to build in app notification service like one of these from scratch ?

  • Notification when user likes or comments on a post (Instagram, Twitter)
  • Notification when someone views your profile (Linkedin)
  • Notication when a channel you are subscribed to uploads a video (Youtube)

These are different from push notifications like

  • Notification when someone sends you a message (All chat apps)
  • Live status via notification of your delivery (Food delivery apps)

Push notifications need not be stored permanently in any database but what happens with in app notifications? How to build such service which is scalable too.

One possible solution I could think of is this, for notification on post like

  • User A has made a post.
  • User B likes their post.
  • From likePost API emit an event which will notify User A that User B liked their post, listen for these real time events on client side. This can be done via sockets.
  • Do not store any notifications in database, just update the notifications in UI on that event emitted by likePost API or listen to real time changes in likes attribute of a User's Post table (is this possible?) and update UI.
  • In UI just show all such notifications by fetching from likes and comments table.

But I wonder how scalable is this approach.


I searched but couldn't find any good resources regarding this, so please if anyone could explain this or provide link to any blog or videos it will be helpful. (P.s. I'm an undergrad student and don't have experience in system design and architectures, just started learning about these so just curious)

Thanks.

Abhishek Jha
  • 111
  • 1
  • 11
  • Notification systems are very complex to build and scale. It primarily uses an event driven architecture (EDA) that communicates through message brokers and queues to do tasks like template parsing, user preference checks, provider API call, DB store etc. For In-app you might need a realtime connectivity, as well as persisted store. But scaling the store would be tricky, so you might need partitioning as well. – anand Jun 30 '23 at 13:54

1 Answers1

0

apps like Facebook, Instagram and linkedIn provides web hook of notifications. Webhooks allow you to receive real-time HTTP notifications for subscribed events. This functionality is only available for applications with an approved use case for webhooks. Webhhook received as a notification when user comment on your post or like your post, a web hook can be used to retrieve the information of post, comment and commentor etc.

I am attaching a reference of LinkedIn web-hook.

https://learn.microsoft.com/en-us/linkedin/shared/api-guide/webhook-validation

Dharman
  • 30,962
  • 25
  • 85
  • 135