What is CQRS?
CQRS stands for Command and Query Responsibility Segregation. What this means is that commands and queries should have separate responsibilities and clear domain boundaries.
Let say you have a controller, and the controller has a few endpoints for getting data, creating data, updating data, and removing data, and these are your GET, POST, PUT, and DELETE methods in short.
Everything in the controller that gets data or does not mutate data falls under Query; while everything else that mutates data, such as POST, PUT, and DELETE requests, is classified as Command.
Now, your application should have a query model that handles the query for getting data from the database. It should also have a command model that handles the command for writing or deleting data in the database.
The following is a diagram of a command that goes to your application:
The preceding Figure 6.1 shows the UI...