# citerus/dddsample-core architecture

> Architecture diagram of the GitHub repository citerus/dddsample-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/citerus/dddsample-core
- Repository: https://github.com/citerus/dddsample-core

## Overview

##### Main Components
- Frontend/Interfaces Layer: Represented by the “interfaces” package (with sub-packages for booking, handling, and tracking) and the static & template resources under src/main/resources. This layer handles web interactions (REST endpoints, controllers, JSP/HTML pages) and is the entry point for client requests.
- Application Layer: Found in the “application” packages (both under se/citerus/dddsample/application and in the booking facades). This is where use-case orchestration occurs through services such as BookingService, CargoInspectionService, and HandlingEventService.
- Domain Layer: Located under se/citerus/dddsample/domain where the core domain models (cargo, handling, location, voyage, etc.), domain services, and specifications reside. This layer encapsulates business rules and entities.
- Infrastructure Layer: Seen under se/citerus/dddsample/infrastructure. It covers messaging (JMS consumers and producers), persistence (JPA and Hibernate implementations for repositories), routing (integration with external routing services), and sample data generators.
- Additional/Supporting Components: The “com.pathfinder” package provides a separate Graph Traversal service. Although it sits outside the main DDD package hierarchy, it should be represented if it plays a role in the overall system (for example, if graph path computations are integrated into the business logic).

##### Relationships and Data Flow
- That the Interfaces Layer (web controllers, REST endpoints) receives requests and passes them to the Application Layer.
- The Application Layer coordinates domain logic by invoking Domain layer objects and domain services.
- Domain objects are persisted/retrieved through the Infrastructure layer where both JPA and Hibernate-based repositories reside.
- There is integration with Messaging (via JMS in the Infrastructure layer) and External Routing Services, which feed data or commands back into the domain logic.
- The Pathfinder component (Graph Traversal API) should be depicted as a separate module that might be used internally by application services or as an independent API that can be called externally.

##### Architectural Patterns and Technologies
- The layered architecture neatly separates concerns (presentation, application, domain, infrastructure).
- DDD principles are central – emphasize aggregates, domain services, repositories, and value objects.
- Use of Spring Boot and Maven (indicated by the pom.xml, Maven wrapper – mvnw) simplifies application startup and dependency management.
- REST endpoints like the HandlingReport API (POST /dddsample/handlingReport) which is defined in the API documentation (api-docs.yaml).
- External messaging integration (JMS consumers for handling event registration).

##### Final Recommendations
- To include details relevant for a full-stack DDD sample project, with special attention to how domain-driven design is implemented in its code structure.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend / Interfaces Layer
    subgraph "Frontend / Interfaces"
        IF["Web/REST Controllers (Interfaces)"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        AP["Application Services\n(BookingService, HandlingEventService, etc.)"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        DM["Domain Model\n(Cargo, HandlingEvent, Location, Voyage)"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        INF["Infrastructure\n(JPA/Hibernate, JMS, Routing, Data Generators)"]:::infrastructure
    end

    %% Pathfinder Component
    EX["Graph Traversal Service\n(Pathfinder)"]:::external

    %% Relationships
    IF -->|"calls"| AP
    AP -->|"invokes"| DM
    DM -->|"persists/retrieves"| INF
    AP -->|"integrates"| INF
    AP -->|"uses"| EX

    %% Styles
    classDef frontend fill:#cfe2f3,stroke:#1f497d,stroke-width:2px;
    classDef application fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef domain fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef infrastructure fill:#ead1dc,stroke:#842029,stroke-width:2px;
    classDef external fill:#d0e0e3,stroke:#434343,stroke-width:2px;

    %% Click Events
    click IF "https://github.com/citerus/dddsample-core/tree/master/src/main/java/se/citerus/dddsample/interfaces"
    click AP "https://github.com/citerus/dddsample-core/tree/master/src/main/java/se/citerus/dddsample/application"
    click DM "https://github.com/citerus/dddsample-core/tree/master/src/main/java/se/citerus/dddsample/domain"
    click INF "https://github.com/citerus/dddsample-core/tree/master/src/main/java/se/citerus/dddsample/infrastructure"
    click EX "https://github.com/citerus/dddsample-core/tree/master/src/main/java/com/pathfinder"
```
