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.