I am making a social media app. I have a use case in which i have to cluster similar type of data. For example, take Instagram. When a user likes a post, we get a notification that 'x likes your post'. Same in the case of follow. If 3 more users liked that post and 2 more followed the user, after some time, notification becomes 'x and 3 others like your post' and 'y and 2 others followed you'. This is something i have to achieve. Post, Like and Follow data is stored in PostgresSQL. I am also using MongoDB and Redis and more dbs can be added.
How should i cluster my notification data in this case? what should be the flow to cluster the notifications so that there shouldn't be any extra load over server or DB. Should it create a new notification in the db saying 'x and 3 others like your post' or should it just send it as a response on the front end?