Skip to content
Skills Library
Programming · Building & coding

spring-boot-modulith

/spring-boot-modulith

Spring Modulith 2.0 implementation for bounded contexts in Spring Boot 4. Use when structuring application modules, implementing @ApplicationModuleListener for event-driven communication, testing with Scenario API, enforcing module boundaries, externalizing events to Kafka/AMQP, building a modular monolith, defining module dependencies, managing inter-module events, or organizing DDD modules as packages. Covers package-based module boundaries, named interfaces, event publication, and Scenario API testing. For architecture decisions, see domain-driven-design skill.

Licence
MIT
Last repository change
14.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
6
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 14.08.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Spring Modulith 2.0 implementation for bounded contexts in Spring Boot 4. Use when structuring application modules, implementing @ApplicationModuleListener for event-driven communication, testing with Scenario API, enforcing module boundaries, externalizing events to Kafka/AMQP, building a modular monolith, defining module dependencies, managing inter-module events, or organizing DDD modules as packages. Covers package-based module boundaries, named interfaces, event publication, and Scenario API testing. For architecture decisions, see domain-driven-design skill.

Original author description

Spring Modulith 2.0 implementation for bounded contexts in Spring Boot 4. Use when structuring application modules, implementing @ApplicationModuleListener for event-driven communication, testing with Scenario API, enforcing module boundaries, externalizing events to Kafka/AMQP, building a modular monolith, defining module dependencies, managing inter-module events, or organizing DDD modules as packages. Covers package-based module boundaries, named interfaces, event publication, and Scenario API testing. For architecture decisions, see domain-driven-design skill.

How it works

  1. Core Concepts
  2. Module Structure
  3. Quick Patterns
  4. Spring Boot 4 / Modulith 2.0 Specifics
  5. Detailed References
  6. Related Skills
  7. Anti-Pattern Checklist
  8. Critical Reminders
Original SKILL.md headings · 87 lines, 434 words
SKILL.md preview
---
name: spring-boot-modulith
description: Spring Modulith 2.0 implementation for bounded contexts in Spring Boot 4. Use when structuring application modules, implementing @ApplicationModuleListener for event-driven communication, testing with Scenario API, enforcing module boundaries, externalizing events to Kafka/AMQP, building a modular monolith, defining module dependencies, managing inter-module events, or organizing DDD modules as packages. Covers package-based module boundaries, named interfaces, event publication, and Scenario API testing. For architecture decisions, see domain-driven-design skill.
spring-boot-version: "4.0"
---

# Spring Modulith for Bounded Contexts

Implements DDD bounded contexts as application modules with enforced boundaries and event-driven communication.

## Core Concepts

| Concept | Description |
|---------|-------------|
| **Application Module** | Package-based boundary = bounded context |
| **Module API** | Types in base package (public) |
| **Internal** | Types in sub-packages (encapsulated) |
| **Events** | Cross-module communication mechanism |

## Module Structure

```
src/main/java/
├── com.example/
│   └── Application.java              ← @SpringBootApplication
├── com.example.order/                ← Module: order
│   ├── OrderService.java             ← Public API
│   ├── OrderCreated.java             ← Public event
│   ├── package-info.java             ← @ApplicationModule config
│   └── internal/                     ← Encapsulated
│       ├── OrderRepository.java
│       └── OrderEntity.java
├── com.example.inventory/            ← Module: inventory
│   ├── InventoryService.java
│   └── internal/
└── com.example.shipping/             ← Module: shipping
```

Types in `com.example.order` = public API
Types in `com.example.order.internal` = hidden from other modules

## Quick Patterns

See [EXAMPLES.md](EXAMPLES.md) for complete working examples including:
- **Module Configuration** with @ApplicationModule
- **Event Publishing** with domain event records
- **Event Handling** with @ApplicationModuleListener (Java + Kotlin)
- **Module Verification Test** with PlantUML generation
- **Event Externalization** for Kafka/AMQP

## Spring Boot 4 / Modulith 2.0 Specifics

- **@ApplicationModuleListener** combines `@Async` + `@Transactional(REQUIRES_NEW)` + `@TransactionalEventListener(AFTER_COMMIT)`
- **Event Externalization** with `@Externalized` annotation for Kafka/AMQP
- **JDBC event log** ensures at-least-once delivery

## Detailed References

- **Examples**: See [EXAMPLES.md](EXAMPLES.md) for complete working code examples
- **Troubleshooting**: See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for common issues and Boot 4 migration
- **Workflow**: See [WORKFLOW.md](WORKFLOW.md) for detailed step-by-step Modulith setup
- **Module Structure**: See [references/MODULE-STRUCTURE.md](references/MODULE-STRUCTURE.md) for package conventions, named interfaces, dependency rules
- **Event Patterns**: See [references/EVENTS.md](references/EVENTS.md) for publishing, handling, externalization, testing with Scenario API

## Related Skills

| Need | Skill |
|------|-------|
| DDD concepts | `domain-driven-design` |
| Data layer per module | `spring-boot-data-ddd` |
| Module event testing | `spring-boot-testing` |
| REST APIs for modules | `spring-boot-web-api` |

## Anti-Pattern Checklist

| Anti-Pattern | Fix |
|--------------|-----|
| Direct bean injection across modules | Use events or expose API |
| Synchronous cross-module calls | Use `@ApplicationModuleListener` |
| Module dependencies not declared | Add `allowedDependencies` in `@ApplicationModule` |
| Missing verification test | Add `ApplicationModules.verify()` test |
| Internal types in public API | Move to `.internal` sub-package |
| Events without data | Include all data handlers need |

## Critical Reminders

1. **One module = one bounded context** — Mirror DDD boundaries
2. **Events are the integration mechanism** — Not direct method calls
3. **Verify in CI** — `ApplicationModules.verify()` catches boundary violations
4. **Reference by ID** — Never direct object references across modules
5. **Transaction per module** — `@ApplicationModuleListener` ensures isolation
Files in this package (6)
  • EXAMPLES.md 5 KB
  • SKILL.md 4 KB
  • TROUBLESHOOTING.md 6 KB
  • WORKFLOW.md 7 KB
  • references/EVENTS.md 12 KB
  • references/MODULE-STRUCTURE.md 8 KB

Versions

The database has no other skills named spring-boot-modulith.

Database snapshot: 13.11.2026 · package version 045f699d3f7f (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100spring-modulith
    Use when organizing or verifying a modular Spring Boot monolith with Spring Modulith, including module APIs, dependency rules and reliable module events. Do not restructure an application into modules for an unrelated endpoint change.
  • 100305-frameworks-spring-boot-modulith
    Use when you need to design, review, or improve modular monoliths with Spring Modulith in Spring Boot applications - including application module package structure, ApplicationModules verification, named interfaces, allowed dependencies, domain events, @ApplicationModuleTest,…
  • 100spring-modulith
    Use when organizing or verifying a modular Spring Boot monolith with Spring Modulith, including module APIs, dependency rules and reliable module events. Do not restructure an application into modules for an unrelated endpoint change.
  • 100spring-modulith
    Spring Modulith for modular architecture in Spring Boot 3.x. Covers module structure, API vs internal packages, inter-module events, module testing, documentation generation, and observability. USE WHEN: user mentions "spring modulith", "modular monolith", "@ApplicationModule",…
  • 100spring-modulith-verifier
    Verifies whether code follows Spring Modulith code structure or not. Show list of violations along with recommendations on how to fix them. Use this skill: * When reviewing Spring Boot applications which uses Spring Modulith * When verifying whether Spring Boot application code…
  • 100spring-testing-strategy
    Choose the kind of test for Spring Boot code - plain unit test, @SpringBootTest, test slice, Spring Modulith module test, SpringApplicationBuilder, or browser test. Use when about to write tests in a Spring Boot app, or when deciding where a new test belongs.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.