ShawnShiSS / clean-architecture-azure-cosmos-db

A starting point to build a web API to work with Azure Cosmos DB using .NET 5 and Azure Cosmos DB .NET SDK V3, based on Clean Architecture and repository design pattern. Partition key is also implemented through the repository pattern.
MIT License
344 stars 95 forks source link

Place and use of MediatR code and Specification code #42

Open hansmbakker opened 3 years ago

hansmbakker commented 3 years ago

Hi,

thank you for this great starter repository and for the series of blog articles! I'm still finding my way how to best structure a DDD/CQRS project and your content is really helpful for that.

I was hoping you could help me understand the place and use of the MediatR code and Specification code better.

You put the Specifications in the Core (domain model) project; this seems similar to how the blog I linked above puts Queries in its Domain project.

SKharayat commented 2 years ago

@hansmbakker MediatR command and queries responsibility is to orchestrate the application flow and let the information flow from application layer to infrastructure (referencing core layer or models ) and finally to the database, this is the reason I myself keep them in application layer, also as Dto's are not a part of core (as per my view) they also act as ACL's in DDD so they do not need to flow via core layer they can be used in mediatR queries for fetching read-only data in this case also I feel queries should be application layer. I am myself struggling with structuring CQRS/DDD in my api's, please let me know your views on my inputs and if you have any suggestions that will be awesome .