What Is a Command Handler?
A command handler is a unit of code that accepts a single command object expressing an intent to change state and carries out that change. It validates the request, loads the relevant aggregate, applies business rules, and persists the result. Each command type typically maps to exactly one handler.
Why it matters
Isolating each write operation in its own handler keeps business logic focused and testable. It is a core building block of CQRS, where the write side is modeled separately from reads.
Related guides
What Is a Query Handler?A query handler is the component that answers a read request by fetching and shaping data, without changing a…
What Is CQRS?CQRS separates the model used to change data from the model used to read it, letting writes and reads be desi…
What Is an Aggregate Root?An aggregate root is the single entity through which all access to a cluster of related domain objects flows,…