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.
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
backend/src/main/java/com/algorithmrace/visualizer/controller/StreamController.java.GET /api/simulations/stream/sortingreturningSseEmitter.Consumer<SimulationFrame>, emitting frames directly to the emitter as the loop runs.frontend/src/services/sseClient.tsto consumeEventSourcestreams into theusePlaybackframe buffer.Definition of Done
Skill Level
Hard — Spring SseEmitter implementation, reactive frame streaming, and client EventSource handling.