This archetype is used to create a maven project structure inpired by Uncle Bob's Clean architecture concept. The following diagram exposes an overview of this model:
When using this archetype with these parameters:
mvn archetype:generate -DarchetypeGroupId=ca.anynamus.archetype \
-DarchetypeArtifactId=modular-service-archetype \
-DgroupId=ca.anynamus.user \
-DartifactId=user
the following directory and project structure is genarated. For simplycity, the generated packages have been removed:
+---api
| \---src
| +---main
| | +---java
| | \---resources
| \---test
| +---java
| \---resources
+---core
| \---src
| +---main
| | +---java
| | \---resources
| \---test
| +---java
| \---resources
\---gateway
| \---gateway-api
| \---src
| +---main
| | +---java
| | \---resources
| \---test
| \---resources
+---driver
|
This hierarchy is expressed like this from a maven artifact point of view :
+---user-api
+---user-core
\---user-gateway
| \---user-gateway-api
+---user-driver
This module contains the interfaces for entities and use cases of the project.
This module implements the entities and use cases defined into the API module.
This module contains the interfaces exposing the functionalities to access the entities by the mean of repositories.
This project may contains one or more gateway-api implementations. As an example, the user gateway may have an in memory repository implementation for testing purpose and another JPA repository implementation for the production environment.
A driver module is mainly how the service functionnality will be exposed to the rest of the world.
The driver is a project of type pom
because it may host more than one type of driver. As an example, the core business logic may be exposed as as a web service as well as command line batch.
This project is a very good overview of the clean architecture's purpose. Note that this archetype's gateway concept is the equivalent of the dataprovider and that the driver concept is the equivalent of the entrypoints concept.
- The Clean Architecture https://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html
- Hexagonal Architecture http://alistair.cockburn.us/Hexagonal+architecture
- Robert C. Martin - Clean Architecture https://vimeo.com/43612849
- Clean Architecture: A Craftsman's Guide to Software Structure and Design, by Robert C. Martin