Open In App

Spring Boot - Architecture

Last Updated : 07 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Spring Boot is built on top of the core Spring framework. It simplifies and automates Spring-based application development by reducing the need for manual configuration. Spring Boot follows a layered architecture, where each layer interacts with other layers in a hierarchical order. The official Spring Boot documentation defines it as:

"Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications with minimal configuration."

The main goal of Spring Boot is to eliminate XML and annotation-based configuration complexities. It provides several benefits, including opinionated defaults, convention over configuration, stand-alone applications, and production readiness.

Spring Boot Layers

Spring Boot consists of the following four layers:

  1. Presentation Layer: Handles HTTP requests, authentication, and JSON conversion.
  2. Business Layer: Contains business logic, validation, and authorization.
  3. Persistence Layer: Manages database interactions using ORM frameworks like Spring Data JPA.
  4. Database Layer: Stores application data using relational (MySQL, PostgreSQL) and NoSQL databases (MongoDB, DynamoDB).
Layers-Of-Spring-Boot


1. Presentation Layer

The Presentation Layer is the topmost layer of the Spring Boot architecture. It primarily consists of REST controllers that handle HTTP requests (GET, POST, PUT, DELETE). It performs authentication, request validation, and JSON serialization/deserialization (conversion of JSON to Java objects and vice versa). After processing the request, it forwards the request to the business layer.

2. Business Layer

The Business Layer is responsible for implementing the application's core logic. It consists of service classes that:

  • Process and validate data.
  • Handle authentication and authorization (integrating Spring Security if needed).
  • Apply transaction management using @Transactional.
  • Interact with the Persistence Layer to store or retrieve data.

3. Persistence Layer

The Persistence Layer manages database transactions and storage logic. It consists of repository classes using Spring Data JPA, Hibernate, or R2DBC for data access. It is responsible for:

  • Mapping Java objects to database records using ORM frameworks.
  • Managing CRUD (Create, Read, Update, Delete) operations.
  • Supporting relational and NoSQL databases.

4. Database Layer

The Database Layer contains the actual database where the application data is stored. It can support:

  • Relational Databases (MySQL, PostgreSQL, Oracle, SQL Server).
  • NoSQL Databases (MongoDB, Cassandra, DynamoDB, Firebase).
  • Cloud-based databases for scalability.

Spring Boot Flow Architecture

Spring-Boot-Flow-Architecture


Explanation:

  • The client (frontend or API consumer) sends an HTTP request (GET, POST, PUT, DELETE) to the application.
  • The request is handled by the Controller Layer, which maps the request to a specific handler method.
  • The Service Layer processes business logic and communicates with the Persistence Layer to fetch or modify data.
  • The Persistence Layer interacts with the Database Layer using Spring Data JPA or R2DBC, often through a Repository Class that extends CRUD services.
  • The processed response is returned as JSON.
  • Spring Boot Actuator can be used for monitoring and health checks.

Next Article

Similar Reads