Skip to content

An analysis of a clean architecture implementation in a spring boot application.

Notifications You must be signed in to change notification settings

vinimrs/spring-boot-clean-architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Architecture with Spring Boot

An analysis of a clean architecture implementation in a spring boot application. Checking the results of the merge of this two architectures. Comparing the code metrics of Spring Boot classical architecture and the result of the clean architecture applied to it.

The target application

Project to implement a web application of a system for online bike rentals using the technologies Java Spring Boot for the development of a API REST, in order to contemplate the main responsibilities of a bicycle rental exploring and knowing better how the development of web systems works.

Collection of requests for the API - Postman

Features

This system was based on the requirements document proposed by the professor during the course.

  • Feature 1 Users management: The system allows a super user (administrator) to manage (CRUD) all users of the system, such as rental companies and customers.
  • Feature 2 Bikes rental: The system allows customers to rent bicycles at a certain date from rentesCompanies available in the system.
  • Feature 3 Browsing without login: The system provides interfaces for non-logged in users to be able to use the system without a registration.
  • And more....

Technologies

Common Spring Boot Architecture

The common architecture is an simple one, based on layers that communicate with a certain hierarchy between them, as can be seen below.

Common spring boot architecture

The central idea is that it will have well-defined layers with vertical boundaries. But this idea is not being followed properly. In reality, some cyclic dependencies occur between layers, because many responsibilities are not well separated, making the code more coupled.

Layers depend on others in a partial hierarchy and all layers depend on the structure code. And this can be negative for a few reasons:

  1. The main rules of the domain are mixed with the details of the framework;
  2. The code complexity of domain rules increases;
  3. Changes to the structure directly affect the application code.

The application implemented is the [common project].

Simplified Spring Boot Architecture with Clean Architecture

Trying to improve code organization, the clean architecture is a good start with that rules. We can arrive in an well-defined vertial boundaries, with a rigid hierarchy between the layers, the rules of the domain code is encapsulated of the framework code, and basically the code of the inner layers.

Spring boot architecture with clean arhcitecture

The resulting architecture proposed for the application of Clean Architecture will contain 3 layers, they are: Infraestructure, Use case and Entity. In which follows a rigid hierarchy between the layers - the codes of the innermost layers do not know those of the outermost.

This architecture implemented is in the [simplified project].

About

An analysis of a clean architecture implementation in a spring boot application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages