HOCO B2B
Team tasksAnis

SRV-08 — Jobs & notifications infrastructure

BullMQ queues and scheduler, transactional outbox, notification service (inbox, FCM push, SMS, email adapters with dev simulators), templates and the event → channel matrix.

FieldDetails
Task codeSRV-08
PhaseP0 — Foundations (cadrage, UX/UI, architecture & contract)
Product scopeV1
StatusDone (Mon 19 Oct 2026)
StartMon 19 Oct 2026
DueMon 19 Oct 2026
ResponsibleAnis — Full-stack developer
Co-responsible—
Effort1.25 person-day(s) planned · 6 from scratch · size S
Area · appServer · server
Depends onSRV-07
UnblocksSRV-24, SRV-39, SRV-40
Milestones—

Summary

BullMQ queues and scheduler, transactional outbox, notification service (inbox, FCM push, SMS, email adapters with dev simulators), templates and the event → channel matrix.

Description

Notifications, SSE, analytics aggregates, CRM automation and scheduled rules all run in the worker process, driven by events (NOT-01…NOT-04, INT-02…INT-04, cahier §8, §11). This task builds the BullMQ queues and the repeatable scheduler, the transactional outbox (OutboxEvent written in the same transaction as the change, dispatched by the worker with retries and a dead-letter state), and the notification service: in-app inbox (Notification), per-channel deliveries (NotificationDelivery), localised templates (NotificationTemplate per event × channel × locale), the event → channel → recipient matrix (NotificationRule), user preferences (NotificationPreference, marketing opt-out) and adapters for FCM push with deep links, SMS (provider closed in PRJ-03) and email, each with a dev simulator. It implements the reseller/delegate inbox endpoints. Out of scope: the SSE streams themselves (SRV-26) and template content for every event (filled by each module).

Subtasks

#SubtaskOwner
1BullMQ setup: queues outbox, notifications, pdf, exports, imports, images, scheduled; retry/backoff policies; Bull Board behind staff authAnis
2Outbox writer helper (inside Prisma transaction) and dispatcher (poll + LISTEN/NOTIFY) with ordering per aggregate, retries and DEAD stateAnis
3Repeatable scheduler registry for module jobs (orders.expireAssisted every 15 min, promotions.applySchedule every minute, support.autoClose daily, purges)Anis
4Notification service: rule resolution (event → channels → recipients), preferences and quiet hours for PROMOTIONAL, inbox write, delivery fan-outAnis
5FCM adapter (firebase-admin) with deep-link payloads, token invalidation on UNREGISTERED, per-device delivery statusAnis
6SMS adapter interface + provider implementation + dev simulator; email adapter (SMTP/provider, Mailpit locally)Anis
7Template engine with fr/ar/en variants and variables (order number, status label from enums.json)Anis
8Endpoints notifications.list, unreadCount, markRead, markAllRead, preferences.get/updateAnis
9Push payload and deep-link format review for both Flutter appsImad

Deliverables

  • apps/server/src/platform/{queues.ts,scheduler.ts,outbox/}
  • apps/server/src/modules/notifications/{service.ts,rules.ts,templates/,adapters/{fcm,sms,email}.ts,router.ts}
  • Notifications matrix page /docs/srs/notifications-matrix aligned with the seeded rules

Acceptance criteria

  • An event written in a rolled-back transaction is never dispatched; a committed event is dispatched at least once and consumers are idempotent by event id
  • A failing consumer is retried with backoff and lands in DEAD after the last attempt, visible in Bull Board
  • A reseller who opted out of PROMOTIONAL receives no promotional push but still receives TRANSACTIONAL ones (NOT-06)
  • An order status event produces an inbox entry and a push with a deep link to the order (NOT-01, NOT-02)
  • OTP SMS uses the SMS adapter; in dev the code is printed instead of sent (NOT-03)

Requirements covered

RequirementTitleRelease
NOT-01In-app notification inbox with read/unread in every appV1
NOT-02Push notifications (FCM) with deep linksV1
NOT-03SMS for OTP and critical messages; email for staff and documents; WhatsApp share linksV1
NOT-04Event → channel → recipient matrix and localised templatesV1
INT-02Firebase Cloud MessagingV1
INT-03SMS gateway for OTP, invitations, confirmations and remindersV1
INT-04Transactional emailV1
NOT-05Automatic notifications on order changes, assignments, follow-ups and promotionsV1

API surface

Endpoint groupOperations
Notifications & announcements10

Test measures

  • Integration tests with real Redis and Postgres for outbox dispatch, retries and dead-lettering
  • Unit tests for rule resolution and preference filtering
  • Manual check: push received on an Android test device from staging

Risks

  • SMS provider approval and sender-id registration take weeks — start the request right after PRJ-03 and keep the simulator on staging until approved

KPI

  • Delivered by Mon 19 Oct 2026 within 1.25 person-day(s).
  • Every acceptance criterion above demonstrated before hand-off; linked requirements' acceptance criteria pass.
  • Zero open critical defects, permission gaps or data-integrity regressions at sign-off.

Generated from content/plan/tasks.json by scripts/generate-team-tasks.mjs. Dates are computed by the scheduler (Sunday–Thursday weeks, holidays excluded) — change the plan, not this page.

On this page