DocsEngineeringArchitecture

Architecture

The complete runtime topology and communication model.

Chronoverse separates synchronous domain ownership from asynchronous orchestration. The HTTP gateway serves browser and external clients, gRPC services own domain state, and Kafka workers perform delayed or distributed work.

Runtime topology

HTTP gatewaySessions · CSRF · REST · SSE
gRPC domains
usersworkflowsjobsnotificationsanalytics
Kafka workers
schedulerworkflowexecutionjob logsanalyticsoutbox
Runtime data plane
runtime-agentDocker proxyruntime_nodes
infrastructure
PostgreSQLClickHouseRedisKafkaMeilisearchLGTM
Synchronous domain ownership with asynchronous, replay-safe orchestration.

The production entry point is Nginx. It serves the dashboard, proxies /api/... to the HTTP server, and disables response buffering for live job log routes.

Domain services

Five gRPC services own users, workflows, jobs, notifications, and analytics. They expose ports 50051 through 50055 inside Compose.

All five services expose gRPC reflection only outside production. Reflection requires a JWT valid for the target service. Health checks remain available without a JWT.

Asynchronous plane

Kafka carries workflows, jobs, job_logs, and analytics topics. Scheduling, workflow preparation, container execution, retained log processing, analytics, and outbox publication scale independently within topic and infrastructure constraints.

Persistence plane

  • PostgreSQL: transactional state, runtime nodes, leases, idempotency, outbox rows, container intents/receipts/holds, redrive audits, and analytics.
  • ClickHouse: retained high-volume job logs.
  • Redis: HTTP sessions, live log pub/sub, workflow lifecycle locks, and runtime-node-scoped image pull locks. Workflow and user reads use PostgreSQL directly.
  • Meilisearch: retained log search.
  • Runtime agent: Docker-capable node registration, heartbeat, and capacity metadata.
  • Docker proxy: token-authenticated, method-and-path-allowlisted node-local container lifecycle access.
  • LGTM: OpenTelemetry collection and dashboards.

Docker client compatibility

Container workers use the supported Moby client and API modules with automatic Docker Engine API negotiation (minimum API 1.40). An older daemon may report "client version too new" instead of a clear minimum-version error; check docker version and upgrade daemons below API 1.40.

Operators still patch their Docker daemon separately. golang-migrate's go.mod carries the legacy Docker SDK as an indirect requirement, pulled in by its PostgreSQL-driver tests via upstream dhui/dktest. Chronoverse source and compiled packages use Moby. Upstream test-helper migration and module cleanup are separate follow-ups, without a fork or module replacement in this application.

Design invariant

Workers request state transitions from domain services rather than directly inventing workflow or job state. This keeps replay and ownership rules concentrated at the domain boundary.

Container execution has an additional locality invariant: a container_id is never enough on its own. jobs-service assigns a fresh READY runtime node during claim, persists runtime_node_id and a Docker endpoint snapshot on the job, and workers use that endpoint directly for execution, live logs, cleanup, and expired-lease recovery. Immutable intent/materialization records retain the original daemon instance after source deletion. Cleanup receipts and capacity release require that same instance; quarantine or an administrative redrive does not bypass physical proof.

Repository architecture notesdocs/architecture.md