# arisros/fate architecture

> Architecture diagram of the GitHub repository arisros/fate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arisros/fate
- Repository: https://github.com/arisros/fate

## Overview

fate is a dependency-free Go statechart engine. Users define a machine, create and start an actor, then send events; the actor evaluates transitions and actions to update its state and context. Delays and invoked work are exposed as pending effects for adapters to drive. Snapshots support persistence and restoration. Separate product surfaces provide HTTP simulation, a Temporal workflow adapter, and descriptor-based visualization and inspection. The graph follows README capabilities; some subsystem links are based on documented APIs because their implementation was not sampled.

Main entry points: [`actor.go`](https://github.com/arisros/fate/blob/main/actor.go) (Actor runtime), [`cmd/fate/main.go`](https://github.com/arisros/fate/blob/main/cmd/fate/main.go) (Fate CLI), [`temporal/workflow_actor.go`](https://github.com/arisros/fate/blob/main/temporal/workflow_actor.go) (Temporal adapter), [`machine.go`](https://github.com/arisros/fate/blob/main/machine.go) (Machine config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Statechart core"]
  node_machine["Machine config<br/>[machine.go]"]
  node_validation["Config validation<br/>[validator.go]"]
  node_actor["Actor runtime<br/>[actor.go]"]
  node_actions["Actions<br/>[action.go]"]
  node_guards["Guards<br/>[guard.go]"]
  node_state["State values<br/>[state_value.go]"]
end

subgraph group_effects["Effects and adapters"]
  node_timers["Delayed transitions<br/>[timer.go]"]
  node_invokes["Invocations<br/>[invoke.go]"]
  node_temporal["Temporal adapter<br/>[workflow_actor.go]"]
  node_http["HTTP simulator<br/>[handler.go]"]
end

subgraph group_inspection["Inspection tools"]
  node_persistence["Snapshot persistence<br/>[persist.go]"]
  node_descriptor["Machine descriptor<br/>[descriptor.go]"]
  node_render["Chart renderers<br/>[ascii.go]"]
  node_cli["Fate CLI<br/>[main.go]"]
  node_diff["Snapshot diff<br/>[diff.go]"]
end

node_user(("Machine user"))
node_studio(("Studio client"))
node_temporal_service(("Temporal services"))

node_user -->|"defines"| node_machine
node_machine -->|"validates config"| node_validation
node_user -->|"creates and starts"| node_actor
node_actor -->|"uses"| node_machine
node_user -->|"sends events"| node_actor
node_actor -->|"checks transitions"| node_guards
node_actor -->|"updates state"| node_state
node_actor -->|"runs actions"| node_actions
node_actor -->|"exposes timers"| node_timers
node_actor -->|"exposes invocations"| node_invokes
node_temporal -->|"drives effects"| node_actor
node_temporal_service -->|"hosts workflow"| node_temporal
node_temporal -->|"runs activities"| node_temporal_service
node_http -->|"dispatches events"| node_actor
node_studio -.->|"simulates machine"| node_http
node_actor -->|"persists snapshot"| node_persistence
node_user -->|"requests snapshot"| node_actor
node_actor -->|"describes machine"| node_descriptor
node_cli -->|"loads descriptor"| node_descriptor
node_cli -->|"renders chart"| node_render
node_cli -->|"compares snapshots"| node_diff
node_user -->|"inspects JSON"| node_cli

click node_machine "https://github.com/arisros/fate/blob/main/machine.go"
click node_validation "https://github.com/arisros/fate/blob/main/validator.go"
click node_actor "https://github.com/arisros/fate/blob/main/actor.go"
click node_actions "https://github.com/arisros/fate/blob/main/action.go"
click node_guards "https://github.com/arisros/fate/blob/main/guard.go"
click node_state "https://github.com/arisros/fate/blob/main/state_value.go"
click node_timers "https://github.com/arisros/fate/blob/main/timer.go"
click node_invokes "https://github.com/arisros/fate/blob/main/invoke.go"
click node_temporal "https://github.com/arisros/fate/blob/main/temporal/workflow_actor.go"
click node_http "https://github.com/arisros/fate/blob/main/httphandler/handler.go"
click node_persistence "https://github.com/arisros/fate/blob/main/persist.go"
click node_descriptor "https://github.com/arisros/fate/blob/main/descriptor.go"
click node_render "https://github.com/arisros/fate/blob/main/render/ascii.go"
click node_cli "https://github.com/arisros/fate/blob/main/cmd/fate/main.go"
click node_diff "https://github.com/arisros/fate/blob/main/diff/diff.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_machine,node_validation,node_actor,node_actions,node_guards,node_state,node_user,node_studio toneBlue
class node_timers,node_invokes,node_temporal,node_http toneAmber
class node_persistence,node_descriptor,node_render,node_cli,node_diff toneMint
class node_temporal_service toneIndigo
```

## Components

### Statechart core

- [Machine config](https://github.com/arisros/fate/blob/main/machine.go): `machine.go`
- [Config validation](https://github.com/arisros/fate/blob/main/validator.go): `validator.go`
- [Actor runtime](https://github.com/arisros/fate/blob/main/actor.go): `actor.go`
- [Actions](https://github.com/arisros/fate/blob/main/action.go): `action.go`
- [Guards](https://github.com/arisros/fate/blob/main/guard.go): `guard.go`
- [State values](https://github.com/arisros/fate/blob/main/state_value.go): `state_value.go`

### Effects and adapters

- [Delayed transitions](https://github.com/arisros/fate/blob/main/timer.go): `timer.go`
- [Invocations](https://github.com/arisros/fate/blob/main/invoke.go): `invoke.go`
- [Temporal adapter](https://github.com/arisros/fate/blob/main/temporal/workflow_actor.go): `temporal/workflow_actor.go`
- [HTTP simulator](https://github.com/arisros/fate/blob/main/httphandler/handler.go): `httphandler/handler.go`

### Inspection tools

- [Snapshot persistence](https://github.com/arisros/fate/blob/main/persist.go): `persist.go`
- [Machine descriptor](https://github.com/arisros/fate/blob/main/descriptor.go): `descriptor.go`
- [Chart renderers](https://github.com/arisros/fate/blob/main/render/ascii.go): `render/ascii.go`
- [Fate CLI](https://github.com/arisros/fate/blob/main/cmd/fate/main.go): `cmd/fate/main.go`
- [Snapshot diff](https://github.com/arisros/fate/blob/main/diff/diff.go): `diff/diff.go`

### Other components

- **Machine user**
- **Studio client**
- **Temporal services**

## Connections

- Machine user → Machine config: defines
- Machine config → Config validation: validates config
- Machine user → Actor runtime: creates and starts
- Actor runtime → Machine config: uses
- Machine user → Actor runtime: sends events
- Actor runtime → Guards: checks transitions
- Actor runtime → State values: updates state
- Actor runtime → Actions: runs actions
- Actor runtime → Delayed transitions: exposes timers
- Actor runtime → Invocations: exposes invocations
- Temporal adapter → Actor runtime: drives effects
- Temporal services → Temporal adapter: hosts workflow
- Temporal adapter → Temporal services: runs activities
- HTTP simulator → Actor runtime: dispatches events
- Studio client → HTTP simulator: simulates machine
- Actor runtime → Snapshot persistence: persists snapshot
- Machine user → Actor runtime: requests snapshot
- Actor runtime → Machine descriptor: describes machine
- Fate CLI → Machine descriptor: loads descriptor
- Fate CLI → Chart renderers: renders chart
- Fate CLI → Snapshot diff: compares snapshots
- Machine user → Fate CLI: inspects JSON
