---
title: "Application"
description: "An Application is the service you build with the Dex SDK. Its Workers run your Flows, and its Client starts and calls them through Dex Server."
canonical_url: "https://docs.superdurable.io/concepts/application/"
source: "docs/content/concepts/application.mdx"
locale: "en"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Application

An **Application** is the service you build with the Dex SDK. Its Workers run
your Flows, and its Client starts and calls them.

<a id="how-it-fits-with-the-other-components"></a>

> **Diagram**: Your Application holds a Client and a Worker, both built with the Dex SDK. The Client starts Flows and calls RPCs on Dex Server. The Worker connects to Dex Server and takes Steps and RPCs over that connection. Dex Server persists every Flow.

<a id="registry"></a>

## Flows and the Registry

A **Registry** holds your Flow definitions. Build the Worker and the Client
from the same Registry. The Worker runs those definitions. The Client uses
them to encode start input and RPC arguments and to decode results.

<a id="enable-pull-mode"></a>

## Worker

A **Worker** runs the Steps and RPC handlers of the Flows in its Registry. It
connects out to Dex Server and pulls its work. So it needs no inbound port or
Worker address.

> **Diagram**: A Worker gets its work over task streams that it opens to Dex Server, in six stages. The example is an adaptive Worker with four task slots and no reserved RPC slot. Two idle streams wait for a task. Dex Server sends a Step down one of them, and the Worker runs it. An RPC takes the last idle stream, so the Worker opens two more streams, up to its limit of four, and they take new Steps. With every stream busy, a new Step waits in the Step task queue in Dex. A Step finishes, its result returns on the same stream, and that stream is idle again. In this example, the waiting Step then goes to that stream.

Each stream runs one task at a time.
[Workers and the task queue](https://docs.superdurable.io/reference/server/workers.md#capacity-and-shutdown)
has the settings.

A Worker serves one task queue. An available Worker on that queue that
supports the Flow type and Step can take its next eligible task. Dex Server
holds Flow state across Worker restarts.
Keep state that a later Step needs in Dex, not in Worker memory.

<a id="dex-server"></a>

A Worker runs inside your service process, or as its own deployment when Steps
need different scaling or release timing than your API.

<a id="client"></a>

## Client

<a id="when-to-use-a-client"></a>

<a id="read-and-write-flow-state"></a>

<a id="flow-owns-decisions"></a>

<a id="related-primitives"></a>

<a id="reference"></a>

Your handlers use a **Client** to start Flows, call their RPCs, read
Attributes, wait for progress, and stop a Flow. It encodes with the Flow's
registered definition, so a service that only starts Flows still registers
them. The Flow writes its own state, and a Client changes it through RPCs. A
handler only starts the Flow or calls an RPC, and a Step writes your database
row, because writing a row and then starting a Flow is not atomic.

> **Diagram**: An API service calls Dex Server through its Client, one call at a time, in six stages. Starting a Flow sends the request, and the server saves the Flow. After the save, the reply to the Client and a Worker running the start Step are independent and come in no fixed order. A new RPC request goes through the server to a Worker, which runs the RPC handler. The server answers a read of Attributes from saved state alone. A wait for a Step returns when the Worker completes it, or ends earlier, for example when the Flow closes or the wait times out. Following a Stream relays the Worker's progress to the Client.

<a id="guarantees"></a>

<a id="client-guarantees"></a>

### Guarantees

- **A successful start returns only after Dex stores it.** The run continues
  even if your process exits.
- **An Attribute read returns saved values from one moment.**
- **A wait reads the Flow's saved state.** It can also end before its
  condition holds; see
  [Wait timeouts and limits](https://docs.superdurable.io/reference/server/client-apis.md#wait-timeouts-and-limits).
- **A cancel, fail, or terminate stop closes the run.** Once the stop commits,
  Dex starts no new Steps or cleanup for that run.

[Client APIs](https://docs.superdurable.io/reference/server/client-apis.md) describes each call, with a
runnable example.

<a id="blob-cache"></a>

## Blob cache

Dex sends a large value, such as a big Attribute, as a reference. Each process
keeps the values it downloads in a local **blob cache**. The Client and the
Worker of one process can share one blob cache, as they share the Registry.
A shared cache can reuse a value while it is cached.
[Blob cache](https://docs.superdurable.io/reference/server/workers.md#blob-cache) says how to open one.

<a id="operate-it-in-production"></a>

<a id="versioning-flow-code"></a>

<a id="versioning-example"></a>

<a id="lock-business-behavior-at-flow-start"></a>

<a id="evolve-data-and-contracts-additively"></a>

<a id="keep-old-definitions-until-old-flows-finish"></a>

<a id="time-travel"></a>

<a id="add-to-a-service"></a>

<a id="next"></a>

## Next

- [Connector](https://docs.superdurable.io/concepts/connector.md): a packaged integration with an external service, such as email or payments.
- [Flow](https://docs.superdurable.io/concepts/flow.md): what a Flow definition contains and how a run starts.
- Start a Worker: the Workers reference of [Go](https://docs.superdurable.io/reference/go/workers.md), [Python](https://docs.superdurable.io/reference/python/workers.md), [Java](https://docs.superdurable.io/reference/java/workers.md), [TypeScript](https://docs.superdurable.io/reference/typescript/workers.md), or [Rust](https://docs.superdurable.io/reference/rust/workers.md).
- [Install](https://docs.superdurable.io/install.md): set up `dexcli` and a local Dex. Each SDK reference has its install command: [Go](https://docs.superdurable.io/reference/go.md#install), [Python](https://docs.superdurable.io/reference/python.md#install), [Java](https://docs.superdurable.io/reference/java.md#install), [TypeScript](https://docs.superdurable.io/reference/typescript.md#install), and [Rust](https://docs.superdurable.io/reference/rust.md#install).
- [Test your application](https://docs.superdurable.io/reference/cli.md#test-your-application): run your tests against a real Dex Server.
