I'm using Hexagonal Architecture in my Ktor app wi...
# ktor
r
I'm using Hexagonal Architecture in my Ktor app with the following layers - core, infrastructure and webapi, Initially I tried to have these as top-level packages (e.g. my.root.package.core), but as the app grows it's getting messy. So I thought of taking advantage of Gradle modules to split the layers (as an extra I can also better isolate implementation details for each layer). Now I'm wondering where to place the modules though, I see lots of apps with modules in the root of the project, but then I have to use a prefix to keep the module folders close to each other. If you split your app in Gradle modules, where do you usually put them and which naming convention do you use, if any?
d
You can create the modules in subfolders, one per area of functionality for your app. Your gradle modules might end up with a structure like this, given you have a "payment" and a "shipment" functionality and you want to keep the layers within these functionalities together:
Copy code
:payment:core
:payment:infra
:payment:webapi

:shipment:core
:shipment:infra
:shipment:webapi
❤️ 1
👍 1
r
That looks really nice!
c
You are talking about layers in Hexagonal Architecture. Is it oxymoron? The Hexagonal Architecture claims to replace layered architecture. Nevertheless, both architectures can organizing/grouping Gradle modules they way you want. One, suggested by @Dominik Sandjaja is good example of one of possible way.
r
Fun fact: I had to search for what oxymoron meant to answer you 😅 I wouldn't say it odd at all for Hexagonal Architecture to use layers, it might replace the traditional stacked layered architecture but that doesn't mean it can't have layers for internal organization. The whole purpose is establishing a core with ports that external adapters either use or implement, now if adapters are organized as modules/layers/subprojects that's up to implementation. At least that's how I understood it.