{"id":21901077,"url":"https://github.com/naspredam/rest-spring-boot-reactive-hexagonal-architecture","last_synced_at":"2025-04-15T20:09:17.240Z","repository":{"id":263126675,"uuid":"326426524","full_name":"naspredam/rest-spring-boot-reactive-hexagonal-architecture","owner":"naspredam","description":"Reactive project for hexagonal architecture","archived":false,"fork":false,"pushed_at":"2021-03-15T17:08:06.000Z","size":208,"stargazers_count":18,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T20:09:08.306Z","etag":null,"topics":["architecture","java","jpa","jpa-hibernate","reactive","spring-boot","spring-boot-framework"],"latest_commit_sha":null,"homepage":"","language":"Java","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/naspredam.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-03T14:30:43.000Z","updated_at":"2025-04-10T19:10:19.000Z","dependencies_parsed_at":"2024-11-20T11:03:53.980Z","dependency_job_id":null,"html_url":"https://github.com/naspredam/rest-spring-boot-reactive-hexagonal-architecture","commit_stats":null,"previous_names":["naspredam/rest-spring-boot-reactive-hexagonal-architecture"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naspredam%2Frest-spring-boot-reactive-hexagonal-architecture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naspredam%2Frest-spring-boot-reactive-hexagonal-architecture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naspredam%2Frest-spring-boot-reactive-hexagonal-architecture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/naspredam%2Frest-spring-boot-reactive-hexagonal-architecture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/naspredam","download_url":"https://codeload.github.com/naspredam/rest-spring-boot-reactive-hexagonal-architecture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249145302,"owners_count":21219966,"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":["architecture","java","jpa","jpa-hibernate","reactive","spring-boot","spring-boot-framework"],"created_at":"2024-11-28T15:12:13.463Z","updated_at":"2025-04-15T20:09:17.201Z","avatar_url":"https://github.com/naspredam.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest-spring-boot-hexagonal-architecture\n\nThis project is to expose my interpretation of the hexagonal architecture, under spring-boot framework.\n\nThe diagram of the hexagonal architecture relies on the following:\n\n![Hexagonal architecture diagram](img/hexagonal-architecture.png)\n\nI have tried to take a diagram that I have seen common on different articles, even though I saw port/adapter to be swap.\n\nThis architecture follows the clean architecture from Uncle bob:\n\n[https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)\n\nThis project is following this diagram on spring-boot framework.\n\n## Application diagrams\n\nOn this I was doing the following approach diagram:\n\n![Application diagram](img/hexagonal-arch-spring-naspredam.png)\n\nWhere we have as part of the application is:\n\n- REST implementation\n- Database connection\n\nThe colors meant to be:\n\n- Orange: this is the domain model of our application, that is located on `com.example.service.user.domain`\n- Blue: this is the application itself, where we have the logic and the ports (to apply this logic from and to). The package is: `com.example.service.user.application`\n- Green: this is the package `com.example.service.user.adapter`, where are the implementation of the ports. It was decided to keep the repositories and the controllers, even though this could be moved to the `infrastructure` package.\n\nWhat was not played out on this diagram was the package:\n\n`com.example.service.user.infrastructure`\n\nThis package is cross, so it was not having a flow on the diagram, but impacts to be defined shared components.\n\n## Domain model\n\nThe domain model is a simple one, for user management.\n\nThis diagram it is just a simple information for eventual `User` domain. We can see the following domain model diagram:\n\n![Domain model diagram](img/user%20domain%20model.png)\n\nwhere the colors here represents:\n\n- Orange: entity or root aggregate of our domain\n- Blue: value objects\n\nThis domain has a functions class, where it is a bunch of functions to access to `User` entity information.\n\n## Architecture tests\n\nIt was implemented the arch rules from [arch unit library](https://www.archunit.org/).\n\nThe tests are located on:\n\n```text\ncom.example.service.user.architecture.*\n```\n\n## Test strategy\n\nThe tests develop were doing unit tests for each class of the project.\n\nDo integration test on the controller, which is our application entry point.\n\n## Reactive strategy\n\nIn order to have not coupling with the spring boot reactive approach, it was defined two wrappers:\n\n- `com.example.service.user.infrastructure.reactive.CollectionReactive`: wrapper of the `Flux` object from reactive spring (reactor) approach.\n- `com.example.service.user.infrastructure.reactive.UnitReactive`: wrapper of the `Mono` object from reactive spring (reactor) approach.\n\nThese objects are used in the application level, to control the access to the reactive objects.\n\nThere is a problem when requiring transaction, where `@Transactional` cannot be used, as Flux/Mono are not being used. To have transactions we can use:\n\n```text\norg.springframework.transaction.reactive.TransactionalOperator\n```\n\nWe can see its use on the test:\n\n```text\ncom.example.service.user.adapter.entrypoint.api.UserControllerIntegrationTest\ncom.example.service.user.adapter.persistence.UserRepositoryTest\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaspredam%2Frest-spring-boot-reactive-hexagonal-architecture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnaspredam%2Frest-spring-boot-reactive-hexagonal-architecture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnaspredam%2Frest-spring-boot-reactive-hexagonal-architecture/lists"}