Skip to content

[Feature] Implement Server-Sent Events (SSE) Engine for Real-Time On-Chain Mint & Settlement Stream #20

Description

@Darkvader-ship-it

Estimated Effort: 3 weeks / 9 days

Impacted Subsystems / Files:

app/api/events/stream/route.ts
lib/event-bus.ts
components/system-ticker.tsx
components/fusion-chamber.tsx
Context & Problem Statement: Users currently must manually refresh or rely on polling loops to view new NFT mints, market offers, or collection settlements. This creates unnecessary RPC load and degrades real-time UX during live drop events in the Chamber.

Technical Requirements & Scope:

Build an SSE endpoint at /api/events/stream supporting client subscription channels (mints, settlements, offers).
Create an in-memory event bus (lib/event-bus.ts) triggered by API route actions and Mercury webhooks.
Integrate SSE subscriber hooks into components/system-ticker.tsx and components/fusion-chamber.tsx.
Implement automatic client reconnection logic with exponential backoff and message ID replay.
Multi-File Change Surface: Creates app/api/events/stream/route.ts and lib/event-bus.ts. Updates app/api/forge-agent/route.ts, app/api/market/route.ts, components/system-ticker.tsx, and components/fusion-chamber.tsx.

Acceptance Criteria:

[ ] Mint and settlement events propagate to connected clients in <200ms.
[ ] SSE connections maintain stability under 500 concurrent client streams.
[ ] Graceful fallback to polling when browser SSE client disconnects.
Suggested Approach / Investigation Steps:

Design SSE protocol payload format and channel subscription parameters.
Implement EventBus singleton in Node server runtime.
Create Next.js App Router streaming route handler.
Wire client-side useEventStream hook in Chamber and Ticker components.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions