| name | rust-contract-domain-modeling |
| description | Domain-driven modeling patterns for Axone contracts. Use when introducing domain concepts, encoding invariants, or deciding boundaries between domain, handlers, services, gateways, queries, and state. |
| license | BSD-3-Clause |
| metadata | {"author":"axone.xyz","version":"1.0"} |
Rust Contract Domain Modeling
Goal
Keep business invariants in explicit domain types instead of scattering them across handlers, query builders, or storage code.
Boundary Rules
domain/ owns business concepts and invariants.
handlers/ decode messages, orchestrate use cases, and shape responses.
services/ compose domain logic with environment-dependent enrichment or cross-module coordination.
gateway/ isolates external module interaction and protocol-specific I/O.
queries/ build external query payloads or request strings; they should not become the home of business rules.
state/ persists data and reconstructs domain values; it should not silently redefine domain invariants.
Domain Rules
- Prefer constructors such as
new or try_new that reject invalid states up front.
- Use
TryFrom when validating a parsed or transport-level representation into a domain type.