amantinband / clean-architecture

The ultimate clean architecture template for .NET applications 💪
MIT License
1.4k stars 221 forks source link

Question: Api project no longer needs to have a reference to Application project because .... #24

Closed suugbut closed 6 months ago

suugbut commented 6 months ago

Sir, I think Api project should not have a reference to Application project because Api already has a reference to Infrastructure project that has a reference to Application project.

https://github.com/amantinband/clean-architecture/blob/09605637026f5e05375969b4fedb6c797dabe736/src/CleanArchitecture.Api/CleanArchitecture.Api.csproj#L19

image

Thijs153 commented 6 months ago

Hello @suugbut,

Please correct me if I'm mistaken, but according to the Clean Architecture principles, the presentation layer should only reference the application layer. The API project references the infrastructure layer as well, but solely for Dependency Injection purposes.

suugbut commented 6 months ago

Hello @suugbut,

Please correct me if I'm mistaken, but according to the Clean Architecture principles, the presentation layer should only reference the application layer. The API project references the infrastructure layer as well, but solely for Dependency Injection purposes.

Yes. It is correct but because Api already references Infrastructure that references Application then transitively Api references Application.

amantinband commented 6 months ago

Hey @suugbut, as @Thijs153 wrote above - the presentation layer theoretically should not reference the Infrastructure layer. The only reason why it is referenced is for wiring together the interfaces from the application and domain layers to their implementations in the infra layer.

This is why the presentation layer references both the infra and the application layers even though it could reference only the Infrastructure layer as you said.