Class Diagrams
Class structure and responsibilities for backend Notification System delivery.
π€ Development Teamπ
Updated: Mar 16, 2026π Servicesπ·οΈ notificationsπ·οΈ backendπ·οΈ class-diagramπ·οΈ architecture
Class Diagrams
This page explains the backend class structure used to construct and deliver web notifications. The primary goals are:
- Standardise how notification payloads are built across types.
- Keep recipient resolution consistent and testable.
- Use a gateway layer so delivery mechanisms can evolve independently.
Core Class Structure
How to Read the Diagram
-
Notification(base model)- Represents the conceptual notification and its core fields (message params, sent_to, sent_on).
- In practice, this maps to stored notification records and is used as the common βunitβ across types.
-
AbstractWebNotification(contract)- Defines the required lifecycle of any web notification type:
prepare_payload()β build the message/payload (title/body/data) from inputs and templates.get_recipients()β compute who should receive the notification (lab users, roles, org, doctors).send()β orchestrate persistence + delivery via configured gateway(s).
- Defines the required lifecycle of any web notification type:
-
Type-specific classes (example:
OrgReportReady)- Encapsulate business logic for a particular notification type.
- Common responsibilities:
- Convert domain objects (e.g. lab_notification) into a payload.
- Apply type-specific routing rules (which roles/topics receive it).
- Choose delivery channel(s) via gateways.
-
Gateway layer (
FCMPusherGateway,PusherGateway)- Abstracts the underlying delivery provider:
- FCM is typically used for browser push notifications and offline delivery.
- Pusher/WebSocket may be used for faster in-app delivery where available.
- Keeps provider authentication, payload formatting quirks, retries, and response handling out of the business logic.
- Abstracts the underlying delivery provider:
Typical Runtime Flow
- A business event occurs (e.g. organisation report becomes ready).
- The system instantiates the relevant notification type class (e.g.
OrgReportReady(lab_notification)). - The notification class:
- Calls
prepare_payload() - Calls
get_recipients()
- Calls
send()persists notification records and delegates delivery to:FCMPusherGateway.send_notification(...)(push), and/orPusherGateway.send_notification(...)(in-app)
- Delivery outcomes are recorded and later user actions update read/unread activity.
Where This Fits
- For persisted entities and relationships, see Data Model.
- For the client-facing endpoints that interact with this layer, see API Reference.