Domain Model First Development
Start with domain behavior you can test without infrastructure. Add delivery and persistence after the model earns them.
Workflow
Write domain examples as tests using ubiquitous language.
Implement value objects, entities, aggregates, and domain services until the domain tests pass.
Add in-memory repositories for use-case tests.
Implement use cases as application orchestration over aggregate roots and ports.
Add infrastructure adapters last and verify they satisfy the same port contracts.
Rules
Do not let ORM annotations or API DTOs define the domain model.
Use factories and constructors to protect invariants.
Keep repository interfaces at the application boundary, not inside aggregates.
Prefer fast tests until the domain behavior is stable.
Detailed Reference
For non-trivial implementation, review, or refactoring work, read references/details.md before giving final guidance. It contains the detailed rules, examples, smells, and migration notes that do not belong in the short invocation body.
Output
Return the implementation order, tests to write, domain API sketch, repository contract, and adapter plan.