# dorian-frances/df-java-template architecture

> Architecture diagram of the GitHub repository dorian-frances/df-java-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dorian-frances/df-java-template
- Repository: https://github.com/dorian-frances/df-java-template

## Overview

##### Main Components

a) Core Components:
- Domain Layer (Central Hexagon)
- Application Layer (Primary/Driving Adapters)
- Infrastructure Layer (Secondary/Driven Adapters)
- Bootstrap Layer (Application Configuration)

b) Technical Components:
- REST API Interface
- PostgreSQL Database
- Spring Boot Framework
- Liquibase Migration System

**[External Layer]**
- REST API Adapter (Primary)
- PostgreSQL Adapter (Secondary)

**[Domain Layer (Core Hexagon)]**
- User Service
- Domain Models
- Port Interfaces

**[Infrastructure Layer]**
- Database Configuration
- Entity Mappings
- Repositories

**[Bootstrap Layer]**
- Application Configuration
- Dependency Injection

##### Key Relationships to Highlight

a) Port Interfaces:

b) Data Flow:
- REST API requests flow through controllers to domain services
- Database interactions from domain through storage ports

##### Specific Implementation Details

- UserController → UserFacade → UserService → UserStoragePort → PostgresUserAdapter
- Error handling flow through DfExceptionMapper
- Liquibase migration connection to PostgreSQL
- Spring Boot's configuration management

##### Additional Elements

Supporting components:
- Test containers for integration testing
- CircleCI pipeline connection
- Contract-first API generation flow
- Error handling pathways

##### How the bootstrap module orchestrates all components

Remember to maintain a balance between detail and clarity, focusing on the architectural decisions while avoiding implementation-specific details that don't contribute to understanding the system's structure.

- How the application implements hexagonal architecture
- The flow of data through the system
- Where to add new features or adapters
- How testing fits into the architecture
- The role of each technical component

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef domain fill:#FFD700,stroke:#333,stroke-width:2px
    classDef application fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#90EE90,stroke:#333,stroke-width:2px
    classDef bootstrap fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef port fill:#FFFFFF,stroke:#333,stroke-width:2px
    classDef technical fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% External Systems
    subgraph External["External Systems"]
        Client["Client Applications"]
        DB[(PostgreSQL Database)]
    end

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        Controller["User Controller"]
        ExMapper["DF Exception Mapper"]
        UserMapper["User Mapper"]
    end

    %% Domain Layer
    subgraph DomainLayer["Domain Layer"]
        UserModel["User Model"]
        UserService["User Service"]
        subgraph Ports["Ports"]
            InPort["User Facade"]
            OutPort["User Storage Port"]
        end
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        PostgresAdapter["Postgres User Adapter"]
        UserEntity["User Entity"]
        UserRepo["User Repository"]
        DBConfig["Database Config"]
        Liquibase["Liquibase Migrations"]
    end

    %% Bootstrap Layer
    subgraph BootLayer["Bootstrap Layer"]
        MainApp["Main Application"]
        DomainConfig["Domain Config"]
        RestConfig["REST Config"]
        MainConfig["Main Config"]
    end

    %% Relationships
    Client --> Controller
    Controller --> InPort
    InPort --> UserService
    UserService --> OutPort
    OutPort --> PostgresAdapter
    PostgresAdapter --> UserRepo
    UserRepo --> DB
    Liquibase --> DB
    
    %% Additional Connections
    Controller --> ExMapper
    Controller --> UserMapper
    UserMapper --> UserModel
    PostgresAdapter --> UserEntity

    %% Click Events
    click UserModel "https://github.com/dorian-frances/df-java-template/blob/main/domain/src/main/java/io/df/java/template/domain/model/User.java"
    click InPort "https://github.com/dorian-frances/df-java-template/blob/main/domain/src/main/java/io/df/java/template/domain/port/in/UserFacade.java"
    click OutPort "https://github.com/dorian-frances/df-java-template/blob/main/domain/src/main/java/io/df/java/template/domain/port/out/UserStoragePort.java"
    click UserService "https://github.com/dorian-frances/df-java-template/blob/main/domain/src/main/java/io/df/java/template/domain/service/UserService.java"
    click Controller "https://github.com/dorian-frances/df-java-template/blob/main/application/rest-api-adapter/src/main/java/io/df/java/template/application/rest/api/adapter/controller/UserController.java"
    click ExMapper "https://github.com/dorian-frances/df-java-template/blob/main/application/rest-api-adapter/src/main/java/io/df/java/template/application/rest/api/adapter/mapper/DfExceptionMapper.java"
    click UserMapper "https://github.com/dorian-frances/df-java-template/blob/main/application/rest-api-adapter/src/main/java/io/df/java/template/application/rest/api/adapter/mapper/UserMapper.java"
    click PostgresAdapter "https://github.com/dorian-frances/df-java-template/blob/main/infrastructure/postgres-adapter/src/main/java/io/df/java/template/infrastructure/postgres/adapter/PostgresUserAdapter.java"
    click UserEntity "https://github.com/dorian-frances/df-java-template/blob/main/infrastructure/postgres-adapter/src/main/java/io/df/java/template/infrastructure/postgres/entity/UserEntity.java"
    click UserRepo "https://github.com/dorian-frances/df-java-template/blob/main/infrastructure/postgres-adapter/src/main/java/io/df/java/template/infrastructure/postgres/repository/UserRepository.java"
    click DBConfig "https://github.com/dorian-frances/df-java-template/blob/main/infrastructure/postgres-adapter/src/main/java/io/df/java/template/infrastructure/postgres/configuration/PostgresConfiguration.java"
    click MainApp "https://github.com/dorian-frances/df-java-template/blob/main/bootstrap/src/main/java/io/df/java/template/bootstrap/DfJavaTemplateApplication.java"
    click DomainConfig "https://github.com/dorian-frances/df-java-template/blob/main/bootstrap/src/main/java/io/df/java/template/bootstrap/configuration/DomainConfiguration.java"
    click RestConfig "https://github.com/dorian-frances/df-java-template/blob/main/bootstrap/src/main/java/io/df/java/template/bootstrap/configuration/RestApiConfiguration.java"
    click MainConfig "https://github.com/dorian-frances/df-java-template/blob/main/bootstrap/src/main/java/io/df/java/template/bootstrap/configuration/DfJavaTemplateConfiguration.java"
    click Liquibase "https://github.com/dorian-frances/df-java-template/blob/main/infrastructure/postgres-adapter/src/main/resources/db.changelog/db.changelog-master.yaml"

    %% Style Applications
    class UserModel,UserService domain
    class Controller,ExMapper,UserMapper application
    class PostgresAdapter,UserEntity,UserRepo,DBConfig,Liquibase infrastructure
    class MainApp,DomainConfig,RestConfig,MainConfig bootstrap
    class InPort,OutPort port
```
