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.
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.
The firts step was to create a new Notification model. I designed it with essential attributes:
user_id
: who should receive the notificationactor_id
: who triggered the actiontype
: like, bookmark, review, etc.related_entity_id
: the target post/place/etc.read : boolean
to mark when the notification was readThis structure gave me flexibility for multiple types of events.
I created basic API routes to interact with notifications:
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.
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.
The solution? I wrote a data migration script to generate notifications based on existing likes
and bookmarks
.
I also added event triggers for new activities like:
(These will be covered in another post)
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.