Skip to content

How to organize the project structure of a REST API service? #210

Answered by odrotbohm
rijekaDrina asked this question in Q&A
Discussion options

You must be logged in to vote

Before we start, please note that it does not make sense to discuss module structure with only a single module present. Spring Modulith primarily helps to organize code into multiple, functional modules. What kind of technical organization you use within those modules is actually a bit out of scope as it is, essentially, an implementation detail of the module and thus doesn't affect the maintainability of the overall arrangement.

Basically, you have two options:

Single-package approach

Simply stick to the user package. Types that need to be accessed by other modules, need to be declared public (+). Everything else stays package private (o).

└ user
  ├ + User.java
  ├ o UserController.java…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@odrotbohm
Comment options

Answer selected by odrotbohm
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants