3 tiers architecture

In software engineering, multitier architecture (often referred to as n-tier architecture) or multilayered architecture is a client–server architecture in which presentation, application processing, and data management functions are physically separated. The most widespread use of multitier architecture is the three-tier architecture.

source

The main idea is to separate your application to 3 layers (tiers) i’ll describe the flow of a request to the server from the client, the purpose of the request is to add user to my database:

1) User has clicked on ADD button.

2) Client side send a POST request to the server with username and password on the body of the request as JSON format to www.example.com/users

3) Routing package getting the path (/users) and the request method (POST) and navigate it to the PL (presentation layer) function.

4) PL function getting the data from the request (username and password) and convert it to some struct and calling to the BLL (business login layer) function with the struct as a parameter.

5) BLL function gets the user struct and makes some validations (or any logic on the data) (e.g does user already exists ? does password length is more than 4 digits ? and so on…), if all the validation are valid, BLL calls to DAL (data access layer) function with the struct as a parameter.

6) DAL function insert the user to the database, DAL is the only layer that can aceess the database.

You should use this architecture because you have layer to every step you do with your data.
There is more reasons to use this architecture, you can read about it :slight_smile: