Skip to content

feat: implement Redis pub/sub SSE, webhook dispatcher, stream runway alerts, and transaction export - #1202

Merged
blurbeast merged 1 commit into
LabsCrypt:mainfrom
Georgechisom:feat/backend-redis-webhooks-alerts-export
Aug 29, 2026
Merged

feat: implement Redis pub/sub SSE, webhook dispatcher, stream runway alerts, and transaction export#1202
blurbeast merged 1 commit into
LabsCrypt:mainfrom
Georgechisom:feat/backend-redis-webhooks-alerts-export

Conversation

@Georgechisom

Copy link
Copy Markdown
Contributor

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

…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
@blurbeast
blurbeast merged commit 07683a3 into LabsCrypt:main Aug 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants