Skip to content

Align growth/alerts Module — Event-Driven Alert Pipeline with Delivery Guarantees #12

@grantfox-oss

Description

@grantfox-oss

Description
The alerts module (src/growth/alerts/) has basic CRUD for alerts and trigger logs, but lacks:

  • Event-driven trigger mechanism — alerts are created via direct API calls, not by subscribing to domain events (risk breaches, portfolio thresholds, DeFi position changes).
  • Delivery channel abstraction — no distinction between email, push, WebSocket, or in-app alerts.
  • Delivery guarantees — no retry logic, no deduplication, no rate limiting per user.
  • Integration with the risk management events from Issue Align defi Module — Protocol Adapter Registry & Strategy Discovery #9.

Direction

  1. Create src/growth/alerts/listeners/ directory with event listeners:
    • RiskAlertListener — subscribes to risk.threshold.breached events.
    • PortfolioAlertListener — subscribes to portfolio rebalancing events.
  2. Create src/growth/alerts/services/alert-dispatcher.service.ts:
    • Channel abstraction (EmailChannel, WebSocketChannel, InAppChannel).
    • Retry logic with exponential backoff (max 3 attempts).
    • Deduplication via alert fingerprint (hash of userId + triggerType + triggerId + timeWindow).
  3. Add user preference model: AlertPreference entity storing per-user channel preferences and quiet hours.
  4. Expose POST /api/v1/alerts/subscribe and DELETE /api/v1/alerts/unsubscribe endpoints for user preference management.
  5. Rate limit alert delivery per user (configurable, default: 10 alerts/hour).

Definition of Done

  • Alerts module reacts to domain events automatically.
  • Users receive alerts through their preferred channels with delivery guarantees.

Acceptance Criteria

  • RiskAlertListener creates alerts when risk.threshold.breached events are emitted
  • AlertDispatcher delivers through at least 2 channels (in-app + one other)
  • Duplicate alerts within a 5-minute window are deduplicated
  • Failed deliveries retry up to 3 times with exponential backoff
  • AlertPreference entity exists with channel and quiet-hours configuration
  • Subscribe/unsubscribe endpoints exist and are documented in Swagger
  • Rate limiting prevents more than 10 alerts per user per hour
  • npm run build succeeds
  • Alert service unit tests pass

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions