/spring-boot-clean-architecture-demo

An example of clean architecture implementation with Spring Boot

Primary LanguageJava

spring-boot-clean-architecture-demo

Build Status

An example of clean architecture with Spring Boot

Foreword

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 on use_cases or infrastructure packages.
  • use_cases is like a conductor. It will depend only on domain package to execute business logic. use_cases should not have any dependencies on infrastructure.
  • infrastructure contains all the technical details, configuration, implementations (database, web services, etc.), and must not contain any business logic. infrastructure has dependencies on domain, use_cases and frameworks.

Install

./gradlew assemble

Test

./gradlew check

Mutation testing

./gradlew pitest

Run

./gradlew bootRun