All Projects → aantoniadis → clean-architecture-example

aantoniadis / clean-architecture-example

Licence: other
A simple clean architecture example in Kotlin and Spring Boot 2.0

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to clean-architecture-example

ecommerce-microservices-spring-reactive-webflux
E-commerce demo with spring reactive webflux and spring cloud microservice
Stars: ✭ 107 (+69.84%)
Mutual labels:  maven
Keyist-Ecommerce
🔑 A simple ecommerce site powered with Spring Boot + Angular 10 + Ngrx + OAuth2
Stars: ✭ 220 (+249.21%)
Mutual labels:  maven
headless-chrome
Implementation of the new headless chrome with chromedriver and selenium.
Stars: ✭ 34 (-46.03%)
Mutual labels:  maven
iOS-Clean-Architecture-Example
An iOS app designed using clean architecture and MVVM.
Stars: ✭ 50 (-20.63%)
Mutual labels:  clean-architecture
cyclonedx-maven-plugin
Creates CycloneDX Software Bill of Materials (SBOM) from Maven projects
Stars: ✭ 103 (+63.49%)
Mutual labels:  maven
textdigester
TextDigester: document summarization java library
Stars: ✭ 23 (-63.49%)
Mutual labels:  maven
pipeline-maven-plugin
Pipeline Maven Plugin
Stars: ✭ 50 (-20.63%)
Mutual labels:  maven
DropBeat
A Music Player with downloading, playing, searching, exploring functions.
Stars: ✭ 13 (-79.37%)
Mutual labels:  clean-architecture
workable-converter
基于libreoffice实现的文档转换项目,无框架依赖,即插即用
Stars: ✭ 74 (+17.46%)
Mutual labels:  maven
Compose-BreakingBad
🧪 ☠︎ Jetpack Compose - Breaking Bad ☢︎
Stars: ✭ 26 (-58.73%)
Mutual labels:  clean-architecture
WorldGuardWrapper
A wrapper for the WorldGuard API that allows plugins to support both v6 and v7 APIs.
Stars: ✭ 21 (-66.67%)
Mutual labels:  maven
maloss
Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages
Stars: ✭ 46 (-26.98%)
Mutual labels:  maven
metadatamanagement
Metadatamanagement (MDM) - Data Search for Higher Education Research and Science Studies
Stars: ✭ 21 (-66.67%)
Mutual labels:  maven
dockercompose-springboot-mongodb-nginx
Docker Compose with Spring Boot, MongoDB and NGINX
Stars: ✭ 27 (-57.14%)
Mutual labels:  maven
maven-wrapper-plugin
Apache Maven Wrapper Plugin
Stars: ✭ 14 (-77.78%)
Mutual labels:  maven
MovieRatings
Android app to show movie ratings when browsing Netflix, Amazon Prime Video and other supported video streaming apps on the phone
Stars: ✭ 71 (+12.7%)
Mutual labels:  clean-architecture
maven-settings-action
This action setup maven settings.xml
Stars: ✭ 39 (-38.1%)
Mutual labels:  maven
archunit-junit5-kotlin
Generic Architecture Tests written in Kotlin using ArchUnit and Junit5
Stars: ✭ 22 (-65.08%)
Mutual labels:  clean-architecture
vim-maven-plugin
The Maven plugin for VIM
Stars: ✭ 52 (-17.46%)
Mutual labels:  maven
whats-new-in-java
Overview of features that were introduced in Java 8-13.
Stars: ✭ 29 (-53.97%)
Mutual labels:  maven

Build Status

Compile and run the app

./mvnw install && ./mvnw spring-boot:run -pl delivery

or

./mvnw install && java -jar delivery/target/delivery-1.0.0-SNAPSHOT.jar

Description of the architecture

The project consists of 4 modules core, usecases, dataproviders, and delivery.

core module

This module contains the domain entities. There are no dependencies to frameworks and/or libraries.

usecases module

This module contains the business rules that are essential for our application (Application business rules). The only dependency of this module is to core. In this module, gateways for the repositories are being defined. Each use case defines the interface of the gateway that is required following the ISP. These gateways, operate on the domain entities defined in core.

In this module, UseCase and UseCaseExecutor are also defined. The UseCase is an interface similar to the java.util.Function. It just gets a request and returns a response.

The UseCaseExecutor handles the execution of a UseCase. To do so, it has an invoke method that takes the following arguments:

  1. the use case that is to be executed
  2. the RequestDto
  3. a function that converts the RequestDto to a Request object (the input of the use case)
  4. a function that converts the Response object (the output of the use case) of the use case execution to a ResponseDto

There are 3 more overloaded versions of the invoke method, which omit the input and/or the output of the UseCaseExecutor.

Currently, the UseCaseExecutor implementation (UseCaseExecutorImp) is using java.util.concurrent.CompletableFuture and java.util.concurrent.CompletionStage for the execution abstraction. These abstractions are convenient as they can perform asynchronous executions and also have out of the box compatibility with most frameworks.

dataproviders module

This module contains the implementation of the gateways defined in the usecases module. This module depends on the framework that facilitates the data access. In our example, we use JPA and Spring Data. The Jpa*Repository classes are the actual implementation of the gateways defined in the usecases module.

These repositories, use the Spring Data JpaRepository as dependencies. For more, check JpaProductRepository.kt. The entities in this module, are JPA entities, so mappings to and from these and the domain entities are needed. Check ProductEntity.kt for more.

delivery module

This module contains all the details of the delivery mechanism that we use along with the wiring of the app and the configurations. In our example, we use rest services built with Spring Boot. Similarly, to the JPA entities of the dataproviders module, the DTOs have mappers, to convert from and to the domain entities.

A rest controller gets the RequestDto, and forwards it to the related use case through the UseCaseExecutor. The response of the use case (which is a ResponseDto) is the response of the controller's method that implements the endpoint. An example of such usage is ProductResourceImp.kt. The exceptions are handled by GlobalExceptionHandler.kt, and they are converted to ErrorDto.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].