Notifications System Architecture Proposal #496
Replies: 2 comments 1 reply
-
Hi @BogoCvetkov and awesome work on describing the notifications! All looks quite good, I just have a few comments to try make our life simpler:
WIth this said, I think we can start the implementation as per your description and gradually extend to richer functionality. |
Beta Was this translation helpful? Give feedback.
-
Very well described solution! Congrats on that one! I am with @igoychev on this one and think we should stay away from adding even more software to our stack (it is already quite complicated). Reading through your notes I see that the idea is to have a generic eventing system that would allow us to send real-time updates in the UI, email notifications, marketing messages and whatever else we come up with later. Based on the description it looks to me that we can go for a much simpler solution. What you are proposing is a valid way of implementing this but I think it's over-engineered for our use-case. Your solution is intended for a highly-available, high-throughput and distributed processing implementations. I think we have the need for neither of those:
My proposal for solving this challenge is to use a simple table in Postgres. Actions in the platform can store the events in this table with all the necessary data. If we want to make it super generic we can use a We can then make a separate process (new deployment) that will be processing these events. I would say that we don't need to process anything in parallel. We just go top-to-bottom 1-by-1 and handle each event. This processor should store somewhere in the DB the last event that has been processed. In case the processor crashes or is re-deployed, it will read from the DB the last processed event ID and will start from the one after it. We can make the processor's architecture generic by allowing the registration of multiple plugins that handle the different types of events. We can store the events in the DB forever (at least for now), which will allow us to do re-processing if needed. |
Beta Was this translation helpful? Give feedback.
-
Motivation and context
Motivation
Context
Taking into consideration the above mentioned points here are the features of the notification system that have been analyzed when designing the architecture outlined in the next part:
Architecture Overview
DB Schema
To accommodate for the dynamic nature of the notification system, we would have a many-to-many relationship subscription table that maps the users to the events and an additional table for storing the templates for the notification messages. So we will have 3 new tables:
Events Table
id
(primary key)name
- name of the eventdescription
can_subscribe
- as mentioned above, not all events will be able for explicit subscription(signup,register, etc.), so we need to distinguish themtype
- user/admin or user + admin- determine for whom the events will be important -this field should make it easier on the FE to recognize the eventsTemplates Table
id
(primary key)name
- name of the templatedescription
content
- the actual notification messagecontent_type
-HTML
,Plain
etc.event_id
- (foreign key of the event)type
-system
/custom
Subscriptions Table
id
(primary key)uid
(foreign key of the user)event_id
(foreign key of the event)template_id
(foreign key of the template)medium
-Email
,SMS
,Viber
,Discord
etc.Separating everything into it's own table allows for the following flexibility:
BE Implementation
Having the ability to send multiple and different types of notifications and doing so reliably and efficiently requires a more robust and scalable approach. This is why a simple background worker won't cut it. That's why the best approach here would be to use a battle tested Message Broker. The two best options (taking into considerations the needs of the platform) are:
Advantages
Actual Implementation
funding_raised
and then everyone subscribed would be notifiedunrecognized_donation
, where all subscribed admins will get notified that an action should be takenHandlebars.js
as a popular framework for this particular taskDevOps Considerations
FE Considerations
We should generally discuss if the template creation will be on our side or if it will be offloaded to a marketing platform (MailChimp, MailGun, etc.). In the second case all we have to do is communicate with the marketing platform's API and in the case of the first approach, the following should be considered:
WYSIWYG
editor is probably the best way to visually create HTML .We already have aWYSIWYG
editor implemented on the FE -React-Quill
. It should be enough for defining and styling simple to moderately complex emails.UI/UX Considerations
Beta Was this translation helpful? Give feedback.
All reactions