customer_relation 0.1.3
customer_relation: ^0.1.3 copied to clipboard
A deterministic, domain-driven customer relationship and trust model with strict invariants.
customer_relation #
A deterministic, domain-driven customer relationship and trust model for Dart.
This package helps you model customers, profiles, trust levels, and brand relationships with strict invariants, immutable identities, and fully controlled time.
If a rule can be violated, the API is considered broken.
Why this package exists #
Most customer/loyalty systems fail because:
- Identity can be mutated accidentally
- Trust levels can be skipped or forged
- Business rules live in services instead of the domain
- Time (
DateTime.now()) makes logic untestable and non-replayable
customer_relation fixes this by enforcing rules inside the domain, not in documentation or developer discipline.
Core principles #
-
Identity is sacred
Customer identity fields are immutable and validated. -
Trust is monotonic
Relationship levels can only move forward in a defined order. -
No hidden mutations
All state changes go through explicit intent-revealing methods. -
Time is injected, not magical
NoDateTime.now()leaks into the domain. -
Deterministic by design
Same input + same time = same output.
Features #
- Immutable
CustomerId - Safe
CustomerProfilemutation - Brand relationship lifecycle
- Trust level progression
Identity → Habit → Legend - Relationship status management
- Clock / TimeProvider abstraction
- Fully testable & replayable domain logic
Installation #
dart pub add customer_relation