Skip to content

Showcasing Spring Modulith's power to assemble an application like a jigsaw puzzle of cohesive modules.

Notifications You must be signed in to change notification settings

MarianaSequeira/spring-modu-jigsaw

Repository files navigation

Spring Modulith Jigsaw

Showcasing Spring Modulith's power to assemble an application like a jigsaw puzzle of cohesive modules. This repository serves as a demonstration and reference to implement and use the new Spring Modulith feature.

Spring Modulith supports developers implementing logical modules in Spring Boot applications. It allows to apply structural validation, document the module arrangement, run integration tests for individual modules, observe the modules interaction at runtime and generally implement module interaction in a loosely-coupled way. (Click here to learn more)

Project Overview

In this repository, you'll find a sample application that demonstrates some of the key concepts of Spring Modulith. The project is organized into four modules: gateway, inventory, notification and order. The component diagram on the right describes the architecture of this example project. Please note the following:

  • The purpose of this project is just to showcase some of the most important features available with Spring Modulith.
  • The diagram presented was generated using Spring Modulith documentation capabilities, available via ApplicationModules class. In addition to being able to generate component diagrams in UML and C4, this feature also allows to generate a so-called Application Module Canvas, a tabular overview about the module and the most relevant elements in those. This can be achieved by running the Unit Test renderDocumentation() available in the ModularityTests class.

Bonus 🎉

In addition to showcasing the Spring Modulith architecture, this project incorporates the following features:

Observability

Interactions between application modules are instrumented to generate Micrometer spans, which are then aggregated into traces that can be visualized using tools like Zipkin. When you start the application, Spring Boot will automatically attempt to launch a Docker container for Zipkin. To access the Zipkin dashboard, open your web browser and navigate to http://localhost:9411.

zipkin_example.png

Event-Based Communication

To keep application modules as decoupled as possible from each other, their primary means of interaction should be event publication and consumption. This avoids the originating module to know about all potentially interested parties, which is a key aspect to enable application module integration testing. This application is making use of Application Events to showcase how can this be achieved by using @ApplicationModuleListener annotation.

Another intriguing aspect of Spring Modulith is the Event Publication Registry. Spring Modulith includes a built-in event publication registry that seamlessly integrates with the core event publication mechanism of the Spring Framework. To delve deeper into this topic, you can find more information by following this link.

Requirements

Before you get started, ensure you have the following software installed on your system:

  • Java Development Kit (JDK) - You'll need JDK 17 or higher.
  • Maven - A build and dependency management tool.
  • Docker - A containerization platform. Ensure that Docker is installed and running on your system.

How to Run

Follow these steps to run this project on your local machine:

  1. Clone the Repository

    git clone https://github.com/MarianaSequeira/spring-modu-jigsaw.git
    
  2. Run the app with the following command:

    $ mvn spring-boot:run

About

Showcasing Spring Modulith's power to assemble an application like a jigsaw puzzle of cohesive modules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages