Examples¶
Six runnable programs under examples/,
each a small application built around one machine. Every one runs in CI (test/unit/examples/),
so they keep up with the engine. Each page says what the example does, shows its machine, walks
through how it is built, and draws its main path as a sequence diagram.
Each also says how it runs, along the two axes of execution models: its semantics — does the caller wait for the result, or hand the event to a worker? — and its execution model — the caller’s own thread, a background event loop, or coroutines on the caller’s loop. Between them the examples cover each combination an application meets:
example |
what it is |
semantics |
execution model |
why |
|---|---|---|---|---|
the smallest machine, driven by a script |
synchronous — |
background (the default) |
a script: nothing to choose |
|
an order lifecycle: retries, a selector, |
synchronous |
background |
scenarios replayed one after another |
|
a payment driven by webhooks, with a durable timeout |
asynchronous — |
background (FastAPI’s |
the webhook must answer at once; a worker advances the machine |
|
a multi-step form that survives reloads and restarts |
synchronous — |
coroutines |
NiceGUI calls its handlers on its event loop |
|
an order whose state commits with the shop’s own writes |
synchronous |
inline |
one transaction for the shop’s rows and the machine |
|
seeds a store with executions in every state, for the monitor |
synchronous, with the trace on |
background |
a one-off seeding script |
Run any of them from the repository root, for example:
uv run python -m examples.minimal.run