# CQRS

> A design pattern that separates the model that handles commands from the model that answers queries.

Record: `architecture:command-query-responsibility-segregation`
Kind: pattern
Layer: [Execution Core](https://banes-lab.com/records/layer/execution-core.md)
Severity: contextual
Scope: application, data access
Aliases: CQRS
Canonical: https://banes-lab.com/ontology#architecture-command-query-responsibility-segregation

Listed in [Architecture principles](https://banes-lab.com/api/records/architecture.md), after [Event Sourcing](https://banes-lab.com/records/architecture/event-sourcing.md) and before [Domain Events](https://banes-lab.com/records/architecture/domain-events.md).

## Repair

- Refactored by: Split Command and Query Models
- Detected by: command/query side-effect violations
- Violated by: queries mutating state, commands returning complex read models
- Measured by: read/write separation compliance
- Enforced by: handler conventions, [tests](https://banes-lab.com/records/lexicon/tests.md)

## Requires

- [Command/Query Separation](https://banes-lab.com/records/lexicon/command-query-separation.md)

## Reinforces

- [Scalability](https://banes-lab.com/records/architecture/scalability.md)
- [Event Sourcing](https://banes-lab.com/records/architecture/event-sourcing.md)

## Enables

- [Read/Write Model Optimization](https://banes-lab.com/records/lexicon/read-write-model-optimization.md)

## Conflicts with

- [Unified CRUD Model](https://banes-lab.com/records/lexicon/unified-crud-model.md)

## In tension with

- [Eventual Consistency](https://banes-lab.com/records/architecture/eventual-consistency.md)

## Tensions

- [CQRS / Eventual Consistency](https://banes-lab.com/records/tension/cqrs-eventual-consistency.md)

## Severity

- [contextual](https://banes-lab.com/records/vocabulary/severity-contextual.md)

## Category

- [Event / Messaging / Asynchronous Architecture](https://banes-lab.com/records/architecture-category/event-messaging-asynchronous-architecture.md)

## Enabled by

- [Event-Driven Architecture](https://banes-lab.com/records/architecture/event-driven-architecture.md)

## Linked from

- [Every record has a kind](https://banes-lab.com/software-architecture/principles/every-record-has-a-kind.md)
- [Event / Messaging / Asynchronous Architecture](https://banes-lab.com/ontology/principles/architecture-category-event-messaging-asynchronous-architecture.md)
- [Scalability / Performance / Optimization](https://banes-lab.com/ontology/principles/architecture-category-scalability-performance-optimization.md)
- [Event Messaging Async](https://banes-lab.com/ontology/lexicon/lexicon-category-event-messaging-async.md)
- [Severity levels](https://banes-lab.com/ontology/schema/the-vocabulary-severity.md)
- [The resolutions](https://banes-lab.com/ontology/schema/the-resolutions.md)
