StarRocks (OLAP Analytics)
Architecture, event catalog, medallion pipeline, and cutover runbook for StarRocks — the analytics read-model for dashboards, reports, and BI.
Omni uses StarRocks as the analytics read-model (single source of truth for all analytical reads). Postgres remains the system-of-record (OLTP); StarRocks serves dashboard overviews, charts, reports, and BI through a three-layer medallion architecture (bronze / silver / gold) fed by event-driven ingestion.
Architecture
Section titled “Architecture”flowchart LR subgraph Postgres[Postgres - System of Record] O[Transactional Outbox<br/>event_outbox] end subgraph SR[StarRocks - OLAP Read Model] B[(Bronze<br/>analytics_event_raw)] S[(Silver Facts<br/>fact_*, dim_*)] G[(Gold Marts<br/>mart_*)] end subgraph Svc[Backend StarrocksSyncService] Sync[Sync Worker<br/>*/10s + direct bridge] Router[Event Router] Sink[Stream Load / Kafka] end O -->|emitOutbox| Sync Sync --> Router --> Sink --> B Sink --> S Dim[Dims<br/>StarrocksDimService] --> S Mart[Mart Scheduler<br/>02:15] --> G S --> Mart B -.->|parity gate| GEvent Catalog & Coverage
Section titled “Event Catalog & Coverage”All events are captured in bronze (analytics_event_raw, append-only, unique event_id). Two ingestion paths exist:
- Outbox (
emitOutbox) — durable, automatically hits bronze. Covers the majority of events. - Direct bridge — for in-process events (
bus.emit) that bypass the outbox, captured via@OnEventlisteners inStarrocksSyncService(theonJournalPosted,onPoIssued, etc. pattern).
Silver facts
Section titled “Silver facts”| Domain | Fact | Notes |
|---|---|---|
| Accounting | fact_journal_line | Journal line-grain, dimension-rich (OU/cost_center/project) |
| Order-to-Cash | fact_invoice, fact_invoice_line, fact_sales_order, fact_so_line, fact_payment | Enriched (segment, discount, tax, outstanding, method/channel) |
| Procure-to-Pay | fact_pr, fact_po, fact_goods_receipt, fact_vendor_invoice | Header grain |
| HR/Payroll | fact_attendance, fact_payroll | |
| Inventory | fact_inventory_movement |
Dimensions
Section titled “Dimensions”dim_date (2020–2035 calendar), dim_customer, dim_vendor, dim_product, dim_account, dim_organization_unit, dim_employee, dim_warehouse, dim_bank_account — SCD Type 1, rebuilt from Postgres masters.
Gold marts
Section titled “Gold marts”mart_revenue_kpi, mart_cash_position_account_daily, mart_ar_aging, mart_ar_totals, mart_cash_application_daily, mart_ar_overdue_daily, mart_customer_revenue, mart_payment_channel, mart_so_pipeline.
Pipeline & Jobs
Section titled “Pipeline & Jobs”| Component | Schedule | Role |
|---|---|---|
StarrocksSyncService | every 10s | Consume outbox → bronze + silver UPSERT |
StarrocksDimService | daily 02:15 | Rebuild dim_* from Postgres |
StarrocksMartSchedulerService | daily 02:15 | Rebuild gold marts + parity reconcile |
StarrocksParityService | on-demand | Validate Postgres ↔ StarRocks |
Cutover Runbook
Section titled “Cutover Runbook”1. Verify the pipeline
Section titled “1. Verify the pipeline”cd backendbun run scripts/starrocks-selfcheck.ts # apply DDL + check bronze/silver/dim/mart2. Historical backfill
Section titled “2. Historical backfill”bun run scripts/starrocks-backfill.ts --table fact_journal_line # or --table <all>bun run scripts/starrocks-repair-journal-date.ts # fill journal_date for legacy rows3. Parity gate
Section titled “3. Parity gate”bun run scripts/starrocks-selfcheck.ts# then via UI Settings → StarRocks Operations → Run Parity (per tenant), or the endpoint4. Enable
Section titled “4. Enable”STARROCKS_ENABLED=trueOperator UI
Section titled “Operator UI”The Settings → StarRocks Operations page provides: ingestion status, delivery-queue admin (list/stats/replay), parity gate (run + history), and gold-mart + dimension rebuilds.
Code Reference
Section titled “Code Reference”- Router & facts:
backend/src/modules/starrocks/starrocks-event-router.ts - Sync bridge:
backend/src/modules/starrocks/starrocks-sync.service.ts - DDL migrations:
backend/src/modules/starrocks/ddl/starrocks-ddl.ts - Read/rebuild marts:
backend/src/modules/starrocks/starrocks-analytics.service.ts - Dimensions:
backend/src/modules/starrocks/starrocks-dim.service.ts - Parity:
backend/src/modules/starrocks/starrocks-parity.service.ts - Backfill/selfcheck:
backend/scripts/starrocks-backfill.ts,backend/scripts/starrocks-selfcheck.ts