I'm looking for advice on how to structure namespaces in a CQRS structured application.
Currently the command-side and the query-side are in the same namespace in each bounded context, but as complexity is growing, it is starting to create problems.
Currently the structure has the following folders which each contains the implementation:
Application
+ Api
+ Cli
+ Web
Domain
+ Action (Command and Command Handlers in one - we are not using a CommandBus)
+ Event
+ Model
+-- Project
|-- Project.file
|-- ProjectRepository.file
Infrastructure
+ Consumer (Projections and ProcessManagers)
+ EventStore
+ Persistance (Denormalized read side)
+-- Project
|-- SqlProjectRepository.file
Common (Supporting namespace)
The issue is now that the Domain Model currently contains both the entities and event sourced aggregate root which are essentially only part the query-side and command-side, respectively.
There is no overlap in the aggregates of the query-side and command-side.
In a refactoring to a separation, where should the slice be made?
A full slice resulting in a query and a command-side which means that even the Application layer has read and write side.
A slice which is only made on the Domain layer so that the query side contains the (quite anemic) entities of the read model and the command-side holds events, event sourced aggregate root and more.
Please make a 3rd suggestion, if mine do not apply. Thanks.
This is the approach I take - based on CQRS and DDD, noting that our DDD extends to having a separate solution (.NET - Web APIs for different domain bounded contexts).
Secondly, all our infrastructure code, auth handling, and shared code - is done in a private package manager, which removes some of the mess, of a single solution, we DI it in the StartUp (DI). Also note we use EntityFramework as our DB implementation.
However, given that, here is how I and my team, separate out CQRS and DDD.
+ App
+- Command
+-- Application.Command
+-- Data.Command.EntityFramework
+-- Domain.Command
+- Query
+-- Application.Query
+-- Data.Query.EntityFramework
+-- Domain.Query
+ Build
+- Pipeline
+ Database
+- Data.Database.EntityFramework
+- Data.Database.Model
+ Test
Api (API app)
Cli