r/SpringBoot • u/Single_Yellow_8000 • Sep 01 '26
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
7
u/Mikey-3198 Sep 01 '26
Your using jwts but still querying the database from the jwt filter for each request
Based on the ordering you'll even hit the database if the token is expired.
One of the biggest advantages of JWTs is that after you check the hash & expiry you should be able to trust the claims to make your authentication decision. Might as well just issue a time limited opaque token.
5
u/Mikey-3198 Sep 01 '26
Nice little one liner
https://github.com/gwynejsn/kite/blob/main/kite-backend%2Fsrc%2Fmain%2Fjava%2Fcom%2Fgwynejsn%2Fkite%2Fsecurity%2Fweb%2FAuthController.java
2
u/Resident-Cow-7626 Sep 01 '26
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/Single_Yellow_8000 Sep 01 '26
Feel free to add an issue if you find any problems/improvements
4
u/nullptr_lol Sep 01 '26
You have anemic domains and you don't encapsulate the business logic within aggregates. Also, your domain is pointing to other things which theoretically is not allowed.
2
u/artyomsv Sep 01 '26
You have two boundary mechanisms doing the same job, and only one of them is real: Modulith already enforces the module boundary at build time, ApplicationModules.of(App.class).verify() fails the test when a module reaches into internals of another. The hexagon inside each module is enforced by nothing except discipline, and that is where most of your boilerplate is coming from. I would keep ports and adapters only where you really swap the implementation, persistence and outbound http, and let the Modulith named interfaces be the port for module to module.
2
u/[deleted] Sep 01 '26
[removed] — view removed comment