/spring-modulith

Primary LanguageJavaApache License 2.0Apache-2.0

Spring Modulith

Spring Modulith allows developers to build well-structured Spring Boot applications and guides developers in finding and working with application modules driven by the domain. It supports the verification of such modular arrangements, integration testing individual modules, observing the application’s behavior on the module level and creating documentation snippets based on the arrangement created.

Quickstart

  1. Create a Spring Boot application on https://start.spring.io

  2. Create a Java package arrangement that puts business modules as direct sub-packages of the application’s main package.

    □ Example
    └─ □ src/main/java
       ├─ □ example           <1>
       |  └─ Application.java
       ├─ □ example.inventory <2>
       |  └─ …
       └─ □ example.order     <2>
          └─ …
    1. The application root package

    2. Application module packages

  3. Create an ApplicationModules model, run verifications and create documentation snippets.

    class ApplicationTests {
    
      @Test
      void writeDocumentationSnippets() {
    
        var modules = ApplicationModules.of(Application.class).verify(); (1)
    
        new Documenter(modules) (2)
          .writeModulesAsPlantUml()
          .writeIndividualModulesAsPlantUml();
      }
    }
    1. Creates application module model and verifies its structure.

    2. Renders Asciidoctor snippets (component diagrams, application module canvas) to target/modulith-docs.

  4. Run integration tests for individual application modules.

    □ Example
    └─ □ src/test/java
       └─ □ example.order
          └─ OrderModuleIntegrationTests.java
    @ApplicationModuleTests
    class OrderModuleIntegrationTests {
    
      @Test
      void someTestMethod() { … }
    }

Reference documentation

Find the reference documentation here.

Contributing

Pull requests are welcome. Note, that we expect everyone to follow the code of conduct.

License

Spring Modulith is Open Source software released under the Apache 2.0 license.