Designing REST API architecture
The REST architecture consists of three layers. The architecture is shown in the picture below.
The web layer is the top layer in the architecture. It is responsible for processing user queries and returning back responses to the user. These operations happen in the controllers. The web layer handles exceptions which have appeared in the other layers. If the REST API is secured, the authentication process is handled in the web layer.
The service layer is located below the web layer. It applies additional business logic on client requests before passing the request to the next layer. The data provided from the Repository layer can also be transformed in the Service layer before passing it back to the user as a response. The design principle ‘Separation of concerns’ is achieved by placing business logic in the service layer. Thus the controllers located in the web layer remain clear of business logic.
The repository layer is the bottom layer in the architecture. It is responsible for communicating with the database. The CRUD (Create, Read, Update, Delete) operations are performed in the repository layer.
In the next article we will see a complete example of implementing the REST architecture in a real REST API.
Letzte Beiträge
Share :
Share :
Weitere Beiträge
6 Fragen an unseren Geschäftsführer Dimitar
Heute möchten wir euch Dimitar vorstellen, einen unserer zwei Geschäftsführer bei der DiSC. Er ist Spezialist für Mobile Netzwerke, Java Backend, Java Enterprise Edition sowie für Java Spring Boot
View Model. Example
In this article we will go through the steps of creating a simple game screen. We will make it the traditional way without using View Model and we will see why it is absolutely wrong to persist data in the View.
Dependency Injection with Spring 5
As we learned in the previous chapter dependency injection is a very powerful technique. DI is provided by the Spring 5 Framework implementation of the Inversion of Control (IoC) principle.