An example of clean architecture with Spring Boot
This application is designed using a Clean Architecture pattern (also known as Hexagonal Architecture). Therefore SOLID principles are used in code, especially the Dependency Inversion Principle (do not mix up with the classic dependency injection in Spring for example).
Concretely, there are 3 main packages: domain
, use_cases
and infrastructure
. These packages have to respect these rules:
domain
contains the business code and its logic, and has no outward dependency: nor on frameworks (Hibernate for example), nor onuse_cases
orinfrastructure
packages.use_cases
is like a conductor. It will depend only ondomain
package to execute business logic.use_cases
should not have any dependencies oninfrastructure
.infrastructure
contains all the technical details, configuration, implementations (database, web services, etc.), and must not contain any business logic.infrastructure
has dependencies ondomain
,use_cases
and frameworks.
./gradlew assemble
./gradlew check
./gradlew pitest
./gradlew bootRun