loading...

Discussion on: Spring boot codebase structure

Collapse
ndrone profile image
Nicholas Drone

As far as project structure. I start with 2 modules Applications and components.

Applications are your microservices. They contain your spring boot dependencies, controllers and message listener code. The idea is they take the information off the wire and passes it onto your service layer which is in your components module. This way if the delivery protocol changes you only need to change your application layer code.

Components are broken out into multiple modules. I usually have one or more core module. The core module contains all or most of my interfaces, not the implementations, any pojos needed for the interfaces, helper classes and utils. These are split on domains depending on project size.

Repository implementations are all separate by domain and technology. For example, a contact domain may have 2 modules one for JDBC and one for HTTP.

Then I have a service module for the repositories which is what the applications interface with if need be. If the service layer is just a pass-through then I forgo the service layer.