In Clean Architecture, which layer receives the business rules and logic specific to a system?

Asked

Viewed 78 times

0

Speaking of Clean Architecture, we usually see examples of a basic CRUD system, but that do not show where are located the codes of controllers that need a complexity a little more than simply a CRUD.

For example:

A controller should register a user but, first, it needs to see if the user already exists, check if the password entered is in accordance with the security rules, among other things that could be cited in this example.

I believe that the answer is that this logic is in the layer "Application" however, more specifically where? Would it be within the Service classes? The same that contains the standard CRUD methods (add, remove, update, List, etc.) ? Or it would be creating a new Service for this type of logic?

1 answer

1


Good morning, Not really, The layer where are the rules of Business,is the layer called entity, in your project it will be the models that you will make to insert into the database. For example it is the file where vc defines which data will have in the tables and how they will relate.

After it comes the layer called Use-cases,.

The most external layer are the Controllers,These yes, that will communicate with The entity,making essential operations of CRUD,.

In your project, it would be the endpoints that you model, and the REST requests that you make.

And finally, there’s the UI, which is the user interface,.

In this layer TBM is the DB that will communicate with the Repositorio.

clean-architeture

  • here is an image of the book Architecture Clean https://www.google.com/url?sa=i&url=https%3A%2F%2Fimasters.com.br%2Fback-end%2Fintroducao-clean-architecture&psig=Aovvaw1mnsqs7v_jtuhzpm0rhped&Ust=1613584134866000&source=images&cd=vfe&ved=0CAAAAAAAAAAAABAD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.