Architecture Overview
Architecture Overview
Architecture Overview
This document provides a high-level overview of the components and data flows in the system.
Components
-
API Service (
cmd/api) Exposes REST + SSE endpoints. Hosts the OpenAPI spec. Handles idempotency and error models. -
Runtime Translator (
runtime/translator) Validates Intermediate Representation (IR) against JSON Schema and compiles it into a Temporal workflow spec. -
Runtime Bridge (
runtime/bridge) Wraps the Temporal client. Provides APIs for starting, signaling, querying, and canceling runs. Executes generic workflows and activities. -
Workers Language-specific (Python, Go) adapters that execute activities such as LLM calls, tools, checkpoints, and token streaming.
-
Storage Backends Integration with Postgres and S3 for persisting checkpoints, logs, and workflow states.
-
Temporal Cluster Manages workflow execution, retries, signals, versioning, and search attributes.
Data Flows
- Client calls API (
create run). - API validates request and forwards IR to
translator. - Translator compiles IR into a Temporal workflow spec.
- Bridge submits workflow to Temporal with search attributes.
- Temporal schedules Activities on Workers.
- Workers execute activities (LLM/tool/etc.), stream tokens if needed, and checkpoint state to Postgres/S3.
- Client consumes updates through
/streamSSE endpoint.
Sequence Diagram (Mermaid)
sequenceDiagram
participant Client
participant API
participant Translator
participant Bridge
participant Temporal
participant Worker
Client->>API: POST /runs
API->>Translator: Validate + Compile IR
Translator-->>API: TemporalWorkflowSpec
API->>Bridge: StartRun(spec)
Bridge->>Temporal: ExecuteWorkflow
Temporal->>Worker: Schedule Activity
Worker-->>Temporal: Result / Checkpoint
Temporal-->>Bridge: Workflow Events
Bridge-->>API: Events
API-->>Client: SSE Stream (/stream)