🚀 Installation
Add the crate as a dependency in yourCargo.toml:
Feature Flags
Our framework is highly modular. You can enable specific adapters and engines depending on your production requirements.Enabling Durable Database Adapters:
- SQLite Support: Enable the
"sqlite"feature (uses therusqlitedriver under the hood). - PostgreSQL Support: Enable the
"postgres"feature (uses thepostgresdriver under the hood). - MySQL Support: Enable the
"mysql"feature (uses themysqldriver under the hood). - WASI MySQL Helper: Enable
"wasi-mysql"for raw TCP MySQL query execution from generic Wasmtime/WASI runtimes. - Spin MySQL Helper: Enable
"spin-mysql"for Spin SDK MySQL query execution.
Supported Backends:
- SQLite / Local File: Standard local embedded SQL.
- PostgreSQL: Stable high-performance relational database.
- MySQL: High-performance relational database with native stores plus runtime query helpers for Wasmtime (
"wasi-mysql") and Spin ("spin-mysql"). - LibSQL / Turso: Supported for distributed edge SQL via the
"wasi-libsql"query helper. - Redis: Supported for async event store, checkpoints, and pub/sub notifications via
"redis"/"wasi-redis"/"spin-redis".
Realtime and Notification Support:
The root crate provides durable stores, checkpoints, idempotency stores, and notification primitives. HTTP streaming is application-owned.- PostgreSQL / SQLite / MySQL: Use durable events and checkpoints to drive polling, SSE, WebSocket, or worker pipelines in your application.
- Redis: Provides experimental async persistence plus notification-only pub/sub wake messages. Durable replay remains the source of truth.
- MySQL: MySQL does not provide a built-in pub/sub stream in this library; pair it with Redis, an outbox worker, binlog CDC, NATS, Kafka, or WebSocket fan-out when low-latency push notifications are required.
API Notes:
- Aggregates are loaded by the repository using the external stream ID; the
Aggregatetrait does not require anid()method. EventTypeis a serde-transparent newtype. Convert it withas_str()orinto_string()when a database, UI, or protocol needs a plain string.SqlSchemaConfigtable-name builders validate eagerly and returnResult.- Process managers can be coordinated by
ProcessManagerRunnerorAsyncProcessManagerRunner. execute_idempotent(...)is portable but not crash-atomic across separate stores. Useexecute_idempotent_atomic(...)with native SQL stores for production request idempotency.
| Feature | Description | Third-Party Dependencies |
|---|---|---|
default | Standard local, thread-safe in-memory event store and memory projection runners. | None |
sqlite | Stable SQLite event store, checkpoint store, idempotency store, snapshot store, and atomic idempotent append. | rusqlite |
postgres | Stable PostgreSQL event store, checkpoint store, idempotency store, snapshot store, and atomic idempotent append. | postgres |
mysql | Stable MySQL event store, checkpoint store, idempotency store, snapshot store, and atomic idempotent append. | mysql |
wasi-mysql | Experimental raw TCP MySQL query helper for generic Wasmtime/WASI runtimes. | rsa, sha1, sha2, getrandom |
spin-mysql | Experimental Spin SDK MySQL query helper. | spin-sdk |
redis | Experimental async Redis event store, checkpoint store, pub/sub publisher, and command executor trait. | None |
wasi-redis | Experimental raw RESP Redis client for generic Wasmtime/WASI runtimes. | redis |
spin-redis | Experimental Spin SDK Redis client. | spin-sdk |
wasi-http | Experimental outbound HTTP helper foundation for WASI runtimes. | wasip3, http, http-body-util, bytes |
wasi-neon | Experimental Neon HTTP SQL query helper. | wasi-http |
wasi-libsql | Experimental LibSQL/Turso Hrana HTTP query helper. | wasi-http |
wasi-postgres-tcp | Experimental raw PostgreSQL TCP query helper for WASI-style runtimes. | md5, base64, pbkdf2, hmac, sha2, rustls |
spin-sqlite | Experimental Spin SQLite host-call query helper. | spin-sdk |
spin-postgres | Experimental Spin PostgreSQL host-call query helper. | spin-sdk |
wasi-supabase-rpc | Experimental Supabase RPC query helper. | wasi-http |
⚡ Quick 10-Second Example
Here is how simple it is to initialize our write path, tie it to an in-memory event ledger, and execute a transactional command:🗺️ How to Navigate This Documentation
We structured our guides as a structured, chronological path designed to take you from a complete beginner to building full-scale, distributed production applications:Start with the CLI: ddd CLI
- What you’ll learn: Install the
dddcommand, scaffold a new app withddd init, add domain events and commands withddd add, enable Redis/gRPC/tracing capabilities, run Spin-focused apps, and use dry-run JSON for agent/MCP workflows.
Module 1: The Patterns (Theory)
- What you’ll learn: The architectural foundations. Read about Domain-Driven Design (aggregate boundaries, Ubiquitous Language), CQRS (separating write vs read pipelines), State Changes (command validation vs event application), Queries (read models), and Event Sourcing mechanics.
Module 2: Domain Modeling (Tutorial)
- What you’ll learn: Build a fully validated Bank Account domain step-by-step. Implement Commands, Events (implementing
DomainEvent), Errors (handling invariants), and the core Aggregate Root struct.
Module 3: Domain Tests
- What you’ll learn: Write bulletproof business validations in microseconds. Learn why Event Sourcing is a unit-testing superpower and write elegant Given-When-Then tests using the Aggregate Test Fixture API.
Module 4: Configuring an Application
- What you’ll learn: Assemble your domain parts. Wire up the local InMemoryEventStore, write a custom Query Projection, and Assemble them together into a working execution loop.
Module 5: Building an Application (Production)
- What you’ll learn: Move to production. Start with Production Guarantees, define Error Handling and Transport Mapping, deploy durable SQLite, PostgreSQL, and MySQL stores, configure asynchronous Projections with Checkpoint tracking, review production Database Query Patterns, use experimental Redis persistence and realtime notifications, attach Metadata trace headers, write custom Event Upcasters for schema evolution, and Integrate with Web Frameworks (Axum).
Module 6: Leptos WASM SSR + Spin CQRS (Production Implementation)
- What you’ll learn: Put everything together across focused implementation pages. Build the pure domain, Spin/WASI storage adapters, checkpointed projections, Leptos server APIs, reactive UI, runtime backend configuration, and execution playbook for a production-grade full-stack CQRS application.
Module 7: Runtimes & Cloud Deployment (Spin vs. Wasmtime)
- What you’ll learn: Production runtimes and connection engineering. Understand the performance differences between Wasmtime CLI and Fermyon Spin connection pooling. Read our best practice architectural recommendations for database proximity, and learn how to deploy serverless WASM applications to Fermyon Cloud and SpinKube on AWS EKS, GCP GKE, and Azure AKS.
PRD and full tutorial pages are registered), see docs/docs.json.