Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean Architecture diagram

Below is the classical Clean Architecture diagram from Uncle Bobs original blog post.

Clean Architecture

I am rather confused as to why the Gateways are more outwards than the Use Cases. This is something present in all such diagrams I have seen so far that include Gateways or some other form of Data Access mechanism.

I understand that Use Cases should not bind to the specifics of the Data Access mechanism, as these should be hidden behind an architectural boundary. At the same time the only users of the services that form this boundary should be the Use Cases. That clashes hard with the diagram, as following the visual rules, Use Cases cannot use the Gateways (while they need to) and frameworky-stuff can use them (while it should not).

Am I missing something? And if not, is there a more correct way to represent the rules of The Clean Architecture visually?

I'm asking because I am creating a diagram that shows The Clean Architecture + DDD Bounded Contexts.

enter image description here

I'm not happy with how the DB and services bits are outside of the UseCase circle as like that it is not clear the UseCases are the public interface of the Bounded Context and that the persistence is not directly accessible from the outside.

Something like this solves these two issues but introduces a new one: no indication of the data access layer boundary. In fact, following the visual rules, the diagram suggests that everything in the Bounded Context can directly access the persistence.

enter image description here

I believe I am running into the same problem that causes the Gateways to be "misplaced" in the original diagram and am looking for a way around that.

like image 686
Jeroen De Dauw Avatar asked Oct 19 '25 02:10

Jeroen De Dauw


1 Answers

The diagram shows where the implementations reside, not the interfaces. The gateway interfaces reside with the use cases.

like image 92
Robert Martin Avatar answered Oct 22 '25 04:10

Robert Martin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!