Jinwon Park

Spring layered architecture is simple and robust way to build a spring backend service.

There are three layers.

Presentation Layer <-> Business Layer <-> Persistence Layer 

Presentation Layer: It works as an intermediary between users and the backend. It handles HTTP request, translates JSON, and authenticates the request. It is usually called as controller.

Business Layer: It contains the business logic of the application. It handles authorization, and pretty much all the backend processes. It is usually called as service.

Persistence Layer: It contains the storage logic and translates business objects to Database. The term persistence is used because the data can persist outside of runtime. It is usually called as repository(JPA) or DAO/Mapper.

Spring provides as annotation: @Controller, @Service, @Repository.

Dividing layers prevents the codebase from getting chaotic as the complexity grows.