Replies: 3 comments
-
This project uses The Common Closure Principle (CCP) and Vertical Slice Architecture, meaning related things live close together (respecting the dependency rules between layers, where makes sense). This makes development process easier, since when you modify a feature you have everything you need in the module/feature directory close together and don't need to jump between multiple different places (which gets harder as project grows). I described it briefly in Folder and File Structure and Modules sections. Also check out this video. Regarding separation into In fact, even in current architecture it's not that hard to do. Even though some files live together, layers do not depend on each other (as described here). You could just write a script that goes through every You need to decide here what is more important to you: 1.developer experience of keeping things close together, or 2. making swapping framework somewhat easier (but honestly, will you ever need to do that? probably not). Regarding "infrastructure gathers ALL the rest" - you will at least need to have some separation between input adapters (public interface/API) and output adapters (database access layer, etc). Those two may have totally different frameworks used. If you swap the database, you'll need to change your output adapters, but if you need to swap for example REST to GraphQL you will need to change your input adapters. So I prefer to separate those two.
Regarding request context I agree, you could abstract and inject Regarding the aggregate, i'm not sure how you want to do it. You will need to pass event emitter and uuid into aggregate constructor each time you create it, which is not worth it IMO. You should aim to follow the architecture and domain purity most of the time (when it makes sense), this will make things easier, but trying to get it to 100% by injecting everything is not worth it (as I described here). 100% domain purity comes at a cost not worth paying for most projects, you most likely will never need to swap those frameworks. And even if you do, having 100% pure domain vs 90% pure domain won't make much difference. |
Beta Was this translation helpful? Give feedback.
-
I'll keep your point in mind. Thank you very much for this fast and really valuable insight! |
Beta Was this translation helpful? Give feedback.
-
@Sairyss |
Beta Was this translation helpful? Give feedback.
-
Hello, and first, thank you for sharing this impressive work.
Hexagonal guidelines I found:
In a speech (in french, sorry) about
hexagonal architecture
, despite theports
aspect, the architect explains it is a lot aboutstrict separation between the domain and the infrastructure
.domain
remains the same concept as in simple DDD approach (with ports)infrastructure
gathers ALL the rest: db layer, controllers, presenters, framework, libs, application layer (I've seen many different interpretation of what the application is layer and if it belongs to the domain or not but this is not my point here)The goal of this split is to make the infrastructure interchangeable easily, whenever the product requires a deep evolution of the stack (contrary to the domain which evolves alongside the business). Being able to change the stack having for main goal to avoid being stuck with some parts of it and avoiding producing code dept, obviously.
The speaker explains that, one good way to achieve this is:
domain
folder and aninfrastructure
folder at the root of our/src
folder https://youtu.be/rjqE3B7nrJk?t=770With your work:
If I want to follow these guidelines using your work, I would need:
src/domain
package containing my domain abstractions and having as dependencies, yourlibs/ddd
folder (with your guard, exception base class, your decorators and utils).@nestjs/event-emitter
anduuid
in aggregate-root.base.tsnestjs-request-context
andslonik
in AppRequestContext.tsThis would allow to have a strictly independent domain using all your conclusions (bridged entity props, guard vs validation, cqrs with correlation/causation...):
free to change the underlying framework
/ backendMy question
Anyway, thank you for your work and sharing it
Beta Was this translation helpful? Give feedback.
All reactions