# xmachines-docs
The guides of xmachines-rs, the Rust implementation of XMachines: a runtime that executes XState v6 machine definitions natively, with guards, actions, delays and computed values written in Rust, and runs them in-process, as WebAssembly components, in Node.js and next to a Kafka broker. This crate holds no code; it is the book, and its examples compile and run against the crates they describe.
This is an independent project, not an official Stately package. It targets `xstate@6.0.0-beta.6`.
## The guides
Start with `getting_started`; the others build on it, and each stands on its own after that.
| [`getting_started`](https://docs.rs/xmachines-docs/latest/xmachines_docs/getting_started/) | A machine (`MachineJSON`) on `xmachines-runtime`: load, start, send, time, snapshots, persist and restore, implementations |
| [`typed_machines`](https://docs.rs/xmachines-docs/latest/xmachines_docs/typed_machines/) | Codegen from a bundle in `build.rs`, the generated types and trait, and `TypedMachine` |
| [`evaluators`](https://docs.rs/xmachines-docs/latest/xmachines_docs/evaluators/) | Code nodes and their languages: Rust expressions, `Evaluator`, `HostEvaluator`, and JavaScript on QuickJS |
| [`codecs`](https://docs.rs/xmachines-docs/latest/xmachines_docs/codecs/) | The codec traits, JSON, MessagePack, protobuf and Avro, and a codec of your own |
| [`wasi`](https://docs.rs/xmachines-docs/latest/xmachines_docs/wasi/) | The two WIT packages and their JSON Schemas, the generic and the typed components, and their hosts |
| [`node`](https://docs.rs/xmachines-docs/latest/xmachines_docs/node/) | The Node.js addons, the `NodeRuntime` contract, Bun and Deno |
| [`kafka`](https://docs.rs/xmachines-docs/latest/xmachines_docs/kafka/) | The Kafka service: the engine, its configuration, its codecs and the local deploy stack |
| [`contracts`](https://docs.rs/xmachines-docs/latest/xmachines_docs/contracts/) | Every contract between the parts, where it lives, and how it is versioned and checked |
## The crates
| [`xmachines-runtime`](https://docs.rs/xmachines-runtime) | The runtime: loading and validating `MachineJSON`, the statechart algorithm, the actor system (XState's pure system API), persistence |
| [`xmachines-build`](https://docs.rs/xmachines-build) | Typed Rust modules from machine bundles at build time: context, events, params and the implementation trait |
| [`xmachines-eval-quickjs`](https://docs.rs/xmachines-eval-quickjs) | An evaluator for JavaScript code nodes on an embedded QuickJS (opt-in) |
| [`xmachines-machine`](https://docs.rs/xmachines-machine) | The contract of a typed machine (`TypedMachine`) and the JSON actor API its WASI components and Node addons share |
| [`xmachines-codec`](https://docs.rs/xmachines-codec) | Pluggable codecs of events and snapshots, registered by name, with JSON built in |
| [`xmachines-codec-msgpack`](https://docs.rs/xmachines-codec-msgpack) | MessagePack events and snapshots |
| [`xmachines-codec-protobuf`](https://docs.rs/xmachines-codec-protobuf) | Protocol Buffers events and snapshots, with `.proto` files generated from machine bundles |
| [`xmachines-codec-avro`](https://docs.rs/xmachines-codec-avro) | Avro events and snapshots in the Schema Registry wire format, with schemas generated from machine bundles |
| [`xmachines-runtime-wasi`](https://docs.rs/xmachines-runtime-wasi) | A WASI 0.2 component that runs any machine definition, with its guards and actions from the host, and `export_runtime!` to export it from another component |
| [`xmachines-machine-wasi`](https://docs.rs/xmachines-machine-wasi) | Typed WASI components for one machine each, with its implementations in Rust inside the component |
| [`xmachines-wasi-host`](https://docs.rs/xmachines-wasi-host) | A library for Wasmtime hosts of both WASI components: bindings, host implementations, actors |
| [`xmachines-runtime-node`](https://docs.rs/xmachines-runtime-node) | A Node.js native addon (napi-rs) with the WASI component's actor API, and its library for addons of one's own |
| [`xmachines-machine-node`](https://docs.rs/xmachines-machine-node) | Typed Node.js addons for one machine each, with its implementations in Rust inside the addon |
| [`xmachines-kafka`](https://docs.rs/xmachines-kafka) | A partition-sharded service next to any Kafka-API broker, with exactly-once state |
The JavaScript and TypeScript implementation of XMachines is [xmachines-js](https://gitlab.com/xmachin-es/xmachines-js); its `@xmachines/run` package runs machines on `xmachines-runtime-node` and on `xmachines-runtime-wasi` as two of its engines.
## Where else to read
- The repository's [`docs/ARCHITECTURE.md`](https://gitlab.com/xmachin-es/xmachines-rs/-/blob/main/docs/ARCHITECTURE.md): how the runtime, the authoring pipeline, the deployment targets and the testing fit together.
- The repository's [`AGENTS.md`](https://gitlab.com/xmachin-es/xmachines-rs/-/blob/main/AGENTS.md): every design decision, the verified XState v6 semantics, the measurements and the roadmap.
## License
MIT