Search code examples
repositorydomain-driven-designcqrsclean-architecture

How Implement CRQS in DDD


If someone tries to implement the CQRS pattern without repository in DDD, in which layer should it be done? Infrastructure or Application Layer?


Solution

  • If you mean the implementation of the handlers of the queries and commands, it's done in the application layer.

    But you need a repository to abstract the technological implementation outside of use cases/interactors (application layer).

    The Infrastructure layer is responsible for encapsulating technology. You can find there the implementations of database repositories for storing/retrieving business entities, message brokers to emit messages/events, I/O services to access external resources, framework related code and any other code that represents a replaceable detail for the architecture.