-
Notifications
You must be signed in to change notification settings - Fork 88
guide structure modern
With trends such as cloud, microservices, lean, and agile, we decided for a more modern project structure that fits better to recent market trends. When starting new projects with devonfw, and especially in the context of cloud-native development, we strongly recommend this modern approach over the classic structure.
Due to trends such as microservices, we are building smaller apps compared to moduliths. For simplicity, we therefore do not split our app into different modules and keep everything top-level and easy.
In addition to java
and resources
, we also add helm
for helm templates and docker
for docker scripts (e.g. Dockerfile
) in src/main
:
├──/src | ├──/main | | ├──/docker | | ├──/helm | | ├──/java | | └──/resources | └──/test | ├──/java | └──/resources └──/pom.xml
For modern projects, we strongly recommend that your build process generates the final deliverable as an OCI compliant container. Further, to go fully cloud-native, you should build your app as a native image via GraalVM AOT compiler. Therefore, we recommed to use quarkus as your main framework. In case you want to go with spring, you may consider using spring-native.
The package structure of your code inside src/main/java
(and src/test/java
) of your app is described in our coding conventions in the sections packages.
For the modern project structure, the layers are defined by the following table:
Layer | «layer» | Description |
---|---|---|
|
The service layer exposing functionality via its remote API. Typical protocol is REST. May also be any other protocol you are using such as gRPC. |
|
|
The data-access with the entities and DB access. Use sub-package (in |
|
|
The logic layer with the functionallity providing the business value. |
|
|
cross-cutting code not assigned to a technical layer. |
In order to help you to map the architecture, packaging, layering, etc. to the code and see where different code elements should be placed, we provide this architecture mapping:
«root» ├──.«component» | ├──.dataaccess | | ├──.repo | | | ├──.«BusinessObject»Repository | | | ├──.«BusinessObject»Fragment | | | └──.«BusinessObject»FragmentImpl | | ├──.dao [alternative to repo] | | | ├──.«BusinessObject»Dao | | | └──.«BusinessObject»DaoImpl | | └──.model | | └──.«BusinessObject»Entity | ├──.logic | | ├──«BusinessObject»Validator | | └──«BusinessObject»EventsEmitter | | └──.Uc«Operation»«BusinessObject»[Impl] | └──.rest | └──.v1 | ├──.«Component»RestService | ├──.mapper | | └──.«BusinessObject»Mapper | └──.model | └──.«BusinessObject»Dto └──.general └──.dataaccess └──.model └──.ApplicationPersistenceEntity
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).