Benefit of Using CQRS Pattern


Hello, I am interested of why you’re using CQRS( Command Query Responsibility Segregation) in this project, but I don’t think I am fully understanding why that you’re choosing CQRS and what would be different with using some other data model converter like AutoMapper to transit ViewModel with DomainModel/DTO, I would say they look quite similar.

There are people saying that CQRS is working better with Domain Driven Design in this case I guess your micro service architecture followed by that, some people saying CQRS is better working with Event Handler, but I couldn’t go deeper with why it’s benefit with DDD or Event handler unless there is an opposite or bad example to compare with, could you please guide me on this part?

Thank you very much for your tutorial!



The overall idea behind CQRS is that at first, there’s a single use-case (handler class) per query which follows the SRP. Yet, the most important benefit is that you can use different models (for writing and reading).
For example, in the command handler you would use your domain objects and keep them in database A, while within your queries, you could store so-called read models and for example keep them in database B (which could be NoSQL, some caching DB etc.) and achieve extremely fast reads due to such optimization and no additional data transformation required between your domain and read models.