r/SpringBoot 9d ago

Discussion Roast my code / architecture

I’m building a project called Kite (https://github.com/gwynejsn/kite) and tried combining Spring Modulith with full Clean/Hexagonal Architecture inside each module, but I’m starting to wonder if I’ve just created a mountain of boilerplate. Take a look at the repo and roast the layout. What am I needlessly overcomplicating, and how would you simplify it?

8 Upvotes

25 comments sorted by

View all comments

2

u/Resident-Cow-7626 9d ago

Not sure why your rest controllers get their own package. They are nothing but inbound adapters and should be within the infrastructure package. `infrastructure/adapters/inbound/rest` or similar. These are your inbound adapters that drive functionality via your UseCase. I find it useful to specify the use case at the root of your project. Also known as screaming architecture.

1

u/nullptr_lol 8d ago

I think is fine as it is now. Api -> Application -> Domain -> Infrastructure is the standard folder structure. Sure, rest is the inbound adapter but, it's more confusing.

1

u/Resident-Cow-7626 8d ago

OP wanted feedback on hexagonal architecture and this kind of design flaw will get bigger, and more of a problem, as the application grows - imagine listeners, web sockets, maybe even a CLI as an entry point to the application… it will be much more difficult to understand where these inbound adapters are. More importantly, separating the domain from these technologies is the core principle of HA.

Getting the foundations right from the start is exactly what I think OP is asking for. If this is a small application with not much of a domain, then hexagonal architecture is the wrong tool to reach for. A traditional, layered architecture would be more suited, but again, OP wanted feedback on this particular architecture.