1 min read

Simple Package Structure for Spring Boot REST API

An opinionated package structure for a relatively simple REST API applications with Spring Boot

What are we building?

Example REST Endpoint - PingPong API

Assumptions:

  • You have some models to store and fetch from storage.
  • There is some business logic involved before saving an object.

Why even bother with a structure?

  • Not over-complicated, but also not everything in one file.
  • Easier to navigate.
  • Paving the road for future extensions.

What's inside?

  • Only three layers.
  • At a minimum, only one model conversion - Entity to DTO.

Advantages

  • It is elementary to get started.
  • Possibility to extend. For example, input validation can be done directly on the DTOs or by introducing Request and Response models at the top layer.

Subscribe and Follow

* Subscribe to CoderVlogger.com and consider becoming a member.
* Check my Twitter for more up-to-date information.