p1-import-claim-chat-notification-modules

donetype/backlogdomain/anabatictech/nestjs

p1 — Import Claim chat + notification modules (reusable in PMS)

TL;DR

Port backend-claim-dev notification and chat Nest modules into backend-pms-dev, wired to the shared Portal uam database (FCM tokens + user notification inbox), with PMS-specific CONTEXT_TYPE and routes bound to projectId instead of payment-request IDs.

Description

Claim production already uses Portal-backed notifications and a conversation-based chat stack (see [[Projects/anabatic-claim/context/production-architecture]]). PMS needs the same cross-cutting capabilities on project records without reimplementing from scratch.

Source of truth (Claim repo, local path):

ModulePath
Notificationbackend-claim-dev/src/modules/notification/
Chatbackend-claim-dev/src/modules/chat/

Reference entities (Claim):

  • Notification: FcmToken, UserNotification — TypeORM connection uam
  • Chat: Conversation, ConversationParticipant, Message, MessageAttachment, MessageMention — connection claim today; PMS must decide same DB vs PMS schema (prefer shared Portal/UAM patterns per Claim prod architecture)

Integration pattern in Claim:

  • ChatModule imports NotificationModule; ChatNotificationAdapter implements CHAT_NOTIFICATION_SENDER
  • payment-request controllers expose thin routes that delegate to ChatService with CONTEXT_TYPE.PAYMENT_REQUEST

Target for PMS:

  • Register modules in backend-pms-dev/src/modules/main.module.ts
  • Add CONTEXT_TYPE.PROJECT (or equivalent) in chat service
  • Expose routes such as GET/POST .../projects/:projectId/chat/... mirroring Claim’s payment-request chat surface
  • Reuse notification inbox + FCM register/list/mark-read APIs for PMS clients

Note: CMS chat-system (polymorphic chatboxes tables) is a different design. This backlog explicitly tracks Claim modules per management request, not CMS legal/cover-letter chat.

Acceptance criteria

Notification module

  • NotificationModule + NotificationService + controller ported; TypeOrmModule.forFeature(..., 'uam') matches PMS datasource config
  • Endpoints: register token, list notifications, mark read, send (internal) — behavior matches Claim unless PMS product trims scope
  • Documented env/config for FCM / Portal DB (CMS-aligned FIREBASE_* in docs/DATABASE.md)

Chat module

  • ChatModule + ChatService + ChatNotificationAdapter ported
  • CONTEXT_TYPE extended for project; conversation keyed by projectId
  • CRUD/chat flows: get conversation by project, send message, add participants (parity with Claim payment-request chat)
  • Chat events trigger notifications via adapter (no duplicate notify logic in projects service)

PMS wiring

  • ProjectChatController delegates to ChatService (no Claim payment-request routes)
  • OpenAPI + module README lists new routes
  • Smoke test: run npm run db:schema:chat then exercise routes against dev DB (see docs/DATABASE.md)

Non-goals (this item)

  • CMS chat-system polymorphic tables migration
  • Frontend UI (backend-only unless paired task exists)

Priority

p1 — raised after 2026-05-21 emergency PMS priority meeting.

Dependencies

  • PMS uam (and chat DB) datasource configuration in backend-pms-dev
  • Stable projectId from [[Projects/anabatic-project-manager/changelog/2026-05-22-pms-progress-snapshot|projects CRUD]] (local implementation exists)
  • Claim module behavior understood — link [[Projects/anabatic-claim/context/production-architecture]]

Links

  • Claim hub: [[Projects/anabatic-claim/anabatic-claim]]
  • Meeting: [[Projects/anabatic-project-manager/meetings/2026-05-21-emergency-pms-priority]]