Skip to content

garytxo/spring-modulith-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Modulith Playground

What is Spring Modulith

Spring Modulith is a none intrusive library to help improve the architecture of spring applications by dividing subpackage into distinct modules. This each module thus encapsulates its own logic, dependencies, and configuration, this promoting separation of concerns and improving maintainability.

This small Inventory Application illustrates how we can take Spring Modulith and add it to some legacy project where currently use hexagonal architecture (with CQRS) and DDD

Inventory Application Modules

The Inventory project is a simple inventory application to manage orders of product.

TODO

  • Explain how the PackageInfo are used to expose internal api and events
  • Check if we can override the domain events database schema
  • Define how to start the application

Working with example

  • Sample CURL to start order
  curl --request POST \
  --url http://127.0.0.1:8080/orders \
  --header 'Content-Type: application/json' \
  --header 'accept: application/json' \
  --data '{  "description": "test", "lineItems": [{ "quantity":4,"product": 5}]}'

Implementation new module

The idea is that we should declare all classes in the new module as Package-Private / Default Visibility. In Java “package-private” (also referred to as “default”) which means that any code in the same package can access it, but any code in a different package can not, including subclasses. Unfortunately kotlin does not currently support this modifer as explained here But maybe it is possible with the internal modifer

Ideas to take into consider

https://www.javaguides.net/2024/05/spring-modulith-tutorial.html

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages