Back to Blog

Building a Notification System from Existing Data: Likes, Bookmarks, and More

Royan Gagas
August 4, 2025
Share
journey
product
nextjs
nodejs
development
Building a Notification System from Existing Data: Likes, Bookmarks, and More

When we think of adding a notification system, most of us imagine sending alerts for real-time events a user likes a post, bookmarks something, leaves a review, etc. But what if those actions already happened before the notification system was even built?

That was the exact situation I faced. Here's how I handled it.



The Problem

In my product Rekkoku, users could already interact with posts liking them, bookmarking interesting places, or reviewing content.

But something was missing: feedback. There was no way for users to know when their content was being engaged with.

Why? because at that time, Rekkoku didn't have a notification system yet.



Step 1: Define the Notification Model

The firts step was to create a new Notification model. I designed it with essential attributes:

user_id : who should receive the notification
actor_id : who triggered the action
type : like, bookmark, review, etc.
related_entity_id : the target post/place/etc.
read : boolean to mark when the notification was read

This structure gave me flexibility for multiple types of events.



Step 2: Build Routes, Controllers, and Services

I created basic API routes to interact with notifications:

GET /notifications : retrieve all notifications for a user
POST /notifications/mark/:id : mark one as read
POST /notifications/mark-all-read : mark all as read

Theses APIs are fetched manually by the frontend either on page load, or on some user action like opening a notification panel.

💡Note: This is not a real-time system, there's no WebSocket or push notification involved (yet). It works more like polling, data is fetched when the user opens the notification panel.



Hmmm...But where's the Data?

After setting up everything, I ran the project and opened the notification panel.

EMPTY

Despite knowing that users had already liked and bookmarked plenty of things, none of that data showed up.



Step 3: Syncing Old Data

The solution? I wrote a data migration script to generate notifications based on existing likes and bookmarks.

Loop throught all likes/bookmarks
For each entry, check if a notification already exists (avoid duplicates)
Insert a new notification if not found

I also added event triggers for new activities like:

Reviewing a post
Reviewing a place

(These will be covered in another post)



Final Result

After running the script, I refreshed the notification view...

Tadaaa!🎉

Everything was there, neatly displayed, with the ability to mark items as read. A once empty screen was now full of meaningful activity.