Skip to content

feat: persist in-app notifications in Postgres (durable, cross-instance) #43

Description

@scarface-dev1

Problem

inAppHandler in packages/notifications keeps a module-level in-memory array capped at 1,000 messages. Notifications are lost on restart, invisible across gateway instances, and only reachable via package-local helpers — the dashboard has no read/read-mark API. The audit (L8) flags this as a durability/scale gap.

Scope

  • Add an InAppNotification model to packages/database/prisma/schema.prisma (providerId, event, data JSON, read, createdAt) + migration
  • Rewrite inAppHandler to persist to Postgres when DATABASE_URL is available (keep in-memory fallback for tests/no-DB)
  • Gateway endpoints: GET /api/v1/notifications (paginated, wallet-scoped) and POST /api/v1/notifications/:id/read
  • Dashboard badge showing unread count

Files to Modify

File What
packages/database/prisma/schema.prisma InAppNotification model + migration
packages/notifications/src/index.ts DB-backed handler
apps/gateway/src/modules/notifications/ New module (controller + service) — or extend admin
apps/dashboard/src/app/layout.tsx / navbar Unread badge

Acceptance Criteria

  • Notifications survive a gateway restart
  • Read/unread state is per-provider and wallet-scoped
  • Pagination works (limit 50 default)
  • In-memory fallback preserved when no DB
  • Migration applies cleanly (prisma migrate dev)
  • Unit tests for the DB handler + endpoints
  • pnpm exec nx test gateway passes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source bounty programMaybe RewardedEligible for GrantFox reward upon mergeStellar WaveDrips Wave contribution programarea:notificationsWebhook and email notificationsbountyBounty-eligible issue — reward contingent on program approvalenhancementNew feature or requestmedium2-8 hours, requires some domain knowledge

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions