This repository provides an example of implementing Clean Architecture using Spring Boot.
- Spring Boot
- Spring Data JPA
- H2 Database
The project is structured following a modular approach with a layered architecture, adhering to the principles of Clean Architecture:
src/
├── main/
│ ├── java/com/mycompany/my-application/
│ │ ├── modules/
│ │ │ ├── my-module/
│ │ │ │ ├── application/
│ │ │ │ │ ├── dtos/
│ │ │ │ │ ├── mappers/
│ │ │ │ │ └── usecases/
│ │ │ │ ├── domain/
│ │ │ │ │ ├── entities/
│ │ │ │ │ ├── enums/
│ │ │ │ │ ├── repositories/
│ │ │ │ │ └── usecases/
│ │ │ │ ├── infrastructure/
│ │ │ │ │ ├── repositories/
│ │ │ │ │ └── config/
│ │ │ │ ├── web/
│ │ │ │ │ └── controllers/
│ │ ├── shared/
│ │ │ ├── ...
│ └── resources/
│ └── application.properties
├── test/
│ ├── java/com/mycompany/my-application/
└── ...
- Modules: Each module encapsulates a specific part of the application's domain, such as a
TaskModule
, containing domain entities, repositories, and use cases. - Domain: Contains core business logic, including entities, enums, repositories, and services.
- Infrastructure: Handles database operations and configurations, encapsulating persistence logic.
- Application: Contains DTOs, mappers, and use cases that represent the application's business logic.
- Web: Exposes the application to the outside world through controllers.
- Java (version 17 or higher)
- Maven
-
Clone this repository:
git clone https://github.com/jheisonnovak/clean-architecture-spring.git cd clean-architecture-spring
-
Build the project:
On Linux/macOS:
./mvnw clean install
On Windows:
mvnw.cmd clean install
-
Run the application:
On Linux/macOS:
./mvnw spring-boot:run
On Windows:
mvnw.cmd spring-boot:run
-
Access the application:
Open your browser and navigate to http://localhost:4000/swagger-ui.html to explore the API documentation using Swagger UI.
For more information on the concepts and practices used in this repository:
- Spring Boot Documentation
- Spring Data JPA Documentation
- Clean Code: A Handbook of Agile Software Craftsmanship - Robert C. Martin
Feel free to submit issues or pull requests. Contributions are welcome!