feat: implement Redis pub/sub SSE, webhook dispatcher, stream runway alerts, and transaction export - #1202
Merged
blurbeast merged 1 commit intoAug 29, 2026
Conversation
…alerts, and transaction export Implemented four backend enhancements for FlowFi: Issue LabsCrypt#1188: Redis Pub/Sub for SSE Broadcasting - Confirmed existing SSE service already has Redis pub/sub support - SSE service initializes Redis subscription in index.ts - Enables horizontal scaling with multi-instance deployments Issue LabsCrypt#1189: Outgoing Webhook Event Dispatcher - Created webhook.service.ts with HMAC-SHA256 signature generation - Implemented webhook subscription CRUD operations - Added automatic retry logic with exponential backoff (5 attempts) - Created webhook.controller.ts with REST endpoints - Added webhook.routes.ts for /v1/webhooks endpoints - Integrated webhook routes into v1/index.ts - Created Prisma models: WebhookSubscription, WebhookDelivery - Supports HTTPS-only webhook URLs for security - Auto-disables subscriptions after 50 consecutive failures Issue LabsCrypt#1190: Stream Runway & Low-Balance Alert Engine - Created stream-runway-worker.ts with hourly monitoring - Calculates remaining runway using claimableAmountService - Sends alerts at 48h (warning) and 24h (critical) thresholds - Implements 24h deduplication window to prevent spam - Broadcasts alerts via SSE to sender and recipient - Created AlertHistory Prisma model for tracking sent alerts - Integrated worker into workers/index.ts startup Issue LabsCrypt#1191: Transaction Export for Tax & Accounting - Created export.service.ts with CSV and JSON streaming - Implements cursor-based pagination for memory efficiency - Supports filtering by direction (incoming/outgoing/all) - Supports date range filtering and token address filtering - Calculates protocol fees and net amounts - Added exportTransactions controller method to user.controller.ts - Added export route to user.routes.ts - Streams large datasets without buffering entire response Database Schema Updates: - Added WebhookSubscription model with HTTPS URL validation - Added WebhookDelivery model for tracking delivery attempts - Added AlertHistory model for deduplication tracking All implementations include: - TypeScript strict type safety - Error handling and logging - Prisma client generation successful - 369/385 tests passing (16 skipped) - Build compilation successful Closes LabsCrypt#1188 Closes LabsCrypt#1189 Closes LabsCrypt#1190 Closes LabsCrypt#1191
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented four backend enhancements
Issue #1188: Redis Pub/Sub for SSE Broadcasting
Confirmed existing SSE service already has Redis pub/sub support
SSE service initializes Redis subscription in index.ts
Enables horizontal scaling with multi-instance deployments
Issue #1189: Outgoing Webhook Event Dispatcher
Created webhook.service.ts with HMAC-SHA256 signature generation
Implemented webhook subscription CRUD operations
Added automatic retry logic with exponential backoff (5 attempts)
Created webhook.controller.ts with REST endpoints
Added webhook.routes.ts for /v1/webhooks endpoints
Integrated webhook routes into v1/index.ts
Created Prisma models: WebhookSubscription, WebhookDelivery
Supports HTTPS-only webhook URLs for security
Auto-disables subscriptions after 50 consecutive failures
Issue #1190: Stream Runway & Low-Balance Alert Engine
Created stream-runway-worker.ts with hourly monitoring
Calculates remaining runway using claimableAmountService
Sends alerts at 48h (warning) and 24h (critical) thresholds
Implements 24h deduplication window to prevent spam
Broadcasts alerts via SSE to sender and recipient
Created AlertHistory Prisma model for tracking sent alerts
Integrated worker into workers/index.ts startup
Issue #1191: Transaction Export for Tax & Accounting
Created export.service.ts with CSV and JSON streaming
Implements cursor-based pagination for memory efficiency
Supports filtering by direction (incoming/outgoing/all)
Supports date range filtering and token address filtering
Calculates protocol fees and net amounts
Added exportTransactions controller method to user.controller.ts
Added export route to user.routes.ts
Streams large datasets without buffering entire response
Database Schema Updates:
Added WebhookSubscription model with HTTPS URL validation
Added WebhookDelivery model for tracking delivery attempts
Added AlertHistory model for deduplication tracking
All implementations include:
TypeScript strict type safety
Error handling and logging
Prisma client generation successful
369/385 tests passing (16 skipped)
Build compilation successful
Closes #1188
Closes #1189
Closes #1190
Closes #1191