ardalis / CleanArchitecture

Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
MIT License
15.26k stars 2.67k forks source link

Modify to support CQRS? #39

Closed tafs7 closed 4 years ago

tafs7 commented 5 years ago

@ardalis would be very interesting how you take this architecture using DDD and layer it with CQRS.

I'd be very interested to see how you'd structure your project. Could even be in a separate branch of this repo.

ardalis commented 4 years ago

I'd be interested to hear how many others would find this useful as a solution template. I'd be open to seeing PRs with this. I hesitate to have a separate branch with it because of the effort to maintain multiple branches.

PureKrome commented 4 years ago

Answer - use Mediatr (ref: github repo) as the framework to handle this. I'm assuming this would mean throwing the implementation in the Infrastructure layer.

ardalis commented 4 years ago

I would almost certainly use MediatR, agreed. I'd also split the repository interface so it separated reads/queries from writes/commands. Some of my DDD labs do this already when I use this as a starting point for DDD training workshops. I don't know that I have the energy to maintain a separate branch with this approach, but I could see doing something as a one-off with a blog post perhaps. I'll keep this open as a reminder to try it some time. :)

PureKrome commented 4 years ago

Nice! but .. as a one-off blog / branch? So the suggestion here is that adding CQRS is just 'too hardcore-advanced' and the idea here with this repo is a more simplistic scenario?

vs ...

CQRS + mediatr should be the default, unless it's a ToDo/Weather app?

ardalis commented 4 years ago

This repo is meant to be a solution template, not a sample app. It's just a starting point, not a full reference application with all the moving parts. If you want more of the latter, I suggest looking at the eShopOnWeb and eShopOnContainers repos. This repo is simplistic - not because it's meant for simplistic scenarios, but because when you start from it I don't want you to have to rip out a bunch of "sample" stuff you don't need.

ardalis commented 4 years ago

At this point, I think perhaps demonstrating how to use separate endpoints, which could be grouped according to CQRS principles, will have to be sufficient for the main version of this template. Closing.

dehghani-mehdi commented 2 years ago

@ardalis could you at least tell us what is the best project structure? for example where is the right place to put commands and queries?