Skip to content

docs: add architecture and implementation documentation for SSE integ… - #1354

Merged
K1NGD4VID merged 1 commit into
LabsCrypt:mainfrom
muhsar27:fix-SSE-architecture
Aug 30, 2026
Merged

docs: add architecture and implementation documentation for SSE integ…#1354
K1NGD4VID merged 1 commit into
LabsCrypt:mainfrom
muhsar27:fix-SSE-architecture

Conversation

@muhsar27

Copy link
Copy Markdown
Contributor

Closes #1300

Description

Corrects the SSE architecture diagrams and documentation in SSE_ARCHITECTURE.md and SSE_IMPLEMENTATION.md. The previous diagrams and prose incorrectly showed HTTP API controllers (e.g., Stream Controller) invoking sseService.broadcast() synchronously upon receiving user actions. In reality, all stream/protocol SSE events originate asynchronously from the background indexer worker (SorobanEventWorker) only after transaction confirmation on the Stellar ledger, with computed runway alerts emitted by StreamRunwayWorker.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #

Changes Made

  • Updated the System Flow ASCII diagram in backend/docs/SSE_ARCHITECTURE.md to show event flow originating from Stellar/Soroban ledger executions to SorobanEventWorker (Indexer), which persists state and dispatches sseService.broadcastToStream/Admin().
  • Added an explanatory note clarifying that HTTP API controllers (stream.controller.ts, sse.controller.ts) do not trigger broadcasts directly and that SSE events are delayed/indexer-driven after on-chain confirmation.
  • Updated the Horizontal Scaling with Redis flow description to indicate that the worker instance processing on-chain events publishes to Redis.
  • Added sseService.broadcastToAdmin() to the Event Broadcasting Logic section alongside broadcastToStream() and broadcastToUser().
  • Updated publisher reference comment in backend/docs/SSE_IMPLEMENTATION.md to reflect SorobanEventWorker / indexer instead of stream controller.

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

  1. Cross-referenced all sseService.broadcast* call sites across backend/src/ (soroban-event-worker.ts, stream-runway-worker.ts, sse.service.ts) against the updated documentation.
  2. Verified markdown syntax and diagram rendering in backend/docs/SSE_ARCHITECTURE.md and backend/docs/SSE_IMPLEMENTATION.md.

Breaking Changes

None.

Screenshots/Demo

N/A (Documentation update).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Updated Postman/Hoppscotch API collections if routes changed
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable

Additional Notes

This update prevents confusion when debugging stream lifecycle events (e.g., pause, withdraw, top-up, cancel) where SSE events appear with ledger latency rather than synchronously upon HTTP API invocation.

@K1NGD4VID
K1NGD4VID merged commit f4cf466 into LabsCrypt:main Aug 30, 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

Development

Successfully merging this pull request may close these issues.

[Audit] SSE architecture diagram contradicts the actual call graph

2 participants