# Architecture Overview
Source: https://docs.maelstrom-ai.co/understanding/architecture/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

Maelstrom turns a user's intent into a UI update. The client sends the current Chart state and update reasons to an Engine host. A configured Planner proposes changes, the Engine validates them, and the client applies the accepted response. Play the diagram to follow a request, or select a package to inspect its role.

## The round-trip, in words

### It starts with a reason

Every update begins with an `UpdateReason`, and there are three: a `user_intent` (someone asks for something), a `chart_resize` (the available grid changed), or a `vessel_mutation` (an Instance changed its active Variant). [`@maelstrom-co/client`](https://docs.maelstrom-ai.co/understanding/llm-orchestration/) batches the pending reasons and builds a `ChartRequest`. This snapshot contains Instance identities and Variants, the current layout, Chart dimensions in grid cells, registered Vessels, and the layout mode. A `ChartRequestMessage` carries it with a session ID, message ID, and timestamp.

### The Planner proposes and the Engine validates

[`@maelstrom-co/engine`](https://docs.maelstrom-ai.co/understanding/engine/) holds no client layout state. It loads prior turns when history is configured and passes the request to a Planner. The reference LLM Planner builds prompts and calls a provider adapter; another Planner can use a different decision process. The Engine validates the candidate and repairs recoverable layout and Action problems.

The accepted `MaelstromResponse` contains a `userMessage` for the user, a `rationale` for diagnostics, an `executionPlan`, and a `layout`. Its `requestId` identifies the originating message.

### The client applies it

The client queues `set_layout` and `execute_actions` as one ordered batch, with layout first. Other queued commands cannot interleave with that batch. Action failures or skips do not roll back the layout or completed Action effects. Retrying the whole batch can repeat effects from Actions that already ran.

A tiling response can introduce an Instance and request an Action on it in the same response. Applying the layout first establishes that Instance before the client waits for its Action runner. The runner must register before the readiness timeout; otherwise, the client skips the Action.

### The loop closes

Applying the response updates the UI. The Chart's `ResizeObserver` watches its container. When the container's pixel size changes enough to change its whole-cell dimensions, the client sends a new `chart_resize` request. That starts a separate Engine turn. The client performs no inline size-reconciliation pass after Actions; the Chart clips visual overflow with CSS.

## The vocabulary

**Vessel**

A registered UI definition with an ID, a description, and a set of Variants. The Planner uses these definitions to choose layouts and Actions. See the [vessel state machine](https://docs.maelstrom-ai.co/understanding/vessel-state-machine/).

**Variant**

One discrete state of a Vessel, carrying its props, the Actions available in that Variant, and a `minSize`. The Engine checks this minimum against the request's Variant snapshot when validating grid positions. A local Action can switch to a larger Variant without resizing its allocation; the client schedules replanning.

**Action**

An operation the client runs on an Instance. It may move the Instance to another Variant via `transitionsTo`.

**Chart**

The container that displays Instances. Grid layouts use integer cells ( `rows` × `columns`). Tiling, the default, uses a tree of `H`/`V` splits. The client converts either layout to pixel bounds using the container dimensions.

`protocol` defines the shared contracts. `client` manages requests and applies responses; `react` binds it to React. `engine` coordinates planning and validation on the server, and `planner-llm` provides the reference LLM Planner.

## Observe the workflow with DevTools

DevTools observes the existing workflow. Its core package owns the bounded collector, explicit content capture, and shared browser panel. The React adapter owns attachment and mounting. Engine evidence crosses through the protocol only when the server host authorizes forwarding for that connection. Select an evidence path below to see who owns each step.

The default production entrypoints are inert. Explicit `/production` imports enable browser tools in every build; production Engine forwarding stays disabled. Follow the [DevTools guide](https://docs.maelstrom-ai.co/guides/devtools/) for installation and recording.

## Where to go next

-   [Quick start](https://docs.maelstrom-ai.co/getting-started/quick-start/): build a Chart.
-   [Core concepts](https://docs.maelstrom-ai.co/getting-started/core-concepts/): Vessels, Variants, and the Chart.
-   [The protocol](https://docs.maelstrom-ai.co/understanding/protocol/): Engine messages and wire envelopes.
-   [The engine](https://docs.maelstrom-ai.co/understanding/engine/): planning, validation, and history.
-   [Why Maelstrom](https://docs.maelstrom-ai.co/understanding/why-maelstrom/): the motivation.
