TODO Example
Use this example to model a simple TODO list and see where CRUD ends and behaviour starts.
Scenario
A user wants to create tasks, mark them complete, reopen them, and view what is still due. A basic TODO system is mostly CRUD, but deadlines, reminders, assignment, and review rules can turn it into a small workflow system.
Simple CRUD Version
- Actor: User.
- User Interface: TODO List.
- Record or aggregate: Todo Item.
- Commands: Create Todo Item, Update Todo Item, Delete Todo Item.
- Events: Todo Item Created, Todo Item Updated, Todo Item Deleted.
- Read models: Todo List, Todo Item Detail.
- Queries: Show Open Todo Items, Show Completed Todo Items, Search Todo Items.
This version is enough when TODO items are just personal notes with a title, optional due date, status, and description.
Behaviour-Rich Version
Use more specific commands when TODO items have meaningful state transitions.
- Commands: Add Todo Item, Prioritize Todo Item, Assign Todo Item, Complete Todo Item, Reopen Todo Item, Defer Todo Item.
- Events: Todo Item Added, Todo Item Prioritized, Todo Item Assigned, Todo Item Completed, Todo Item Reopened, Todo Item Deferred.
- Aggregate: Todo Item.
- Policies: send reminder when due date approaches; notify assignee when item assigned; escalate overdue high-priority item.
- Read models: My Open Todo Items, Team Todo Board, Overdue Todo Items, Completed Todo History.
Aggregate Rules
- A completed TODO item cannot be completed again.
- A deleted TODO item cannot be reopened.
- A TODO item cannot be assigned to an inactive user.
- A due date cannot be earlier than the creation date.
Command Details
Add Todo Item
- Input fields: title, description, dueDate, priority.
- Validation: title is required.
- Success event: Todo Item Added.
Complete Todo Item
- Input fields: todoItemId, completedBy, completedAt.
- Validation: item exists and is open.
- Success event: Todo Item Completed.
- Rejection reasons: item is already completed, deleted, or not visible to the user.
Reopen Todo Item
- Input fields: todoItemId, reopenedBy, reason.
- Validation: item is completed and not deleted.
- Success event: Todo Item Reopened.
Read Models
- My Open Todo Items: title, due date, priority, assigned user, age, next action.
- Overdue Todo Items: title, owner, due date, priority, escalation status.
- Completed Todo History: title, completed by, completed at, cycle time.
When To Keep It Simple
If users only need to add, edit, complete, and delete personal tasks, the CRUD version is ideal. Use the behaviour-rich version when TODO items involve assignment, reminders, audit history, escalation, team accountability, or reporting.