0
votes

I have been using the following project structure in projects for some time, but want to start using CQRS/Event Sourcing. Looking for suggestions of how to structure the projects.

Currently I use this:

  • ProjectName.Common: Extension methods, helpers, etc.
  • ProjectName.Core: Contains the Domain Model and Service Interfaces that define how to interact with the Domain Model. I have been using Anemic Domain Models, but am looking to move to richer DDD models.
  • ProjectName.Data: Contains the Repositories and UnitOfWork used to persist Domain Models to Entity Framework.
  • ProjectName.Services: Conatins all of the Service Implementations described in the ProjectName.Core.Services namespace. Also contains the core business logic and validation and coordinates the retrieving and saving of Domain Models to the database via the repositories and unit of work.
  • ProjectName.Web: Usually an ASP.NET MVC project or some other Presentation Layer.

What would the same thing in a CQRS/Event Sourcing pattern look like as far as structure goes?

I have read this post here: CQRS/Event sourcing project structure, but was looking for other ideas and examples.

1
CQRS/ES has nothing to do with project structure. You can put everything in one project and it will work properly.MikeSW
@MikeSW - I understand that, but I was looking for comments on how people are structuring their commands, command handlers, etc.Sam
It's highly subjective so basically it's off topic for StackOverflowMikeSW

1 Answers

1
votes

If there is a need for the application to scale, make sure you are able to separate (if/when necessary) command handlers and event denormalizers into multiple projects. In extreme cases it could be 1 command/event handler per project.

It also means that commands and events would need to be in separate projects so they could be distributed among command and event handlers. Typically, command handlers would need to be able the domain project and the event store project. Events denormalizers would need to access the read model data access project.

UX, infrastructure, unit tests can be structured in any way that works for you.