Questions tagged [clean-architecture]

The Clean Architecture is a software architecture proposed by Robert C. Martin (better known as Uncle Bob). This architecture is similar to the Onion-Hexagonal-DCI-Architecture proposed by their respective authors. The base of this architecture is to follow and obey rules of the 'Dependency Rule'.

The Clean Architecture is proposed by Robert C. Martin, also known as Uncle Bob. This architecture is similar to the Onion, Hexagonal, Screaming, and DCI architectures. Though these architectures all vary somewhat in their details, they are very similar. They all have the same objective, which is the separation of concerns. They all achieve this separation by dividing the software into layers.

clean architecture diagram Robert C. Martin, The Clean Architecture, 2012

The foundation layers of The Clean Architecture are:

  • Entities (Enterprise Business Rules)
  • Use cases (Application Business Rules)
  • Interface Adapters
  • Frameworks and Drivers.

The rules are driven by The Dependency Rule, which states that:

...source code dependencies can only point inwards. Nothing in an inner circle can know anything at all about something in an outer circle. In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity.

Finally, when obeying this rule and using this architecture it is proposed that:

By separating the software into layers, and conforming to The Dependency Rule, you will create a system that is intrinsically testable, with all the benefits that implies.

1110 questions
7
votes
1 answer

Dagger in separate gradle module

I have 3 gradle modules in my 'clean architecture' Android application: 'data', 'domain' and 'presentation'. 'data' and 'presentation' both depend on 'domain', but not each other. 'presentation' holds Application class realization, and 'data' holds…
Alexey
  • 2,980
  • 4
  • 30
  • 53
7
votes
1 answer

Realizing Interactors with Android MVP Clean Architecture

I'm currently building an android application and wanted to base it on "clean architecture" similarly as suggested by the following authors: Fernando Cejas - Architecting Android…The clean way? Dario Miličić - A detailed guide on developing Android…
Cassio
  • 147
  • 1
  • 8
6
votes
2 answers

Service in clean architecture

Where does Service (or BroadcastReceiver, etc..) belongs to in clean architecture package structure? I am wondering between domain and data layer... I would create new package called services in domain package. Is that right, or I should do it other…
RitchyCZE
  • 44
  • 2
  • 13
6
votes
1 answer

Trouble when using ApplicationUser: IdentityUser, UserManager in clean architecture asp.net core

I am working a asp.net core 6.0 WebAPI in a clean Architecture.https://github.com/jasontaylordev/CleanArchitecture There are 4 projects in this architecture. WebApi, Infrastructure, Application and Domain. Domain is the Core. Application Layer is…
hanushi
  • 1,169
  • 2
  • 12
  • 27
6
votes
3 answers

Where in Hexagonal Architecture do periodic background tasks fit?

I am working on a program in golang, which I am sructuring based on Hexagonal Architecture. I think I have my head wrapped mostly around the idea, but there is something I just can't figure out. The function of the program is to monitor multiple IP…
6
votes
1 answer

converting entities into model in clean architecture in dart

As in clean architecture, we have to define the Entities in Domain layer and Models in Data layer. Now the issue that i am facing is in converting the entities into models when we are passing that as a request object in repositories. here is the…
Hunt
  • 8,215
  • 28
  • 116
  • 256
6
votes
2 answers

In a layered architecture, how can the Application layer know about Web URLs?

I'm currently working on a .NET 5 app that is using a layered architecture (Web / Application / Infrastructure / Domain). If I am to follow the onion/clean architecture pattern, the dependencies should flow in one direction only, e.g: Web ->…
leuquim
  • 636
  • 6
  • 16
6
votes
3 answers

Accessing and Using entities of other features in Clean Architecture

I've created feature packages for every part of my application and my project structure looks like this : app core features main domain data ui feature1 domain …
Ali Raghebi
  • 205
  • 2
  • 6
6
votes
1 answer

Clean architecture and user logins in Flutter - how do I store user information?

I've been trying to use Reso Coder's Flutter adaptation of Uncle Bob's Clean Architecture. My app connects to an API, and most requests (other than logging in) require an authentication token. Furthermore, upon logging in, user profile information…
hacker1024
  • 3,186
  • 1
  • 11
  • 31
6
votes
2 answers

In onion, hexagonal, or clean architecture, can a domain model contain different properties than the domain model in the database?

I am asking you who know well and have experience in building a software using any layered architecture (onion, hexagonal, clean, etc.). Whenever I google about the software architecture, people have different perspectives and explain the same…
6
votes
2 answers

Annotations in domain objects with JPA violates Database is a detail

What do you think about have persistence models and domain models separated? I've read that you don't have to mix persistence concerns with your business concerns (DDD, Clean Architecture,MartinFowler, Eric Evans and a lot and a lot of much more).…
6
votes
1 answer

Clean architecture : where should I put my exceptions?

First off, I present you the context. I am writing an api in C# and ASP.NET Core and I am trying to follow the clean architecture. In summary : I don't know where to put my exceptions. I have written a little scenario where I explain my…
P. Orlando
  • 93
  • 4
6
votes
4 answers

Flutter/Dart: Communication between features in Clean Architecure

I'm new to flutter/dart and I'm trying to create a little application using a Clean Architecture design. I read some blogs and several presentations of Uncle Bob's Clean Architecture before starting to code to get the most of it and now it's time…
6
votes
3 answers

What does Use Case and Interactor mean in the context of clean architecture?

What is Use Case and Interactor in context of Clean Architecture. I read that use case contains business logic, but why use case if there is a presentation layer where in presenter we can put business logic.
Android
  • 239
  • 1
  • 4
  • 12
6
votes
2 answers

Client libraries in Spring Boot microservices

Three years ago I was participating as a developer on my first microservices project. I didn't know anything about microservices conceptions. That project was building as Spring Boot microservices. In general nothing special but all projects applied…