Skip to main content

Purpose

The Notification Service consumes domain events from Kafka and dispatches notifications to users and creators across three channels: push (APNs/FCM), email (transactional ESP), and in-app (persistent notification feed). It is a pure fan-out consumer — it does not own business logic for determining whether a notification should be sent, only how and when to deliver it.

Responsibilities

ResponsibilityDetail
Push notificationsDelivers mobile push via APNs (iOS) and FCM (Android). Tokens registered at app login and de-registered on logout. Delivery failures are retried up to 3 times with jitter before dropping.
Email dispatchTransactional email via a third-party ESP (e.g., SendGrid, AWS SES). Template-rendered HTML/text emails sent for: subscription confirmations, payment receipts, moderation decisions, and creator milestone alerts.
In-app notificationsNotification records written to Postgres and surfaced via a paginated API. Users see a notification badge and an in-app feed. Read status is tracked per notification per user.
Creator alertsNew comment, new subscriber, content moderation outcome, and payout processed notifications delivered to creators.
Viewer alertsNew upload from subscribed creator. Subscription renewal reminder.
Preference managementUsers can configure notification channel preferences and opt out of non-essential categories. Preferences stored in Postgres; checked before dispatch.

API Surface

MethodEndpointAuthDescription
GET/api/v1/notificationsBearerPaginated in-app notification feed
PATCH/api/v1/notifications/{notificationId}/readBearerMark notification as read
DELETE/api/v1/notifications/allBearerClear all notifications
GET/api/v1/notifications/preferencesBearerGet notification channel preferences
PATCH/api/v1/notifications/preferencesBearerUpdate notification preferences

Data Owned

StoreContent
Postgresnotifications (id, user_id, type, title, body, read, created_at), notification_preferences (user_id, push_enabled, email_enabled, category_opt_outs[])

Kafka Topics

TopicAction
media.publishedConsumed — triggers “new upload” notification to creator subscribers
engagement.subscription.changedConsumed — triggers “new subscriber” notification to creators
moderation.flaggedConsumed — triggers moderation decision notification to creators
payment.processedConsumed — triggers payment confirmation notification to subscribers

Failure Behaviour

FailureBehaviour
Push delivery failureRetried 3 times with exponential jitter. After 3 failures, the notification is dropped and a log entry is written. Permanent device token failures (APNs BadDeviceToken) trigger automatic token de-registration.
ESP (email) unavailableEmail queue backed up in an internal retry queue. Retried for up to 24 hours before alerting on-call. Non-critical path — no streaming impact.
Notification Service unavailableKafka consumer lag increases. Notifications are delayed but not lost — topics have sufficient retention (7 days) to catch up on recovery. No streaming impact.

Build docs developers (and LLMs) love