notifications
Status: implemented (services/notifications, contract: docs/dev/phase4-contracts.md, Notifications
service; specs: features.md "Notifications"). Runs in the apps profile of docker-compose.yml on port 8089
(metrics 9189) and is reached through the gateway route /v1/notifications. /internal/v1/alerts is never routed.
Role: turns platform events (Kafka), monitoring alerts and broadcasts into notifications and delivers them on
the channels chosen by each user: in_app (notification centre), email (SMTP), discord (webhook) and
webhook (signed CloudEvent). Users manage their preferences and personal webhooks; organisation webhooks and
broadcasts are permission-gated.
Limits: no browser push (refusing browser notifications never matters). External borrowers (non-members) are
not notified (their contact stays encrypted in borrowing). Recipients granted a permission only through the
default user role are not enumerated (see LookupSubjects).
Flow
Sources and recipients
| Type | Source | Recipients | Default channels |
|---|---|---|---|
borrowing.due_soon, borrowing.overdue | borrowing.reminder.due_soon / overdue | member borrower | in_app, email |
borrowing.approval_requested | borrowing.sheet.submitted | holders of borrowing.sheet.approve on the sheet | in_app |
inventory.stock_low | inventory.stock.low | holders of inventory.issue.handle on the site | in_app |
inventory.issue_reported | inventory.issue.reported | holders of inventory.issue.handle on the issue | in_app |
inventory.maintenance_due | inventory.maintenance.task_due | assignee + holders of inventory.maintenance.manage on the plan | in_app |
finance.purchase_requested | finance.purchase.requested | holders of finance.purchase.approve on the purchase (site, project) | in_app, email |
finance.purchase_decided | finance.purchase.approved / refused | requester | in_app, email |
finance.expense_submitted | finance.expense.submitted | holders of finance.expense.approve on the claim | in_app, email |
finance.expense_decided | finance.expense.approved / refused | requester | in_app, email |
finance.invoice_paid | finance.invoice.payment_applied (status paid) | invoice creator (actor of finance.invoice.created, remembered) | in_app |
bank.consent_expiring, bank.consent_expired | bank.connection.consent_expiring / expired | holders of finance.account.manage on the site | in_app, email |
members.training_expiring | polled GET /v1/members/trainings/expiring (daily, TRAINING_NOTICE) | member | in_app, email |
projects.member_added | projects.project.member_added | added member | in_app |
events.public_event_created | events.event.created (visibility public) | users who opted in | none (opt-in) |
monitoring.alert | Alertmanager webhook | holders of notifications.broadcast.send + ALERT_EMAIL | in_app, email |
notifications.broadcast | notifications.broadcast.created (own topic) | every active member (directory) | in_app |
The user who caused an event is never notified of it. Consumers ignore unknown fields and unknown event types,
validate identifiers and accept the French status values still emitted by finance (payee, facture).
Organisation webhooks only receive the types flagged organization (no personal data).
Delivery
- Idempotency: in-app notifications are unique per (event, user); deliveries per
<event>|<recipient>|<channel>(recipient = user, webhook oralert_list). - Queue: the
deliveriescollection. A lease job (notifications-deliveries, everyDELIVERY_INTERVAL) claims due deliveries atomically, sends them, retries failures afterDELIVERY_BACKOFF × 2^(attempt-1)(capped byDELIVERY_MAX_BACKOFF) and marks themfailedafterDELIVERY_MAX_ATTEMPTSor on permanent errors (4xx, no address, webhook gone), publishingnotifications.delivery.failed. E-mails are spaced byEMAIL_RATE_INTERVAL. - E-mail: address (
workspace_email) and locale read from members at send time with the service principal (memory cacheCONTACT_CACHE_TTL, never stored). Multipart text + HTML (html/template), FR/EN. Port 465 uses implicit TLS, other ports STARTTLS when offered; PLAIN auth whenSMTP_USERis set. - Discord: embed with title, body and link, mentions disabled.
- Webhook: CloudEvent JSON (
application/cloudevents+json, typeatl.notification.<type>, id = delivery ID),X-Atl-Signature: sha256=<hex HMAC-SHA256(secret, body)>,X-Atl-Delivery. Verify the signature on the raw body before parsing. - SSRF: webhook calls refuse loopback, private, link-local and CGNAT destinations and never follow redirects
(
WEBHOOK_ALLOW_PRIVATE/WEBHOOK_ALLOW_HTTPfor development only, refused in production). - Secrets: webhook URLs and signing secrets are sealed with the keyring (subject = webhook ID); deleting a webhook shreds its key. The secret is shown once (creation, rotation).
API
See the API reference. Lists are cursor-paginated, newest first. Texts are rendered in
?locale=, then Accept-Language, then French.
| Endpoint | Purpose |
|---|---|
GET /v1/notifications, GET /unread-count, POST /{id}/read, POST /read-all | Notification centre |
GET/PUT /v1/notifications/preferences | Channels per type (null resets a type) |
/v1/notifications/webhooks CRUD, POST /{id}/test | Personal (owner) and organisation (notifications.webhook.manage) webhooks |
GET /v1/notifications/deliveries | Delivery log (own, or one manageable webhook) |
GET/POST /v1/notifications/broadcasts | Broadcasts (notifications.broadcast.send) |
POST /internal/v1/alerts | Alertmanager receiver (bearer ALERT_WEBHOOK_TOKEN when set) |
Writes are audited (notifications.preference.update, notifications.webhook.*, notifications.broadcast.send,
notifications.notification.read*, one notifications.notification.create per dispatched event,
notifications.member.erase).
Kafka
Consumer group notifications-sources on borrowing.reminder.v1, borrowing.sheet.v1, inventory.stock.v1,
inventory.issue.v1, inventory.maintenance.v1, finance.purchase.v1, finance.expense.v1, finance.invoice.v1,
bank.connection.v1, projects.project.v1, events.event.v1, members.member.v1, notifications.broadcast.v1.
Produces notifications.broadcast.v1 and notifications.delivery.v1 (failed).
Erasure: members.member.erased deletes the member's notifications, preferences, deliveries, invoice-creator
links and personal webhooks (keys shredded).
Data (MongoDB notifications)
notifications, deliveries, webhooks, preferences (one document per user × type), broadcasts,
invoice_creators, plus outbox, leases and the keyring collection.
Environment
| Variable | Default | Purpose |
|---|---|---|
HTTP_ADDR / METRICS_ADDR | :8089 / :9189 | Listeners |
MONGO_URI, MONGO_DATABASE | notifications | Database |
AUTHZ_URL, MEMBERS_URL | localhost | Holders (LookupSubjects), contacts, directory, trainings |
PRINCIPAL_PUBLIC_KEY, PRINCIPAL_SIGNING_KEY | required | Verify callers, sign the service principal |
CRYPTO_KEK_SOURCE, CRYPTO_KEK | Keyring | |
WEB_URL | http://localhost:3000 | Absolute links in e-mails and webhooks |
SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASSWORD, SMTP_FROM, SMTP_TIMEOUT | e-mail disabled without host; 587 | SMTP relay (Mailpit locally, Google Workspace in production) |
EMAIL_RATE_INTERVAL | 200ms | Minimum gap between e-mails |
ALERT_EMAIL | empty | Alert mailing list (comma-separated) |
ALERT_WEBHOOK_TOKEN | empty (required in production) | Bearer token expected from Alertmanager |
DELIVERY_INTERVAL, DELIVERY_MAX_ATTEMPTS, DELIVERY_BACKOFF, DELIVERY_MAX_BACKOFF, DELIVERY_BATCH | 5s, 8, 30s, 1h, 100 | Delivery queue |
WEBHOOK_TIMEOUT, WEBHOOK_ALLOW_PRIVATE, WEBHOOK_ALLOW_HTTP | 10s, false, false | Webhook client |
TRAINING_NOTICE, TRAINING_CHECK_INTERVAL | 720h, 24h | Training expiry job |
BROADCAST_MAX_RECIPIENTS, CONTACT_CACHE_TTL | 5000, 10m | Limits |
Locally, e-mails go to Mailpit (mailpit service, UI http://localhost:8025).