Urgent.News

What's breaking now, across thousands of outlets.

Tech

The notification system you didn't plan to build

Originally published on the Elaan blog . Sending one email is one line of code. The system that grows around it takes months. We had to build that system three times for different products before making it the product, so here is the case for building it yourself and the case against, argued through the two requirements that usually settle it. Someone files a ticket: "users should be notified…

The notification system that seems simple at first becomes a complex, sprawling subsystem over time. Initially, sending an email seems like just one line of code, but the growth of features quickly follows. The initial requirement of notifying users when their report is ready leads to a cascade of additional features and requirements.

Users may not want to receive such emails, leading to the need for user preferences. The option to display notifications within the app itself necessitates an inbox with read/unread states, unread counts, and a notification bell. Push notifications on mobile devices further complicate the system, requiring device tokens, handling dead tokens, and differentiating push notifications for different notification types.

Marketing wants to change the wording, requiring templates and a separate editing system. Legal requirements, such as password reset emails not being opt-out-able, add more complexity. Some notification types may ignore preferences entirely, and a distinction between these types needs to be managed. An outage of the push notification provider for a short period leads to the need for an outbox, retries with backoff, and rules for which failures should be retried.

Finally, support cannot determine if a customer received the email, prompting the need for a delivery log. These requirements accumulate over the course of eighteen months, with each one starting as a single line of code but ultimately growing into a subsystem. The two main requirements that settle this issue are the branding of the notifications and the in-app inbox.

The branding requirement ensures that the customer's brand is represented in the notification, such as the clinic's name, logo, phone number, and reply-to address. This requirement becomes crucial in a B2B2C scenario where the customers receiving the notifications are not the same as the customer of the service providing the notifications.

The in-app inbox requirement adds another layer of complexity, necessitating an inbox with read/unread states, unread counts, and a notification bell. The solution to these complexities involves separating the notification branding from the template and keeping each tenant's identity as its own small record of values. Using this approach, the notification system becomes one call for sending notifications, and the branding values are resolved at render time. This approach simplifies the system and makes it easier to maintain, even as it grows and evolves.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Monday 24 August →