stateset-core
Pure domain models and business logic for commerce applications. No I/O, no runtime — just the type system, validation, events, and repository traits you need to build a commerce backend.
Because there's no I/O in here, the domain is testable without a database and portable to any storage you like: implement the repository traits and the models, state machines, and validation come along unchanged.
Part of the StateSet iCommerce engine.
What's Inside
- 35+ domain modules: orders, payments, inventory, customers, products, carts, returns, subscriptions, shipments, manufacturing, promotions, tax, analytics, and more
- State machines:
OrderStatus,PaymentTransactionStatus,SubscriptionStatuswith exhaustive match enforcement - Event sourcing:
CommerceEventwith 30+ variants for full audit trails - Validation framework: composable
ValidationBuilderwith validators for email, SKU, phone, postal code, price, quantity - Repository traits: generic
Repository, auto-implemented for&T,Box<T>,Arc<T> - Error taxonomy:
CommerceErrorwithis_not_found(),is_retryable(),suggested_status_code(), and domain-specific sub-errors - Agent-to-agent commerce: A2A quotes, purchases, subscriptions, split payments, escrow
- Crypto primitives: x402 payment intents, ERC-8004 identity, Merkle proofs
Usage
Errors are categorized, so callers branch on meaning rather than on strings:
use CommerceError;
Validation composes and returns a single Result carrying every failure:
use ;
assert!;
assert!;
assert!;
Feature Flags
| Feature | Description | Default |
|---|---|---|
embeddings |
Vector embedding support (adds reqwest) |
No |
metrics |
Prometheus metrics (adds prometheus, once_cell) |
No |
test-utils |
Expose test helpers for downstream integration tests | No |
sqlx-postgres |
sqlx type impls for primitives, for PostgreSQL backends |
No |
rusqlite |
rusqlite type impls for primitives, for SQLite backends |
No |
Part of StateSet iCommerce
Built on stateset-primitives and
implemented against by stateset-db. Most
applications consume it via
stateset-embedded or
stateset-sdk.
License
MIT OR Apache-2.0