Skip to content

Getting started

Install OrderLoop, apply the D1 migrations locally, run the web app and engine together, and start a scenario.

OrderLoop is a pnpm + Turborepo monorepo. Local development runs both Workers in one Vite session: the web app, and the engine as a Vite auxiliary Worker, so the ENGINE service binding, the OrderAgent Durable Objects and both Workflows all work on your machine.

  • Node.js 22 or later, and pnpm (the version is pinned in the root package.json)
  • A Cloudflare account, if you want live AI. Workers AI always calls your account, even in local dev. Without one, set AI_MODE to "mock" (see Configuration).
git clone https://github.com/blakebauman/orderloop
cd orderloop
pnpm install
pnpm db:migrate:local # applies packages/db/migrations to the local D1
pnpm web:dev # web + engine in one Vite session

Open the URL Vite prints (http://localhost:5173 by default). With APP_PASSWORD unset, which is the default in apps/web/.dev.vars.example, and no people added, the dashboard and the API are open; Set up sign-in in the menu creates the first operator and turns sign-in on (see Team and roles).

The first request that needs a flow seeds the built-in flows and publishes version 1 of each.

The dashboard lists one-click scenarios, each a real order on a seeded flow: a B2B purchase order read from an email, an order over its credit limit, an out-of-stock order that rolls back, a purchase request, a stock review, two subscriptions, a storefront order that is returned and one priced in euros. Start one and the order page opens: the flow graph colours each node as it runs, waits and finishes, and the timeline records every step. Below the queues, the dashboard’s Last 30 days section shows, in USD, completion rate by order type, revenue per day, refund rate and the slowest steps by p95 duration.

Waits are compressed in development. TIME_SCALE (default 1440) divides every wait and timeout, so a day becomes a minute and a 30-day return window closes in about half an hour.

Some orders stop at an approval or wait for an event. Decide approvals from the order page or the Approvals inbox; deliver events (for example payment.received) from the order page, the REST API or a signed webhook.

curl -s http://localhost:5173/api/v1/orders \
-H 'content-type: application/json' \
-H 'Idempotency-Key: demo-1' \
-d '{
"flowId": "tpl-b2b-order",
"input": {
"type": "b2b_order",
"customerId": "cus_northwind",
"lines": [{ "sku": "WID-100", "qty": 50 }]
}
}'
# → 201 { "orderId": "ord_…" } (a repeat with the same key: 200, same orderId)

Then read its live state with GET /api/v1/orders/:id.

pnpm test # core planner tests (node), engine Workflow e2e (workerd), web tests
pnpm lint # Biome
pnpm check-types # tsc --noEmit (web runs react-router typegen first)

After changing a wrangler.jsonc, regenerate that app’s binding types with pnpm --filter @orderloop/engine types or pnpm --filter @orderloop/web types.

  • Concepts: flows, versions, orders, waits and rollback.
  • Building flows: the editor and the rules a flow must follow.
  • Deploy: ship both Workers to your account.