Skip to content

Install

Requirements

  • Go 1.24 or newer.

The engine

sh
go get github.com/arisros/fate

That's the whole library. It imports only the standard library — adding fate to a project drags in no transitive dependencies.

go
import "github.com/arisros/fate"

Temporal integration (optional)

The Temporal integration is a separate module so that adopters who only want the engine never pull in the Temporal SDK or its transitive graph:

sh
go get github.com/arisros/fate/temporal
go
import "github.com/arisros/fate/temporal"

See the Temporal guide on GitHub for running a machine inside a workflow.

The CLI

A small command-line tool renders (ASCII / Mermaid / graph), inspects, and diffs statecharts from JSON descriptors and snapshots:

sh
go install github.com/arisros/fate/cmd/fate@latest
sh
fate render   machine.json     # ASCII diagram
fate mermaid  machine.json     # Mermaid source
fate graph    machine.json     # resolved canvas graph JSON
fate snap     machine.json     # snapshot
fate diff     a.json b.json    # structural diff

TIP

The CLI is engine-only and file-based as of v0.4.0 — it operates on descriptor and snapshot JSON, with no built-in demo machines. For an interactive, visual experience, use the studio.

Verify

sh
cat > main.go <<'EOF'
package main

import (
	"context"
	"fmt"

	"github.com/arisros/fate"
)

func main() {
	m, _ := fate.CreateMachine(fate.MachineConfig[struct{}, string]{
		ID: "ping", Initial: "idle",
		States: map[string]fate.StateNodeConfig[struct{}, string]{
			"idle": {On: map[string][]fate.TransitionConfig[struct{}, string]{"GO": {{Target: "done"}}}},
			"done": {},
		},
	})
	a := fate.NewActor(m)
	_ = a.Start(context.Background())
	_ = a.Send(context.Background(), "GO")
	fmt.Println(a.Snapshot().Value.Path()) // done
}
EOF
go run main.go   # prints: done

Next

Released under the MIT License · v0.4.0 · pkg.go.dev