Questions tagged [clean-architecture]

Clean Architecture is a book by Robert C. Martin that contains solutions to architecting software solutions. Collectively these concepts are referred to as "Clean Architecture".

Filter by
Sorted by
Tagged with
-1 votes
1 answer
250 views

Do usecase-class work with domain-model or data-model at cleanarchitecture?

I interessted in the "usecases" and "how they interacts with the "context" at "clean architecture". If I understand right, there will be two contexts. First is the ...
Cit's user avatar
  • 21
0 votes
1 answer
609 views

Clean Architecture : Application State

Given the following design from clean architecture in which layer would you put overall application state? In each state a subset of use cases are allowed to be invoked. For example if application is ...
hamid's user avatar
  • 9
1 vote
2 answers
1k views

Help implementing call to external API and store summary in my database in hexagonal architecture with DDD

Good afternoon. My situation is this: I have to call an external API to create some data and store it there, but I want to have a summary of that data in my own database. I have my use case that ...
TheEmpire12's user avatar
0 votes
2 answers
229 views

How to design software architecture without solid requirements?

I am working on a project which does not have solid requirements, All is we have meetings with all the teams across and confluence pages. No one owns any requirements and it just float around ...
uss's user avatar
  • 141
2 votes
0 answers
500 views

On which layer of Clean Architecture hierarchy must be the entities with application-specific properties?

From the answer to Must the use cases extend the entities in Clean Architecture? I have known that the use cases must NOT extend the entities. It's fine, but what do I have to do with the properties ...
Takesi Tokugawa YD's user avatar
0 votes
0 answers
331 views

How to implement repository in clean architecture

I need to rewrite my project due to many underlying issues causing errors and I started following clean architecture by Uncle Bob (I read the book). I created my domain, infrastructure, application ...
z0mbieKale's user avatar
1 vote
2 answers
303 views

Where to save entity metadata in a Ports-And-Adapters Architecture

I’m using a hexagonal/clean/ports-and-adapter architecture. For the sake of simplicity, I’ll only talk about domain and infrastructure here, where the infrastructure has dependencies on the domain but ...
Mirco's user avatar
  • 651
1 vote
1 answer
1k views

Must the use cases extend the entities in Clean Architecture?

Currently I don't understand the Use case concept enough good - too much abstract definitions but no particular examples. The section Use Cases of Chapter 20 Business Rules does not including any code ...
Takesi Tokugawa YD's user avatar
0 votes
3 answers
864 views

Which Clean Architecture Areas do Gateways interfaces and their implementations belong to?

Talking about gateways from the Clean Architecture, it is required to distinguish: The interfaces The implementation of these interfaces The TypeScript example: // === Interface =====================...
Takesi Tokugawa YD's user avatar
0 votes
2 answers
361 views

Making a Data Layer that is tightly coupled to the Presentation Layer in Clean Architecture

So I've got a simple object recognition app in iOS. I am trying to create an Interface-Adapter for the machine learning / computer vision like this: protocol MachineLearningInterface { func ...
Bawenang Rukmoko Pardian Putra's user avatar
-2 votes
1 answer
250 views

Is it OK to use a Command Sourcing instead of Event Sourcing? Replay events in Commands-Repositories

I have a system that uses a graph database without any ORM, mapper or tool that tracks entity changes, like EntityFramework. I'm not using domain entities, instead I have an Event that calls changes ...
Augusto Will's user avatar
0 votes
2 answers
1k views

Is it okay for an Interface Adapter / Repository / Gateway to use Entities in its implementation

I've got these classes: enum Environment { case staging case production static func current() -> Environment { #if STAGING return .staging #elseif PROD ...
Bawenang Rukmoko Pardian Putra's user avatar
3 votes
1 answer
96 views

High level abstraction of file scanning service in domain driven design, and the implementations

My domain requires that a Resource (ubiquitous language for a singular unit of data to be moved - commonly a file or folder) can only be moved if it has been Scanned to ensure it does not contain any ...
Patrick Christie's user avatar
1 vote
0 answers
182 views

Business rule or repository implementation rule in Clean Architecture

I'm studying Clean Architecture with python and got into this "problem" of choosing where to implement a rule (that I considered a Business Rule, maybe I'm wrong) I have 2 Entities @...
Rodrigo Maller Martins's user avatar
1 vote
6 answers
2k views

TDD: testing an abstract class. Test all concrete classes or create mock sub-class to test the behavior?

Well, I'm developing a personal project using TDD and Clean Architecture, and I chose to build an abstract class to gather all use-cases behavior in one single class. My question is: What you think ...
Gabriel Antonio's user avatar
0 votes
1 answer
580 views

Clean Architecture for React App: Component / View / Page

Abstract I'm trying to figure out a solid, scalable, clean and practical architecture for react projects. As a a playground I have a project with two Screen and a JSON server. When I try to apply a ...
DarkTrick's user avatar
  • 207
0 votes
0 answers
50 views

How big should database adapters/gateways be?

Outline When you build an Adapter that connects your application and the database, How big should you make this adapter? Should it contain all possible queries that could be made to the DB? Do you ...
DarkTrick's user avatar
  • 207
0 votes
1 answer
395 views

What should I write before the tests in Clean Architecture with TDD?

Well, we all know the main concept of TDD: write a failing test, then implement the testing component to make your test pass. I've been working on a personal project in Clean Architecture following ...
Gabriel Antonio's user avatar
5 votes
1 answer
1k views

Use Cases in Clean Architecture, in Requirements Specifications from Software Engineering and Use Case Diagrams in UML

Well, I've been studying software architecture a lot, Clean Architecture in specific and I came across some multi meanings terms and "Use Case" is one of them. I'd read in some places that ...
Gabriel Antonio's user avatar
4 votes
1 answer
200 views

Reduce changes needed after adding a new field to domain object

I'm developing an application with DDD pattern with three layers: API Domain DB After adding a new field to the domain object, I realized that many places need to change. Imagine the following model....
Glyphack's user avatar
  • 151
0 votes
0 answers
608 views

DDD: Where to put business logic with conditionals etc., is it a domain service?

I would think the answer to my question is yes, but I have never really seen it in practice or any OSS project (and links to any OSS sample projects are highly welcome because the typical examples ...
IceFire's user avatar
  • 119
0 votes
1 answer
680 views

Clean Architecture: How to decouple the Repository from a CommandHandler?

We are just starting with event driven (and clean) architecture. So far we have two main entrypoints, a consumer (reader from a Redis Stream / Kafka Topic), and an API. As this is almost a modular ...
lowercase00's user avatar
3 votes
2 answers
484 views

What is the alternative to checked exceptions in API/interface design?

Despite checked exceptions being generally bad practice and anti-pattern, I find one feature very useful: having list of checked exceptions part of function signature. Checked exceptions are "...
SadClown's user avatar
  • 139
2 votes
2 answers
2k views

Should similar use cases be splitted or combined in clean architecture?

In Clean architecture Suppose I have two actions (approve/deny) a request. Should I create a use case for approve and another for deny? or both in one use case (RespondToRequestUseCase) and I ...
Mohammad Alotol's user avatar
2 votes
1 answer
1k views

How to integrate Androidx Paging-3 in Clean Architecture?

This blog on "Clean Architecture" describes how to build a modular Android application along with using Clean Architecture. In that example project, the author places the business logic in a ...
Sourav Kannantha B's user avatar
0 votes
1 answer
611 views

How to conform two repositories that work on the same entity but have different methods?

I have to implement 2 use cases, the first one is going to create a Company profile from its document number, so inside the use case, it reaches out to the third party API that contains information ...
Thiago Dias's user avatar
1 vote
1 answer
348 views

Is the use of a catch block as a "rollback mechanism" a bad thing?

I have a service that performs a series of actions based on user information (name, address, etc), one of the problems is that the User entity comes from a legacy third party API (as a repository) ...
Thiago Dias's user avatar
0 votes
1 answer
166 views

Verbs in Use Case name "Create User" [closed]

I'm struggling on how to name classes for use cases. Because I know that is "bad" to use verbs in classes names(Uncle Bob) but at the same time names of use case classes should explain what ...
Carlos Figueroa's user avatar
0 votes
3 answers
1k views

How should you start applying TDD in a clean architecture?

I'll be using Uncle Bob's terms, so i'll call the use cases "interactors" and the domain entities "entities". As far as I understand, the most specific business rules that are most ...
Jordi Pagès's user avatar
6 votes
2 answers
2k views

Alternatives to outbox pattern, does outbox pattern break clean-architecture?

I've read and tried the Transactional Outbox pattern for communicating between services. It is clear to me what are the benefits of this pattern, as it has two main parts: By using a transaction, we ...
oren's user avatar
  • 287
0 votes
0 answers
270 views

microservice custom error messages

We use microservices and spring boot in our saas (multi tenant) projects. We will proceed through the schema per tenant. We manage the error messages we show to the users through a database. We are ...
Burak Yilmaz's user avatar
1 vote
0 answers
159 views

Could output port consist of multiple methods? (Clean Architecture)

The use case output port is called by the Interactor returning the response model, and the output port could be called many times with different responses. Question: Could the output port has multiple ...
Mohammad Alotol's user avatar
8 votes
2 answers
13k views

To which Clean Architecture layer should repositories implementations belong?

It's very common to see this use of repository in projects using clean architecture: interface Hero { } interface HeroRepository { findById(id: number): Hero; } class FetchHeroUseCase { ...
Vitor Figueredo Marques's user avatar
2 votes
4 answers
705 views

Can the presenter talk to to the controller?

in the clear architecture, what uncle bob suggested. I have a lot of questions about how to correctly distribute the responsibility. it seems that there is no relationship between controller and ...
rahul  Kushwaha's user avatar
2 votes
2 answers
223 views

Replacing service implementation based on environment variables

I have previously asked a question on this forum linked here. In short, I wanted to not call 3rd party APIs when developing locally. Based on the wonderful answers received I have opted for the ...
dendog's user avatar
  • 201
1 vote
3 answers
5k views

Mapping to and from domain entities

I am in the process of implementing onion / clean architecture, and would like to understand better how and when to map to my domain entities. So if we take a specific example where we have a Post and ...
dendog's user avatar
  • 201
1 vote
1 answer
1k views

Who should validate the request data, controller or useCase?

I use the controller to extract data from a request and Use Cases/Interactors to validate the data. But can I use the controller to extract and validate the request data?
ellandor's user avatar
0 votes
2 answers
842 views

Sharing logic / services across modules in "clean" architecture [closed]

I am trying to implement a layered architecture consisting of; Controller, Service, Repository, Entity. Each module has at least some of the above layers. I am often finding that modules need to share ...
dendog's user avatar
  • 201
1 vote
1 answer
954 views

How to use external validation libraries for entities in a "clean" architecture?

I would like to make use of a external library to parse the core domain entities. Doing this in a naive way it would look like the following: import { z } from 'zod'; const Audience = z.object({ ...
dendog's user avatar
  • 201
0 votes
1 answer
2k views

Where should interfaces/model definitions live? -- Clean architecture

I'm working on a Node project (in typescript) that features a variation of clean architecture. I have a pretty clear understanding of the different layers of an application and how they depend on each ...
GHOST-34's user avatar
  • 111
1 vote
1 answer
609 views

Where Refit interfaces fit in a Clean Architecture structure

I want to start using Refit, it is a great library, but I'm having some hard time to keep the project structure clean because the library is at the same time the abstraction(interface) and the ...
ddieppa's user avatar
  • 111
0 votes
1 answer
344 views

Implement Dependency Inversion in C with UML diagram

As per Robert C. Martin in Clean Architecture, he gives a simple UML diagram to illustrate Dependency Inversion. To put it simply, HL1 initially referred to ML1 without interface to invoke F() ...
Andy Lin's user avatar
  • 185
1 vote
1 answer
242 views

Avoiding coupling through code sharing

I have been working on an application which consists of several cohesive services, Customer, Invoice, PurchaseOrder, Highlight, the application is deployed within a mono repo and each service is ...
berimbolo's user avatar
  • 113
2 votes
1 answer
218 views

How to deal with master data in a microservice environment

Hey Software Engineers Currently we basically have a what I would call "modular monolith". A diagram would likely look something like this: What we want to do in the future is being able to ...
xeraphim's user avatar
  • 339
-3 votes
1 answer
233 views

Whats the purpose of use-case and data-sources?

I have a question about where should I get the info required for making an api call. Let's say I have this : Presenter --> Use Case --> DataSource --> Api Ok now to do my api call, I need a ...
StuartDTO's user avatar
  • 103
1 vote
1 answer
2k views

Clean Architecture how does domain layer communicate with the Infrastructure layer?

I'm trying to get a grasp of the Clean Architecture. In the examples I found the typical solution structure consists of three projects: Core, Infrastructure, and Presentation/UI. The Core project must ...
blablaalb's user avatar
1 vote
5 answers
1k views

Clean architecture, Login UseCase with OAuth breaking Single responsability principle

I'm building a login system using OAuth to integrate with various social networks. The flow is very simple, first, the user is redirected to their social network to grant permission to read the ...
Thiago Dias's user avatar
6 votes
9 answers
2k views

Java instanceof and Clean architecture

It seems to me that there is a conflict between clean architecture and the recommendation not to use instanceof. Consider the following code: class ParentEntity { } class AEntity extends ParentEntity ...
Shayan's user avatar
  • 199
1 vote
2 answers
436 views

How can I manage dependency injection in test code?

This question is a follow-up question to Clean Architecture use case testing. Suppose the production code injects Use Case Interactor into the Input Boundary - that happens somewhere in the main ...
Brady Dean's user avatar
0 votes
1 answer
115 views

Should I define a separate interface for clarity rather than implementing Supplier<T>?

Let's say you have to meet some prerequisites before doing something. For that, I think implementing Supplier<Boolean> is a great candidate since it's widely used, and quick to understand. But, ...
eca2ed291a2f572f66f4a5fcf57511's user avatar