# Annotations (realtime & stream sync) ## 1. High-Level Overview **Purpose:** **SSE** push for annotation changes and **RabbitMQ Stream** failsafe export — `01_annotations.md` sections *SSE Communication* and *Annotation Sync* / *Failsafe* / *RabbitMQ Stream*. **Architectural pattern:** Event channel + background outbox producer. **Upstream dependencies:** Platform (DB, config, paths), Annotations REST (domain mutations enqueue/publish). **Downstream consumers:** Browser UI (SSE); Admin sync worker; AI Training consumer (external). ## 2. Internal interfaces - `AnnotationEventService` — in-process `Channel`; `PublishAsync` / `Reader`. - `FailsafeProducer` + `RabbitMqConfig` — stream client, MessagePack payloads, drains `annotations_queue_records`. - **HTTP:** `AnnotationsController.Events` — `text/event-stream` subscription (same controller file as REST component; **doc ownership** here for SSE). ## 3. External API / integration | Surface | Notes | |---------|--------| | `GET /annotations/events` | SSE; see suite SSE section | | RabbitMQ stream `azaion-annotations` | Env `RABBITMQ_*` from `Program` | ## 4. Data access patterns Queue table buffering; stream send on connectivity; image bytes in create messages per suite. ## 5. Caveats MessagePack key stability; stream consumer offsets independent per consumer type. ## 6. Dependency graph **Imports from:** Platform, annotations domain (via service calls / shared types). **Consumed by:** External infrastructure. ## 7. Modules included `sse-realtime`, `rabbitmq-stream-sync`.