This project is a Java template for creating a Spring Boot application using the principles of Clean Architecture. This project also uses a pattern called CQRS. You can read more about that here.
I'm a big fan of the popular .NET template by Jason Taylor therefore this template takes a lot of inspiration from that template, and aims to provide a similar experience in Spring and Java. Although, primarily, I have created this as more of a learning exercise. Feel free to use this however you wish.
- Spring Boot
- Spring Security
- Spring Data
- Lombok and Hibernate Validator for validation
- ModelMapper
- PipelinR
- JUnit4, Java Snapshot Testing, Jackson
- NodeJS and PlopJS
- Integration Tests
- Refactor domain layer to remove dependencies
This project uses JUnit4, Spring Security Test and Java Snapshot Testing for unit tests. I've chosen to use Snapshot Testing here as I believe this is quite a clean approach for validating the output of commands and queries, which can often become complex in real-world applications.
As there is quite a bit of boilerplate required to create new commands or queries, this project ships with a small generator utility to quickly create the necessary files and test files.
To set up the generator, run the following (you will need NodeJS, I use nvm to manage this easily):
cd generator
npm install
You can run the generator by running the following command. You will be presented with an interactive generator which will aim to do its best to get you started with new commands, queries, and events.
npm run generate
This layer contains all entities, events, enums, interfaces and logic specific to the domain layer.
This layer contains all application logic and is dependent on the domain layer but has no dependencies on any other layers. This layer defines all the interfaces that are implemented in the infrastructure layer. For example, if you needed to add a new service, you would define the interface here and implement it in the interface layer.
This layer contains classes for accessing external resources such as databases, file services, web services, etc. These classes should implement the interfaces defined in the application layer.
This layer defines the entry point for the web service, which is a Spring Rest API. This layer handles configuring the Spring application and all the dependencies required, such as Spring Security, OpenAPI, Logging, etc. This layer depends on the application and infrastructure layers.
This project is licensed with the MIT license.