Skip to main content

Overview

Decision Engine uses a Kafka to ClickHouse analytics pipeline:
  • API server captures full request and response bodies for API analytics events
  • API server publishes analytics events to Kafka
  • ClickHouse Kafka engine queue tables consume Kafka and materialized views fan into the raw tables
ClickHouse remains the analytics read store for:
  • business-domain analytics events
  • raw API request and response events
The analytics read path uses the two raw tables:
  • analytics_domain_events
  • analytics_api_events
The ingestion path is explicit in ClickHouse too:
  • analytics_domain_events_queue
  • analytics_api_events_queue
  • analytics_payment_audit_summary_buckets
  • analytics_domain_events_mv
  • analytics_api_events_mv
  • analytics_payment_audit_summary_buckets_mv
Payment Audit and Preview Trace now use a two-layer read shape:
  • raw event timelines still read from analytics_domain_events
  • summary lists read from the pre-aggregated analytics_payment_audit_summary_buckets
The correlation key for those reads is the write-time lookup_key:
  • payment_id when present
  • otherwise request_id

Local Bring-Up

Start the local analytics stack:
That profile now includes ClickHouse, Kafka, and topic creation. The full runtime profiles use the same ClickHouse-native ingestion path. There is no separate Rust worker process anymore. Local Compose versions:
  • ClickHouse: clickhouse/clickhouse-server:26.1
  • Kafka: apache/kafka:3.8.1
  • ClickHouse database: default
The bootstrap DDL now lives in:
  • clickhouse/scripts/
ClickHouse loads those shell scripts on first boot through /docker-entrypoint-initdb.d. They create the raw tables, recreate the Kafka queue tables and materialized views, create the payment-audit summary bucket table, and bind the queue tables to the configured Kafka brokers and topics. The analytics data volume is persistent, so normal restarts keep historical data. If you need a clean reset:

Config

Relevant config lives under:
There is no direct API-server write path to ClickHouse anymore. ClickHouse owns Kafka consumption through the queue tables and materialized views.

Retention

The raw analytics tables retain data for 18 months:
  • analytics_api_events
  • analytics_domain_events
Custom query windows are normalized to the same 18-month lookback horizon.

Troubleshooting

Useful checks when ingestion looks stalled:
  • Analytics — the operator-facing view built on this pipeline.
  • Payment Audit — single-payment timeline lookups against these tables.
  • Local Setup Guide — bringing up the analytics-clickhouse profile.