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
0 votes
1 answer
52 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 ...
0 votes
2 answers
59 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 =====================...
0 votes
0 answers
45 views

Clean architecture - modelling the domain

I'm working on a project that deals with form designs (online questionnaires), exported as JSON from the customer's system. The goal is to produce simplified outlines of each design for the customer's ...
0 votes
0 answers
29 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 ...
-2 votes
1 answer
65 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 ...
0 votes
2 answers
69 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 ...
-3 votes
2 answers
78 views

Coding style for a micro-service across organisation [closed]

Background/Context: A big organisation has several departments, those departments have several business units and those business units are divided into domain teams. Assuming domain teams are atomic ...
3 votes
1 answer
75 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 ...
0 votes
0 answers
26 views

Android clean architecture - RemoteMediator with multiple api dependencies and data sources

From the docs, a RemoteMediator used for pagination can have dependency on: Api Service Database Consider the case when you are paginating a list of items, say a list of books for which you have a ...
1 vote
0 answers
62 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 @...
1 vote
6 answers
260 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 ...
0 votes
1 answer
85 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 ...
  • 109
0 votes
0 answers
45 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 ...
  • 109
0 votes
1 answer
147 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 ...
3 votes
1 answer
149 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 ...
3 votes
1 answer
152 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....
  • 141
0 votes
0 answers
202 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 ...
  • 119
0 votes
1 answer
234 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 ...
3 votes
2 answers
184 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 "...
  • 139
1 vote
2 answers
295 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 ...
1 vote
1 answer
353 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 ...
0 votes
1 answer
151 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 ...
1 vote
1 answer
283 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) ...
0 votes
1 answer
85 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 ...
0 votes
3 answers
362 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 ...
3 votes
2 answers
531 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 ...
  • 227
0 votes
0 answers
102 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 ...
1 vote
0 answers
89 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 ...
2 votes
2 answers
3k 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 { ...
2 votes
4 answers
226 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 ...
2 votes
2 answers
94 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 ...
  • 161
0 votes
3 answers
1k 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 ...
  • 161
1 vote
1 answer
331 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?
0 votes
2 answers
292 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 ...
  • 161
-1 votes
1 answer
267 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({ ...
  • 161
0 votes
1 answer
599 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 ...
  • 111
0 votes
0 answers
200 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 ...
  • 101
0 votes
1 answer
134 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() ...
  • 185
1 vote
1 answer
190 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 ...
  • 113
0 votes
0 answers
30 views

"Bind" one domain to another while still following the rules of Clean Architecture?

I am creating a house planning app as a little test project so I get a better understanding for Clean Architecture. I am using more or less this template: https://github.com/jasontaylordev/...
2 votes
1 answer
96 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 ...
  • 329
0 votes
0 answers
74 views

Can/Should Refit (API) Contracts be the same of MediatR (CQRS) Commands?

I'm creating a microservice using Clean Architecture principles. The following picture shows the project structure: On the Application layer, I am using MediatR (using CQRS), where I have the ...
-3 votes
1 answer
118 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 ...
  • 103
1 vote
1 answer
897 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 ...
1 vote
5 answers
728 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 ...
6 votes
8 answers
973 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 ...
  • 199
1 vote
2 answers
292 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 ...
0 votes
1 answer
103 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, ...
  • 101
2 votes
0 answers
376 views

Clean Architecture, what are objects that does not completely fit as entities?

I'm reading chapter 20, "Business Rules", of clean architecture book, in this chapter Uncle Bob defines entities as: An Entity is an object within our computer system that embodies a small ...
0 votes
2 answers
134 views

May the left-side know the right-side when using CQRS with Hexagonal?

I'm trying to use the hexagonal architecture but I want the flexibility to make CUSTOM queries right to the database (or cache) to populate DTOs right from the left-side without passing through the ...
  • 109