revoframework / Revo

Event Sourcing, CQRS and DDD framework for C#/.NET Core.
https://docs.revoframework.net/
MIT License
644 stars 70 forks source link

Why interface IRepository in Revo.Infrastructure ? #21

Closed RustamGulamov closed 3 years ago

RustamGulamov commented 3 years ago

Why interface IRepository in Revo.Infrastructure ? this is contrary to hexagonal or n-layered architecture. The Application layer should not depend from Infrastructure

martinzima commented 3 years ago

Hello RustamGulamov,

No, not really - in hexagonal architecture terms, IRepository would be just a port used in your application layer (i.e. in the command handler), not a layer of its own. I suggest reading up some articles on hexagonal or onion architecture with DDD, e.g.

https://herbertograca.com/2017/11/16/explicit-architecture-01-ddd-hexagonal-onion-clean-cqrs-how-i-put-it-all-together/

Best regards, Martin

RustamGulamov commented 3 years ago

Structure of my project: Airline.WebApi, Airline.Domain, Airline.Infrastructure. I want to create project Airline.Application for domainService/commandHandler. But Infrastructure is one level up then Airline.Application, right ?

Do I understand correctly, сommandHandler should be in Airline.WebApi ?

martinzima commented 3 years ago

I am not entirely sure what Airline.Infrastructure contains in your case, but I'd suggest a setup similar to this: