# feiniaojin/ddd-hcms architecture

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

- Interactive diagram: https://gitdiagram.com/feiniaojin/ddd-hcms
- Repository: https://github.com/feiniaojin/ddd-hcms

## Overview

##### Main Components
- Domain Layer – Represented by the module “ddd-hcms-domain.” It contains all the core domain models (e.g., EntryEntity, TypeEntity), domain services, repository interfaces, factories, value objects (e.g., EntryId, DictVo), and enums. This layer is central to DDD.
- Application Service Layer – Found in “ddd-hcms-application-service.” It includes application logic such as command services, query services (for entries, entry fields, types, type fields), command objects, DTOs, and factories interacting with the domain layer.
- Infrastructure Layer – There are several infrastructure modules, each handling a different external concern:
- Persistence (“ddd-hcms-infrastructure-persistence”) contains repository implementations, JDBC components, SQL scripts, and data mapping.
- Cache (“ddd-hcms-infrastructure-cache”), Gateway (“ddd-hcms-infrastructure-gateway”), and Publisher (“ddd-hcms-infrastructure-publisher”) each handle their respective technical responsibilities.
- Launcher – “ddd-hcms-launcher” serves as the bootstrap or startup module which wires the application together (configurations, logging via logback.xml, etc.).
- User Interface Layers – There are multiple UI modules:
- Provider, Subscriber, Web, and Worker modules: Each module (e.g., “ddd-hcms-user-interface-web”) contains controllers, annotations (like UrlRequestParam and its resolver), and configuration classes for presenting a clean API and handling different types of UI or integration tasks.

##### Relationships and Interactions
- The Infrastructure modules (cache, gateway, persistence, publisher) provide concrete implementations that satisfy the contracts defined in the Domain.
- The User Interface modules expose endpoints (via controllers in, for example, the “ddd-hcms-user-interface-web” module) and interact with the Application Service Layer to process incoming requests or data commands.
- Optionally, indicate interaction with external systems (e.g., databases driven by SQL scripts, external DDD libraries as referenced in the README, or even assets like the book image).

##### Architectural Patterns and Design Principles
- DDD Patterns: Clearly mark bounded contexts; indicate the separation between the domain, application, and infrastructure layers.
- Layered Architecture: Emphasize the separation of concerns by drawing clear boundaries between modules.
- Repository Pattern: Show how domain repository interfaces are implemented by the persistence layer.
- Command-Query Separation: Note command services vs. query services in the application layer.
- Service Factories: Indicate the factory implementations in both the domain and application layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        UI_Provider["UI – Provider"]:::ui
        UI_Subscriber["UI – Subscriber"]:::ui
        UI_Web["UI – Web"]:::ui
        UI_Worker["UI – Worker"]:::ui
    end

    subgraph "Application Service Layer"
        AppService["Application – Command/Query Services"]:::app
    end

    subgraph "Domain Layer"
        Domain["Domain – Content Model"]:::domain
    end

    subgraph "Infrastructure Layer"
        Persistence["Persistence – Repository Implementations"]:::infra
        Cache["Cache – Caching Layer"]:::infra
        Gateway["Gateway – External Gateways"]:::infra
        Publisher["Publisher – Event Publishing"]:::infra
    end

    Launcher["Launcher – Bootstrap/Configuration"]:::launcher

    %% UI to Application Service
    UI_Provider -->|"callsApp"| AppService
    UI_Subscriber -->|"callsApp"| AppService
    UI_Web -->|"callsApp"| AppService
    UI_Worker -->|"callsApp"| AppService

    %% Application Service to Domain
    AppService -->|"callsDomain"| Domain

    %% Domain to Infrastructure (dotted arrows)
    Domain -.->|"repoImpl"| Persistence
    Domain -.->|"repoImpl"| Cache
    Domain -.->|"repoImpl"| Gateway
    Domain -.->|"repoImpl"| Publisher

    %% Launcher initializing Application Service and Infrastructure Layers
    Launcher -->|"initApp"| AppService
    Launcher -->|"initInfra"| Persistence
    Launcher -->|"initInfra"| Cache
    Launcher -->|"initInfra"| Gateway
    Launcher -->|"initInfra"| Publisher

    %% Click Events
    click Domain "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-domain"
    click AppService "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-application-service"
    click Persistence "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-infrastructure-persistence"
    click Cache "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-infrastructure-cache"
    click Gateway "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-infrastructure-gateway"
    click Publisher "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-infrastructure-publisher"
    click Launcher "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-launcher"
    click UI_Provider "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-user-interface-provider"
    click UI_Subscriber "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-user-interface-subscriber"
    click UI_Web "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-user-interface-web"
    click UI_Worker "https://github.com/feiniaojin/ddd-hcms/tree/main/ddd-hcms-user-interface-worker"

    %% Styles
    classDef ui fill:#e2a9f9,stroke:#333,stroke-width:2px;
    classDef app fill:#c7f9cc,stroke:#333,stroke-width:2px;
    classDef domain fill:#aee2f9,stroke:#333,stroke-width:2px;
    classDef infra fill:#f9d6a5,stroke:#333,stroke-width:2px;
    classDef launcher fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
