Deterministic Execution
Same events always produce the same state. No hidden side effects, no surprises. Perfect for testing, debugging, and time-travel capabilities.
Building stateful applications is hard. State management often becomes a black box—difficult to debug, impossible to replay, and challenging to distribute across systems. Traditional approaches lack auditability, determinism, and durability guarantees that modern distributed systems demand.
XMachines brings deterministic, durable, and distributed state management through a unique combination of technologies:
Deterministic Execution
Same events always produce the same state. No hidden side effects, no surprises. Perfect for testing, debugging, and time-travel capabilities.
Git-Backed Durability
Events are stored as Git objects in an append-only log. Your state history is version-controlled, replicable, and distributed using standard Git protocols.
Stream Architecture
Built on Web Streams API. All I/O flows through in, out, err, and snapshot streams with proper backpressure and cancellation support.
Universal Frontend
Build universal frontend apps with strict separation between business logic, runtime adapters, and views. Same code runs in browser, Node, or edge functions.
Protocol Projections
Expose your machines via REST APIs, MCP tools for AI agents, or custom protocols. One state machine, multiple interfaces.
Here’s a simple counter machine with XMachines:
import { createRun } from '@xmachines/core';
// Create a run (instance) from your machine definitionconst run = createRun(counterMachine);
// Get a writer to apply eventsconst writer = run.in.getWriter();
// Apply events - the sole way to mutate stateawait writer.write({ type: 'START' });await writer.write({ type: 'INCREMENT', value: 5 });await writer.write({ type: 'INCREMENT', value: 3 });
// Read the current state snapshotconst reader = run.snapshot.getReader();const { value: snapshot } = await reader.read();
console.log(snapshot); // { count: 8, status: 'running' }Every time you replay these events, you get the exact same state. The event history is stored durably in Git-compatible format.
Event-Sourced Applications
Build systems where every state change is captured as an event. Replay history, audit changes, and implement time-travel debugging.
Stateful REST APIs
Expose state machines as REST endpoints with automatic event streaming, snapshots, and PATCH-based mutations.
AI Agent Support
Connect your state machines to AI agents via the Model Context Protocol (MCP). Machines become tools that agents can invoke.
Universal Frontend with Play
Build universal frontend apps with Play—strict separation between business logic and runtime adapters. Same code runs in browser, Node, or edge functions.
Ready to dive in? Start with our guides:
Getting Started
Install XMachines and build your first state machine in minutes.
Core Concepts
Understand the fundamentals of machines, runs, streams, and durability.
Platform
Learn how to integrate XMachines into browsers, Node, and universal frontends.
RFCs
Read the technical specifications for detailed architecture and design decisions.
View on GitLab
Explore the source code and contribute to the project.