Skip to content

Quickstart

This page runs everything on one machine: a cairnflow node, a small service, and the calls between them.

You need:

  • a Cairnflow runtime — a prebuilt release archive below, or Docker (no Rust, no database);
  • Node.js 22.18 or newer, which runs TypeScript files directly (Node.js 22.6 to 22.17 works with node --experimental-strip-types) — or Python ≥ 3.11 or Go ≥ 1.25.

Option A — Prebuilt binaries (Linux x86_64 below; the releases page has Linux arm64 and macOS arm64 too):

Terminal window
A=cairnflow-v0.1.0-beta.0-x86_64-unknown-linux-musl
mkdir -p ~/.local/bin # or any directory on your PATH
curl -L "https://github.com/cairnflowdev/cairnflow/releases/download/v0.1.0-beta.0/$A.tar.gz" \
| tar -xz -C ~/.local/bin --strip-components=1 "$A/cairnflow" "$A/cairn" "$A/cairn-ctl" "$A/cairn-query-worker"
cairnflow --no-auth # dev switch: no API key, for a machine only you reach

Option B — Docker:

Terminal window
docker run -d --name cairnflow -p 127.0.0.1:8080:8080 \
--add-host=host.docker.internal:host-gateway \
-v cairnflow-data:/var/lib/cairnflow \
ghcr.io/cairnflowdev/cairnflow:v0.1.0-beta.0 --no-auth
cairn() { docker exec cairnflow cairn "$@"; } # the CLI is in the container

Four self-contained binaries ship together: cairnflow (the runtime), cairn (the CLI), cairn-ctl (the operator tool) and cairn-query-worker. The node listens on 127.0.0.1:8080 (8081 is for other nodes), keeps all state under ./cairnflow-data, and serves the web console at http://127.0.0.1:8080/ui/. To compile from source instead, see Build from source.

In a second terminal, install @cairnflow/sdk (zero runtime dependencies):

Terminal window
mkdir greeter && cd greeter
npm init -y && npm pkg set type=module
npm install @cairnflow/sdk

A service is a set of handlers. ctx.run journals the result of a step: after a crash or retry, the step is replayed from the journal instead of running again.

service.ts
import { serve, service } from "@cairnflow/sdk";
const greeter = service("Greeter", {
greet: async (ctx, name: string) => {
// Journaled: a retry after a crash does not run it again.
const upper = await ctx.run("upper", () => name.toUpperCase());
return `Hello, ${upper}!`;
},
});
await serve({ services: [greeter], port: 9080 });

Start it and leave it running:

Terminal window
node service.ts

serve() listens on 127.0.0.1 by default, which is all a node on the same machine needs. When running the runtime in Docker, pass hostname: "0.0.0.0" in serve() so the container can reach your service. It prints a warning that identityKeys is not set: a service that other machines can reach should check that requests really come from your node. See Request identity.

To write the service in Python or Go, see Python SDK (pip install cairnflow) and Go SDK (go get github.com/cairnflowdev/cairnflow/sdk/go). On Vercel or AWS Lambda, the same service runs behind fetchHandler: see Serverless.

In a third terminal, register the deployment so Cairnflow reads its services and handlers, then invoke greet:

Terminal window
cairn register http://127.0.0.1:9080 # with Docker: http://host.docker.internal:9080
cairn invoke Greeter greet --input '"world"'

The answer carries the invocation ID and the handler’s output, "Hello, WORLD!". To fire and forget over HTTP, call POST http://127.0.0.1:8080/invoke/Greeter/greet/send instead: you get the invocation ID back as soon as it is durable.

Every step of the run is recorded. Inspect it with the cairn CLI:

Terminal window
cairn journal <invocation ID>

It lists the input, the step and its result, and the output. Open http://127.0.0.1:8080/ui/ in a browser to inspect journals, timelines and traces visually, retry or cancel runs, and query invocations with SQL.

--no-auth is only for local development on a machine only you reach. Without it, every route except /health requires an API key:

Terminal window
export CAIRNFLOW_ADMIN_KEY="cf_$(openssl rand -hex 24)" # bootstrap key, at least 32 bytes
export CAIRNFLOW_TOKEN="$CAIRNFLOW_ADMIN_KEY" # key sent by the `cairn` CLI
cairnflow # same directory, same data

For production, point the node at an S3-compatible bucket instead of a local directory: --main-store s3://my-bucket/prefix with the usual AWS_* environment variables.