Domain creation
Use action/event discovery to model a domain. Actions and events are the primary engine β models, requirements, and flow outlines are all derived from them, not designed independently.
Derivation Chain
Actions + Events β Aggregates β DBML Models β Requirements (passed to feature loops) β Flow outlines (standalone *.flow.mdoc files)Phase 1 β Action/Event Discovery
Ask the user to describe what happens in this domain without structure or order. Capture both past-tense events and imperative commands:
- Events: past tense, PascalCase β one thing that occurred (UserRegistered, SessionExpired)
- Commands: imperative, PascalCase β one thing requested (RegisterUser, ExpireSession)
- Operations: request/response interactions (GetProfile, SearchUsers) β capture what they return and how they fail
- No filtering β capture everything
- Do not ask about models or structure yet
Phase 2 β Sequence Ordering
Arrange pairs into a chronological narrative:
[start] β RegisterUser β UserRegistered β ValidateCredentials β CredentialsValidated β SessionCreated β CredentialsRejected (Error) β AccountLockedAsk: what is the happy path? Where do branches occur? What are the named failure modes?
Phase 3 β Interaction Pairing
Pair every command with the event it produces, and every operation with its result and errors.
| Interaction | Result / Event | Failure Modes (Errors) |
|---|---|---|
| RegisterUser (Action) | UserRegistered | n/a (async) |
| GetProfile (Op) | Profile Data | ProfileNotFound |
| CreateOrder (Op) | Order ID | InsufficientFunds |
Derivation checkpoint: From these pairs you can sketch:
- Requirements for the feature loop: βThe system must support RegisterUserβ¦β
- Flow outlines: sequences of pairs that become *.flow.mdoc files
Phase 4 β Aggregate Discovery
Group command-event pairs by the entity that handles them. Each group becomes a DBML table.
User aggregate: RegisterUser β UserRegistered LockAccount β AccountLocked
Session aggregate: ValidateCredentials β CredentialsValidated CreateSession β SessionCreatedPhase 5 β Policy Discovery
Identify automatic reactions: βWhen [event], then automatically [command].β
When CredentialsRejected (3rd time) β LockAccountPhase 6 β Glossary
Formalize domain vocabulary discovered in phases 1β5. Ask: βIs there any term that needs a precise definition to avoid ambiguity?β
Phase 7 β DBML Model
Translate aggregates to DBML. Fields are derived from what commands need and events must record.
Phase 8 β Draft & Confirm
Present the complete .domain.mdoc draft for user confirmation before writing.
Output: content/domains/{id}.domain.mdoc
Doβs and Donβts
Do:
- Let actions and events drive all other artifacts β models, requirements, and flows are derived, not invented independently
- Capture every action and event the user mentions without filtering during discovery
- Pair every command with its resulting event before moving to aggregates
- Use the derivation chain (actions/events first, then aggregates, then DBML) strictly in order
- Present the full draft for confirmation before writing anything to disk
Donβt:
- Donβt start with models or data structures β always start with actions and events
- Donβt skip the glossary phase; ambiguous terms cause downstream confusion
- Donβt merge separate aggregates just because they share a field
- Donβt invent actions or events the user did not mention without flagging them as suggestions
- Donβt write the file before the user explicitly confirms the draft
Definition of Done
- Draft presented to user for confirmation
- Document written as
content/domains/{id}.domain.mdocwith correct frontmatter and root tag - All action/event pairs are complete and consistent
- DBML models are derived from aggregates, not invented independently
- All cross-references resolve to existing documents
pnpm compilesucceeds