Overview
Create a notification domain service for email and in-app delivery that supports user preferences, templating, durable retries, deduplication, and delivery history.
Problem
Notifications for funding, investment confirmation, repayments, KYC decisions, payout events, arrears, and contract changes must not be sent directly from route handlers. Direct sends are difficult to retry and can produce duplicate or contradictory messages.
Scope
- Define typed notification events and versioned template payloads.
- Add per-user channel and category preferences, including mandatory operational notices that cannot be disabled where appropriate.
- Generate notifications from domain events through the outbox/job system.
- Create in-app records with read/unread state and email delivery attempts.
- Add idempotency keys so one business event cannot create duplicate notifications.
- Support scheduled reminders, retry/backoff, dead-letter state, and provider response tracking.
- Implement localization-ready template structure without requiring full translation work.
- Add unsubscribe/preference tokens that are scoped, expiring, and safe.
- Ensure no KYC documents, secrets, or unnecessary financial details appear in email content or logs.
Acceptance criteria
- The same domain event creates at most one notification per intended channel.
- User preferences are respected except for documented mandatory notices.
- Failed email deliveries retry without duplicating in-app notifications.
- Template rendering is deterministic and testable in mock mode.
- Delivery history and final failure state are inspectable by authorized users/admins.
- Notification links use safe application URLs and cannot be abused for open redirects.
Tests required
Cover preferences, mandatory events, duplicate domain events, retry, dead-letter, template validation, unsubscribe token expiry, read/unread behavior, unsafe URL rejection, and PII redaction.
Documentation
Add event taxonomy, preference matrix, template rules, and delivery lifecycle.
Overview
Create a notification domain service for email and in-app delivery that supports user preferences, templating, durable retries, deduplication, and delivery history.
Problem
Notifications for funding, investment confirmation, repayments, KYC decisions, payout events, arrears, and contract changes must not be sent directly from route handlers. Direct sends are difficult to retry and can produce duplicate or contradictory messages.
Scope
Acceptance criteria
Tests required
Cover preferences, mandatory events, duplicate domain events, retry, dead-letter, template validation, unsubscribe token expiry, read/unread behavior, unsafe URL rejection, and PII redaction.
Documentation
Add event taxonomy, preference matrix, template rules, and delivery lifecycle.