Skip to content

feat(backend): Server-Sent Events (SSE) Live Frame Streaming Engine #90

Description

@Sanan507

Overview

Implement Server-Sent Events (SSE) streaming for simulation endpoints. For large benchmarks ($N > 1000$ or complex $100 \times 100$ grids), SSE streams simulation frames in real-time as they are computed, eliminating large memory payloads and enabling instant playback start.

Implementation Details & File Reference

  • SSE Controller: Create backend/src/main/java/com/algorithmrace/visualizer/controller/StreamController.java.
    • Endpoint GET /api/simulations/stream/sorting returning SseEmitter.
  • Streaming Service: Update backend algorithm models to accept a frame consumer callback Consumer<SimulationFrame>, emitting frames directly to the emitter as the loop runs.
  • Frontend EventSource: Create frontend/src/services/sseClient.ts to consume EventSource streams into the usePlayback frame buffer.

Definition of Done

  • SSE streaming endpoint streams simulation frames asynchronously.
  • Frontend starts animating instantly without waiting for total simulation completion.
  • Handles connection dropouts and emitter completion cleanly.

Skill Level

Hard — Spring SseEmitter implementation, reactive frame streaming, and client EventSource handling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions