docs(backend): add backend/docs/ARCHITECTURE.md and fix broken indexe… - #1412
Open
olu-cmd wants to merge 1 commit into
Open
docs(backend): add backend/docs/ARCHITECTURE.md and fix broken indexe…#1412olu-cmd wants to merge 1 commit into
olu-cmd wants to merge 1 commit into
Conversation
…r references Fixes audit issue 97/100 — both indexer services referenced docs/ARCHITECTURE.md but no such file existed in backend/docs/. Document indexer ownership (SorobanEventWorker is authoritative, SorobanIndexerService is deprecated legacy per Architecture LabsCrypt#67/LabsCrypt#801), SSE broadcast flow, and keeper-key authorization model (Architecture LabsCrypt#72), and link both services to the new doc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #1299
Fix: Create missing
backend/docs/ARCHITECTURE.mdand repair broken indexer referencesDescription
Closes audit issue 97/100 —
backend/src/services/indexerService.ts:11andbackend/src/services/soroban-indexer.service.ts:9-17both referenceddocs/ARCHITECTURE.md for the full indexer ownership model, but no such file existed anywhere inbackend/docs/(verified via directory listing). This was a dead link for exactly the document contributors need when investigating the known dual-indexer race (Architecture #67).This PR creates the missing file and wires both services to it.
Root Cause
docs/ARCHITECTURE.md(root) exists and documents system-wide flows, butbackend/docs/ARCHITECTURE.mdwas never created.docs/ARCHITECTURE.mdexpecting a backend-local architecture doc with indexer ownership, SSE flow, and keeper-key model (Architecture Frontend: Stream Details Screen #72).backend/docs/only containedAPI_VERSIONING.md,AUTHENTICATION.md,DEPRECATION_POLICY.md,SANDBOX_MODE.md,SSE_ARCHITECTURE.md,SSE_IMPLEMENTATION.md.Solution
1. New file:
backend/docs/ARCHITECTURE.md(138 lines)Single authoritative backend architecture doc, scoped to what the audit requested:
1. Indexer Ownership (Source of Truth)
backend/src/workers/soroban-event-worker.ts(SorobanEventWorker)getEvents, XDR decode, persistStream/StreamEvent, advanceIndexerState, broadcast SSEbackend/src/workers/index.ts:16→startWorkers()backend/src/services/soroban-indexer.service.ts(SorobanIndexerService)@deprecated— do not extend, kept for API/test compat only. Removal tracked as Architecture #67 / issue #801backend/src/services/indexerService.ts(barrel →indexer.service.ts)getIndexerStatus,resetIndexer,replayFromLedger) — read/resetIndexerStatesingleton and trigger worker viatriggerPoll()indexer.service.tspost-consolidationAlso documents: why two indexers exist, race on
IndexerStatesingleton, current startup model (onlySorobanEventWorkerstarted inbackend/src/index.ts:32), cursor/idempotency (@@unique([transactionHash, eventType])inbackend/prisma/schema.prisma:82,ensureIndexerState()withP2002race handling,runExclusive/batchMutexserialization), and pointer to operational runbook inSSE_ARCHITECTURE.md#operational-runbook.2. SSE Broadcast Flow
Indexer-driven origin (never from HTTP controllers), Redis fanout via
backend/src/lib/redis.ts/psubscribeonsse:stream:*/sse:user:*, filtering inbackend/src/services/sse.service.ts:182, links toSSE_ARCHITECTURE.mdandSSE_IMPLEMENTATION.md.3. Keeper-Key Authorization Model (Architecture #72)
KEEPER_SECRET_KEYviabackend/src/services/sorobanService.ts:365/backend/src/controllers/stream/cancel.ts:90Documents env handling, throw when unset, scope, and that frontend must never receive
KEEPER_SECRET_KEY.All sections include file:line anchors and cross-links to
docs/ARCHITECTURE.md,SSE_ARCHITECTURE.md,AUTHENTICATION.md.2. Service reference fixes
backend/src/services/indexerService.ts:1backend/docs/ARCHITECTURE.md(Indexer Ownership) +docs/ARCHITECTURE.mdbackend/src/services/soroban-indexer.service.ts:13@deprecatedJSDoc to linkbackend/docs/ARCHITECTURE.md(Indexer Ownership) + dual-indexer race Architecture #67backend/src/services/indexer.service.ts:1backend/docs/ARCHITECTURE.md(Ownership, SSE, Keeper-Key) + Architecture #67References use
backend/docs/ARCHITECTURE.md(resolves insidebackend/docs/) anddocs/ARCHITECTURE.md(root) — both now valid.Acceptance Criteria
backend/docs/ARCHITECTURE.mdexistsindexerService.ts+soroban-indexer.service.ts, plusindexer.service.tsimpl)How to Verify
Risk
Docs/comment-only. No runtime behavior change. Low risk.
Related
docs/ARCHITECTURE.mdnot found inbackend/docs/