r/SpringBoot • • Sep 29 '24

Package structure

Post image

What do you think about this package structure? What packages or layers would you add or remove if you work with microservices architecture?

43 Upvotes

43 comments sorted by

View all comments

1

u/WaferIndependent7601 Sep 29 '24

If you work with a microservices (you should not do this) then you have no packages. Your service is the package.

Your structure is way too much.

Don’t prefix interfaces with an I.

Don’t use an interface if you only have one implementation.

2

u/Jeevigyan-vala Sep 29 '24

Agree with all of the advice except microservices bit.

Each microservice should handle a separate concern (eg User service, authentication service, etc), and that could include multiple packages within a given service.

Having a separate microservice for each “package” seems too granular and loses sight of the idea behind microservices

-2

u/WaferIndependent7601 Sep 29 '24

That is the idea of a microservice. That’s why this approach is so bad and no one should use it. The definition of a microservice is that you can rewrite it in 4 weeks.

0

u/HappyPurchase72 Sep 29 '24

Thanks for the comment, I think it's a good structure to start with, I'll take into account the interface prefix. Personally I like to separate interfaces and implementations to have a better understanding of the structure.

4

u/WaferIndependent7601 Sep 29 '24

If you think that it’s a good structure and don’t want to change anything: why are you asking?

0

u/HappyPurchase72 Sep 29 '24

I think it's a good basic structure to start with, but I had doubts about how the packages were organized, anyway, thank you very much for your time 😎

2

u/WaferIndependent7601 Sep 29 '24

No. The structure is very bad. Im serious.

1

u/HappyPurchase72 Sep 29 '24

I understand. What structure model could you recommend that takes into account maintenance and changing requirements based on the specific needs of the company? I ask because I am in the design process with the company and I want each microservice to be scalable.

3

u/Jeevigyan-vala Sep 29 '24

Why did you decide on microservices? IMO you should default to a monolith and only do microservices if you can justify it

2

u/WaferIndependent7601 Sep 29 '24

Modulith, not monolith 👍

1

u/HappyPurchase72 Sep 29 '24

I'm considering microservices for my project to ensure scalability and modularity as it grows. I’d appreciate any insights or experiences you have regarding when it’s justified to switch from a monolith to microservices.