How spring-projects/spring-modulith works
Main Components
• Modules/Artifacts: Represent each top-level module (spring-modulith-core, spring-modulith-api, spring-modulith-apt, spring-modulith-actuator, spring-modulith-events, spring-modulith-docs, spring-modulith-runtime, spring-modulith-starters, spring-modulith-test, etc.). Each of these modules is built to support a certain domain:
– Core / API: Provides the model for application modules and common utilities.
– APT (Annotation Processing): Processes annotations to verify module structure.
– Actuator: Exposes module details and integrates with Spring Boot Actuator.
– Events: Manages domain events (with separate implementations for AMQP, JDBC, Kafka, JMS, etc.).
– Observability/Runtime: Monitors module behavior and metrics.
– Starters & Test components: Provide simplified integration for end-users and testing support.
– Examples/Integration tests: Show sample modular applications and verify integrity.
Relationships & Interactions
– The core and API modules form the foundation; other modules (like the actuator and events modules) depend on them.
– The APT module works during compile time to analyze the same package structures that the core uses at runtime.
– Documentation tools (spring-modulith-docs) and testing (spring-modulith-test) integrate with the core model (ApplicationModules) and use outputs from the verification process.
– Starters are thin wrappers that pull in the relevant modules for a Spring Boot application.
• How integration tests (under test directories) leverage specific modules (e.g., “module integration tests” in the examples).
Architectural Patterns & Design Principles
• Modular design: The concept of “application modules” is central. These are typically defined by Java packages that are direct subpackages of the application’s base package.
• Annotated Unit and Integration Tests: The project provides support to test individual modules separately.
• Separation of concerns: Core models are isolated from extension modules (e.g., actuator, events, runtime, documentation) which implement specific cross-cutting concerns.
• Build and dependency management through Maven (the use of a BOM and Maven wrapper across modules reinforces version consistency and modular independence).