# system-sekkei/isolating-the-domain architecture

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

- Interactive diagram: https://gitdiagram.com/system-sekkei/isolating-the-domain
- Repository: https://github.com/system-sekkei/isolating-the-domain

## Overview

##### Main Components
- Frontend/Presentation Layer – This is implemented primarily in the “src/main/java/example/presentation” package for controllers and views (with templates under “src/main/resources/templates”). Use Thymeleaf for the rendering of HTML pages.
- Application Layer – Contains coordinators and services that orchestrate business processes (found under “src/main/java/example/application”). This layer manages operations related to employees, payroll, timerecords, attendance, and wages.
- Domain Layer – This holds the core business logic and domain models (under “src/main/java/example/domain”). It includes packages for different domain objects (employee, contract, timerecord, payroll, wage, and supporting types and validation).
- Infrastructure Layer – Provides the integration with external systems such as persistence. This is implemented in “src/main/java/example/infrastructure” where data sources and MyBatis mappers are defined, as well as transfer objects.
- External Elements – Include database components (implied by the presence of schema files, MyBatis configuration “mybatis.xml”, SQL scripts “schema.sql”, and data seed “data.sql”), and continuous integration (CircleCI configuration) and deployment files (Procfile, gradle build files).

##### Relationships and Interactions
- The Presentation layer (controllers in “presentation/controller”) receives requests (for dashboard, employee management, payroll, time records, etc.) and delegates requests to the Application layer.
- The Application layer (with “coordinator” and “service” subpackages) handles business logic, calling the Domain layer for business rules and computations and relying on the Infrastructure layer (repositories, data sources, mappers) for persistence operations.
- The Domain layer encapsulates the business entities, rules, and validations. It remains independent and is referenced by both the Application and Infrastructure layers to ensure consistency in business logic.
- The Infrastructure layer acts as a bridge between the Application/Domain layers and the database (via MyBatis). It also handles any other external systems or data integration.

##### Architectural Patterns Highlight
- Domain-Driven Design (DDD) / Isolating the Domain – The project clearly separates domain models and business logic from presentation and infrastructure concerns.
- MVC Pattern – The use of Spring MVC for web presentation (controllers and Thymeleaf templates) follows the classic Model-View-Controller separation.
- Layered Architecture – With distinct layers for presentation, application coordination, domain logic, and data access.
- MyBatis SQL Mapping – For data persistence with custom SQL queries, as seen in “ContractMapper.xml”, “EmployeeMapper.xml”, etc.

##### Relevant Technologies
- Java 11
- Spring Boot 2.x & Spring MVC
- Thymeleaf
- MyBatis SQL Mapper
- Gradle (for build and dependency management)
- CI/CD using CircleCI (from the .circleci configuration)

##### Final Advice
- Be very detailed in capturing the separation of concerns. While a high-level overview is useful, ensure each layer is represented and the main packages/components (as noted in the file tree) are clearly visible.

## Diagram (Mermaid)

```mermaid
flowchart TD
    HTTPRequest["HTTP Request"]:::external

    subgraph "Presentation Layer"
        Controllers["Controllers"]:::frontend
        Templates["Thymeleaf Templates"]:::frontend
    end

    subgraph "Application Layer"
        Coordinators["Coordinators"]:::application
        Services["Services"]:::application
        Repositories["Repositories"]:::application
    end

    subgraph "Domain Layer"
        DomainModels["Domain Models & Validation"]:::domain
    end

    subgraph "Infrastructure Layer"
        DataSources["Data Sources & Mappers"]:::infrastructure
        TransferObjects["Transfer Objects"]:::infrastructure
    end

    DB[(Database)]:::external

    subgraph "External Elements"
        SchemaSQL["Database Schema"]:::external
        DataSQL["Data Seed"]:::external
        MyBatisConfig["MyBatis Config"]:::external
        CICD["CI/CD Configuration"]:::external
        Procfile["Procfile"]:::external
        BuildGradle["build.gradle"]:::external
        SettingsGradle["settings.gradle"]:::external
        Gradlew["gradlew"]:::external
        GradlewBat["gradlew.bat"]:::external
    end

    %% Flow Connections
    HTTPRequest -->|"handles"| Controllers
    Controllers -->|"delegates"| Coordinators
    Controllers -->|"renders"| Templates
    Coordinators -->|"calls"| Services
    Coordinators -->|"uses"| Repositories
    Services -->|"invokes"| DomainModels
    Repositories -->|"persists_with"| DataSources
    DataSources -->|"maps_to"| TransferObjects
    TransferObjects -->|"populates"| DB

    %% Click Events for Frontend/Presentation Layer
    click Controllers "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/presentation/controller"
    click Templates "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/resources/templates"

    %% Click Events for Application Layer
    click Coordinators "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/application/coordinator"
    click Services "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/application/service"
    click Repositories "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/application/repository"

    %% Click Event for Domain Layer
    click DomainModels "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/domain"

    %% Click Events for Infrastructure Layer
    click DataSources "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/infrastructure/datasource"
    click TransferObjects "https://github.com/system-sekkei/isolating-the-domain/tree/master/src/main/java/example/infrastructure/transfer"

    %% Click Events for External Elements
    click SchemaSQL "https://github.com/system-sekkei/isolating-the-domain/blob/master/src/main/resources/schema.sql"
    click DataSQL "https://github.com/system-sekkei/isolating-the-domain/blob/master/src/main/resources/data.sql"
    click MyBatisConfig "https://github.com/system-sekkei/isolating-the-domain/blob/master/src/main/resources/mybatis.xml"
    click CICD "https://github.com/system-sekkei/isolating-the-domain/blob/master/.circleci/config.yml"
    click Procfile "https://github.com/system-sekkei/isolating-the-domain/tree/master/Procfile"
    click BuildGradle "https://github.com/system-sekkei/isolating-the-domain/blob/master/build.gradle"
    click SettingsGradle "https://github.com/system-sekkei/isolating-the-domain/blob/master/settings.gradle"
    click Gradlew "https://github.com/system-sekkei/isolating-the-domain/tree/master/gradlew"
    click GradlewBat "https://github.com/system-sekkei/isolating-the-domain/blob/master/gradlew.bat"

    %% Styles
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef application fill:#cfc,stroke:#333,stroke-width:2px;
    classDef domain fill:#fcc,stroke:#333,stroke-width:2px;
    classDef infrastructure fill:#fc9,stroke:#333,stroke-width:2px;
    classDef external fill:#ddd,stroke:#333,stroke-width:2px;
```
