Finitomata
Stop writing FSM plumbing. Start writing business logic.
is the FSM boilerplate based on callbacks โ define your state machine in PlantUML or Mermaid, and let Finitomata generate the GenServer, validation, persistence, and tests for you.
The Pitch
Finite state machines are everywhere in real systems โ order pipelines, connection lifecycles, workflow engines, payment flows. But hand-rolling an FSM means writing the same boilerplate over and over: process management, transition bookkeeping, event validation, state persistence, testing. It's error-prone, it's tedious, and it's not where your value lives.
Finitomata
is the Elixir library that reads your FSM description โ in
PlantUML
(
:state_diagram
) or
Mermaid
(
:flowchart
) syntax โ validates that it's consistent, and generates a battle-tested
GenServer
you can run standalone or inside a supervision tree. You implement
one mandatory callback
(
on_transition/4
). Finitomata handles everything else: transitions, history, failure handling, persistence, timers, and distributed operation.
Why Finitomata?
Describe, don't code
Define your state machine the way you'd draw it:
s1 --> |to_s2| s2
s1 --> |to_s3| s3
Finitomata validates it's consistent โ a single initial state, one or more final states, no orphan states โ then generates the FSM. The diagram is the implementation.
One required callback
def on_transition(:s1, :to_s2, _event_payload, state_payload),
do: {:ok, :s2, state_payload}
on_transition/4
is the only thing you must write.
on_failure/3
,
on_enter/2
,
on_exit/2
,
on_terminate/1
, and
on_timer/2
are all optional with sensible defaults.
Tuning that fits real needs
-
timer:โ recurring callbacks to refresh state from the outside world. -
auto_terminate:โ automatically transition to the end state. -
ensure_entry:โ retry a transition until it succeeds. -
hibernate:โ hibernate on selected states to save memory. -
cache_state:โ ETS-backed state caching. - Pluggable persistence โ built-in ETS (in-memory) and DETS (disk-durable) adapters.
Distributed by design
Infinitomata
โ shipped in the same package โ is a self-contained distributed implementation built on
:pg
for running the same FSMs across a cluster. Your state machines scale the way your Elixir app does.
Testing that's finally painless
Finitomata.ExUnit
provides a dependency-free test harness with
assert_transition/3
, failure assertions (
assert_no_transition/3
), and property-based event generation. Test your FSMs the way they'll actually run โ without fighting the framework.
Smart event semantics
-
Banged events
(
start!) โ a determined transition, entered instantly when it's the only option from a state. -
Questioned events
(
start?) โ expected to fail; no spuriouson_failurecalls or log warnings.
The Tech
| Language | Elixir |
| Runtime | OTP ยท GenServer |
| FSM input |
PlantUML (
:state_diagram
) ยท Mermaid (
:flowchart
)
|
| Persistence | ETS ยท DETS (built-in adapters) |
| Distributed |
Infinitomata on
:pg
|
Who It's For
- Elixir developers who need robust state machines without the boilerplate.
- Teams building workflows, order pipelines, or connection lifecycles.
-
Engineers who want distributed FSMs
(
Infinitomata) without rolling their own cluster coordination. - Anyone who values testing โ with an ExUnit harness that keeps up.
Bottom Line
An FSM is a contract between your states and your events. Finitomata makes that contract visible โ you draw it, validate it, and let the library generate the GenServer, persistence, distribution, and tests that turn a diagram into production code. One callback. Real state machines. Zero plumbing. That's the boilerplate you'll never write again.