DDD architecture implementation using Spring Boot (Spring Security, Spring Data, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully-fledged application built with Spring including CRUD operations, authentication, routing, pagination, and more.
For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
This application uses Spring Boot with Java 11. The implementation is meant to demonstrate idiomatic usage of Spring Framework and other modern Java technologies.
The app is created using API-first approach. I.e. a swagger file (see the api
directory) is used
to generate a skeleton of the REST API together with models (DTO) used for json representation.
In pom.xml
you can see the usage of openapi-generator-maven-plugin plugin which performs actual code generation.
The app itself implements generated interfaces using DDD philosophy. See the structure below.
application/ -> API of the app, encapsulates the domain
+-- service/ -> implementation of generated interfaces
+-- exception -> application exceptions
+-- util -> some helper classes including DTO mapping layer
domain/ -> core business implementation layer
+-- aggregate/ -> aggregates are cluster of domain entities
+-- service/ -> doamin services that operate with domain entities
infrastructure/ -> technical details layer
+-- config/ -> dependency injection configuration
+-- security/ -> security configuration
- Checker framework prevents null-pointer exceptions
- Static code analysis with Checkstyle, PMD and Spotbugs (see configs)
- Automatic code formatting with fmt-maven-plugin
- Checkstyle is configured to check for adherence to Google Style
make run
The server should be running at http://localhost:8080
make postman-test
make
- There is no command and query segregation, as the result, we can see a lot of JPA hacking
- JEP 359 aka Java records is still a preview, but it could simplify the codebase
openapi-generator-maven-plugin
is not a perfect generator - it uses some old spring dependencies- Test coverage can be improved