How packtpublishing/domain-driven-design-with-java-a-practitioner-s-guide works
Project type and purpose
• This is a multi-module Maven project that accompanies the book “Domain-Driven Design with Java – A Practitioner’s Guide.”
File structure
• Top-level modules:
• Chapter05, Chapter06, … Chapter09 – each with its own pom.xml, main/java, main/resources, test/java.
• Within each ChapterXX:
• src/main/java/com/premonition/lc/chXX/domain – aggregates, entities, commands, events, exceptions
• src/main/java/com/premonition/lc/chXX/domain/queries – read-side event handlers, repositories, view models
• src/main/java/com/premonition/lc/chXX/domain/sagas – long-running workflow orchestrators
• src/main/java/com/premonition/lc/chXX/ui – JavaFX UI code: views, viewmodels, services
• application.properties – Spring Boot / Axon / JavaFX configuration
• CI workflow: .github/workflows/pipeline.yaml; root pom.xml orchestrates modules.
README for additional insights
• Describes the book’s DDD focus, layering, event-storming, CQRS, EDA, sagas, microservices decomposition, and usage of Spring, Axon, JavaFX.
a. Main components
• Client Layer: JavaFX UI (Views, ViewModels, UIUtils)
• API Layer: BackendService (HTTP/WebSocket client)
• Application (Spring Boot / Axon) – Command Gateway, Event Bus
• Domain Layer: Aggregates (LCApplication), Commands, Domain Events, Domain Exceptions
• Saga Orchestrator: AutoApprovalSaga
• Query Side: Event Handlers, Read-model repositories (LCViewRepository, LCSummaryRepository), View projections (LCView, LCSummaryView)
• Persistence: Transactional store for write model; separate store/tables for read model
• External Systems: Inbound validation services (ApplicantCreditValidatedEvent, ProductValueValidatedEvent, ProductLegalityValidatedEvent); Outbound notifications (LCApplicationApprovedEvent, etc.)
b. Component relationships & data flows
1. UI triggers command via BackendService →
2. API Layer invokes Axon Command Gateway →
3. Domain Aggregate handles command → emits Domain Event →
4. Event Bus broadcasts event to:
• Saga (AutoApprovalSaga) to orchestrate long-running workflows
• Query Handlers to update read models (projections)
• Message publishers to external systems (outbound events)
5. External systems send inbound events → consumed by Domain Event Handlers → continue saga or update state
6. UI queries read model via BackendService → returns projected views
c. Architectural patterns & design principles
• Layered Architecture (Presentation, Application, Domain, Infrastructure)
• CQRS: separation of command (write) model and query (read) model
• Event-Driven Architecture: domain events as the source of truth, asynchronous message bus
• Saga Pattern: long-running business process orchestration
• Hexagonal / Ports & Adapters: UI and external systems connect via well-defined service interfaces
d. Key technologies & frameworks
• Java 14, Spring Boot
• Axon Framework (Command Gateway, Event Bus, Sagas)
• JavaFX for desktop UI
• Maven for build and module orchestration
• Asciidoctor + PlantUML/Graphviz for documentation