Spring boot Project Structure

In this tutorial we will learn spring boot project structure. while developing any spring boot application we need to follow below structure. Spring boot project structure has divided into 5 types:

  1. ◈ Postman Client
  2. ◈ Controller
  3. ◈ Service Layer
  4. ◈ Model
  5. ◈ Repository
  6. ◈ DTO Layer
  7. ◈ Database

Controller: The controller is a protocol interface which exposes application functionality as RESTful web services.

Service Layer: The service layer contains your business logic. It defines which functionalities you provide, how they are accessed, and what to pass and get in return. The service layer will intract with repository to fetch, save, update and delete the data based on the functionality. The service layer works as a middleware between controller and repository, also data transformation will also apply in service layer.

Model: In spring boot models are table reprasentations in java plain object format.

Repository: The repository abstracts persistence operations: find (by id or other criteria), save (create, update) and delete records. It should do that and nothing more.

DTO Layer: DTO stands for data transformation object, in spring boot while transforming the data as per the standard we should not directly expose the model object to controller, hence DTO will be used to map the requied properties to send the data from model layer to controller.

Below image will talk about the spring boot project structure