{"id":13625049,"url":"https://github.com/aantoniadis/clean-architecture-example","last_synced_at":"2025-04-16T06:31:36.349Z","repository":{"id":215451800,"uuid":"132374909","full_name":"aantoniadis/clean-architecture-example","owner":"aantoniadis","description":"A simple clean architecture example in Kotlin and Spring Boot 2.0","archived":false,"fork":false,"pushed_at":"2018-06-12T17:10:07.000Z","size":71,"stargazers_count":71,"open_issues_count":3,"forks_count":37,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-02-12T16:16:01.749Z","etag":null,"topics":["clean-architecture","kotlin","maven","multi-modules","multimodule","spring","spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aantoniadis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-06T20:49:26.000Z","updated_at":"2023-10-01T15:18:11.000Z","dependencies_parsed_at":"2024-01-04T15:02:07.013Z","dependency_job_id":null,"html_url":"https://github.com/aantoniadis/clean-architecture-example","commit_stats":null,"previous_names":["aantoniadis/clean-architecture-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantoniadis%2Fclean-architecture-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantoniadis%2Fclean-architecture-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantoniadis%2Fclean-architecture-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aantoniadis%2Fclean-architecture-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aantoniadis","download_url":"https://codeload.github.com/aantoniadis/clean-architecture-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223700202,"owners_count":17188267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-architecture","kotlin","maven","multi-modules","multimodule","spring","spring-boot"],"created_at":"2024-08-01T21:01:50.254Z","updated_at":"2024-11-08T14:30:21.045Z","avatar_url":"https://github.com/aantoniadis.png","language":"Kotlin","funding_links":[],"categories":["Kotlin","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"[![Build Status](https://travis-ci.org/aantoniadis/clean-architecture-example.svg?branch=master)](https://travis-ci.org/aantoniadis/clean-architecture-example)\n\n# Compile and run the app\n\n`./mvnw install \u0026\u0026 ./mvnw spring-boot:run -pl delivery`\n\nor\n\n`./mvnw install \u0026\u0026 java -jar delivery/target/delivery-1.0.0-SNAPSHOT.jar`\n\n# Description of the architecture\n\nThe project consists of 4 modules `core`, `usecases`, `dataproviders`, and\n`delivery`.\n\n## `core` module\n\nThis module contains the domain entities. There are no dependencies to frameworks and/or libraries.\n\n## `usecases` module\n\nThis module contains the business rules that are essential for our application\n(Application business rules). The only dependency of this module is to `core`.\nIn this module, gateways for the repositories are being defined. Each use case\ndefines the interface of the gateway that is required following the\n[ISP](https://en.wikipedia.org/wiki/Interface_segregation_principle). These\ngateways, operate on the domain entities defined in `core`.\n\nIn this module,\n[`UseCase`](https://github.com/aantoniadis/clean-architecture-example/blob/master/usecases/src/main/kotlin/com/github/aantoniadis/delivery/usecases/core/UseCase.kt)\nand\n[`UseCaseExecutor`](https://github.com/aantoniadis/clean-architecture-example/blob/master/usecases/src/main/kotlin/com/github/aantoniadis/delivery/usecases/core/UseCase.kt)\nare also defined. The `UseCase` is an interface similar to the\n`java.util.Function`. It just gets a request and returns a response.\n\nThe `UseCaseExecutor` handles the execution of a `UseCase`. To do so, it has an\n`invoke` method that takes the following arguments:\n1. the use case that is to be executed\n2. the RequestDto\n3. a function that converts the RequestDto to a Request object (the input of the use case)\n4. a function that converts the Response object (the output of the use case) of the use case execution to a ResponseDto\n\nThere are 3 more overloaded versions of the `invoke` method, which omit the input\nand/or the output of the `UseCaseExecutor`.\n\nCurrently, the `UseCaseExecutor` implementation\n([`UseCaseExecutorImp`](https://github.com/aantoniadis/clean-architecture-example/blob/master/usecases/src/main/kotlin/com/github/aantoniadis/delivery/usecases/core/UseCase.kt))\nis using `java.util.concurrent.CompletableFuture` and\n`java.util.concurrent.CompletionStage` for the execution abstraction. These\nabstractions are convenient as they can perform asynchronous executions and also\nhave out of the box compatibility with most frameworks.\n\n## `dataproviders` module\n\nThis module contains the implementation of the gateways defined in the\n`usecases` module. This module depends on the framework that facilitates the\ndata access. In our example, we use JPA and Spring Data. The `Jpa*Repository`\nclasses are the actual implementation of the gateways defined in the `usecases`\nmodule.\n\nThese repositories, use the Spring Data `JpaRepository` as dependencies.\nFor more, check\n[JpaProductRepository.kt](https://github.com/aantoniadis/clean-architecture-example/blob/master/dataproviders/src/main/kotlin/com/github/aantoniadis/dataproviders/db/jpa/repositories/JpaProductRepository.kt).\nThe entities in this module, are JPA entities, so mappings to and from these and\nthe domain entities are needed. Check\n[ProductEntity.kt](https://github.com/aantoniadis/clean-architecture-example/blob/master/dataproviders/src/main/kotlin/com/github/aantoniadis/dataproviders/db/jpa/entities/ProductEntity.kt)\nfor more.\n\n## `delivery` module\n\nThis module contains all the details of the delivery mechanism that we use along\nwith the wiring of the app and the configurations. In our example, we use rest services\nbuilt with Spring Boot. Similarly, to the JPA entities of the\n`dataproviders` module, the DTOs have mappers, to convert from and to the domain\nentities.\n\nA rest controller gets the RequestDto, and forwards it to the related\nuse case through the `UseCaseExecutor`. The response of the use case (which is a ResponseDto) is the response of the\ncontroller's method that implements the endpoint. An example of such usage is\n[ProductResourceImp.kt](https://github.com/aantoniadis/clean-architecture-example/blob/master/delivery/src/main/kotlin/com/github/aantoniadis/delivery/rest/imp/ProductResourceImp.kt).\nThe exceptions are handled by\n[GlobalExceptionHandler.kt](https://github.com/aantoniadis/clean-architecture-example/blob/master/delivery/src/main/kotlin/com/github/aantoniadis/delivery/rest/imp/GlobalExceptionHandler.kt),\nand they are converted to\n[ErrorDto](https://github.com/aantoniadis/clean-architecture-example/blob/master/delivery/src/main/kotlin/com/github/aantoniadis/delivery/rest/api/ErrorDto.kt).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faantoniadis%2Fclean-architecture-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faantoniadis%2Fclean-architecture-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faantoniadis%2Fclean-architecture-example/lists"}