# balmarcha/prices-itx-service architecture

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

- Interactive diagram: https://gitdiagram.com/balmarcha/prices-itx-service
- Repository: https://github.com/balmarcha/prices-itx-service

## Overview

##### Main Components
- External Systems/Resources: Include the H2 Database, Liquibase for DB migrations (using changelogs and CSV data files), and OpenAPI (for API documentation). Represent these external resources as separate components that are integrated through the infrastructure adapters.

##### Relationships and Data Flows
- Conversion between external request/response and application/domain objects by including mapper components (for converting between DBO and DTO, for instance).
- External data and configuration flows, such as Liquibase migrations feeding into the Database.

##### Architectural Patterns and Principles
- Hexagonal Architecture by visually centering the Domain and Application core, flanked by adapters on the periphery (for REST, persistence, etc.).
- Use of DDD by grouping each business concept into its bounded context (e.g., pricing, product, brand).
- That the use of Spring Boot and related frameworks (Spring Data JPA, OpenAPI) supports a modular and testable design.

##### Technologies and Frameworks
- For each adapter component (e.g., REST adapter), mention that it leverages Spring MVC/RestController and for persistence, that it uses Spring Data JPA.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Domain Layer
    subgraph "Domain Layer"
        D1["Entities & Value Objects"]:::domain
        D11["Price (Entity)"]:::domain
        D12["Brand (Entity)"]:::domain
        D13["Product (Entity)"]:::domain
        D14["PriceList (Entity)"]:::domain
        
        D2["Domain Exceptions"]:::domain
        D21["PriceNotFoundException"]:::domain
        
        D3["Domain Filters"]:::domain
        D31["PriceFilter"]:::domain
        D32["Common Filters"]:::domain
        
        D4["Ports/Interfaces"]:::domain
        D41["IPriceQueryPort"]:::domain
    end

    %% Application Layer
    subgraph "Application Layer"
        A1["PriceQueryUseCase"]:::application
        A2["Tests: PriceQueryUseCaseUnitTest"]:::test
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        I1["Entry Point: PricesItxApplication"]:::infrastructure
        
        subgraph "Adapters"
            I2["REST Controller: PriceQueryRest"]:::infrastructure
            I3["GlobalExceptionHandler"]:::infrastructure
            I4["JPA Adapter: PriceJpaQueryAdapter"]:::infrastructure
            I5["Repository: IPriceRepository"]:::infrastructure
            I6["Persistence Entity: PriceEntity"]:::infrastructure
            
            subgraph "Mappers"
                I7["IPriceDboMapper"]:::infrastructure
                I8["IPriceDtoMapper"]:::infrastructure
                I9["Brand Mapper"]:::infrastructure
                I10["PriceList Mapper"]:::infrastructure
                I11["Product Mapper"]:::infrastructure
            end
            
            I12["Filter Adapter: PriceFilterAdapter"]:::infrastructure
        end
        
        subgraph "Configurations"
            I13["application.yml"]:::infrastructure
            subgraph "Liquibase"
                I14["Changelog: 00.00.01.yml"]:::infrastructure
                I15["Master Changelog: liquibase-changelog.yml"]:::infrastructure
                I16["CSV Data Files"]:::infrastructure
            end
            I17["OpenAPI: api.yml"]:::infrastructure
        end
        
        subgraph "Tests"
            I18["PriceFilterAdapterUnitTest"]:::test
            I19["PriceJpaQueryAdapterUnitTest"]:::test
            I20["PriceQueryRest Tests"]:::test
        end
    end

    %% External Systems
    subgraph "External Systems"
        E1["H2 Database"]:::external
        E2["Liquibase Migration Tool"]:::external
        E3["OpenAPI Documentation"]:::external
    end

    %% Data Flow Connections
    %% REST flow: Infrastructure -> Application -> Domain
    I2 -->|"calls"| A1
    A1 -->|"uses"| D41
    %% Domain and Infrastructure port-adapter relationship (bidirectional dashed)
    D41 ---|"implements"| I4

    %% Mapper relationships within Infrastructure (used by JPA Adapter)
    I4 -->|"maps data"| I7
    I4 -->|"maps data"| I8

    %% Configuration and External Systems connections
    I13 -->|"configures"| E1
    I14 -->|"migrates"| E2
    I15 -->|"migrates"| E2
    I16 -->|"supplies data"| E2
    E2 -->|"feeds"| E1
    I17 -->|"defines API"| E3

    %% Testing annotations (not a runtime flow, just for reference)
    A1 --- I2
    I12 --> I4
    D31 --- D32

    %% Click Events for Domain Layer
    click D11 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/price/model/Price.java"
    click D12 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/brand/model/Brand.java"
    click D13 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/product/model/Product.java"
    click D14 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/pricelist/model/PriceList.java"
    click D21 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/price/exception/PriceNotFoundException.java"
    click D31 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/price/filter/PriceFilter.java"
    click D32 "https://github.com/balmarcha/prices-itx-service/tree/main/domain/src/main/java/es/bxg/ps/common/filter/"
    click D41 "https://github.com/balmarcha/prices-itx-service/blob/main/domain/src/main/java/es/bxg/ps/price/port/IPriceQueryPort.java"

    %% Click Events for Application Layer
    click A1 "https://github.com/balmarcha/prices-itx-service/blob/main/application/src/main/java/es/bxg/ps/price/usecase/PriceQueryUseCase.java"
    click A2 "https://github.com/balmarcha/prices-itx-service/blob/main/application/src/test/java/es/bxg/ps/PriceQueryUseCaseUnitTest.java"

    %% Click Events for Infrastructure Layer - Adapters
    click I1 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/PricesItxApplication.java"
    click I2 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/rest/PriceQueryRest.java"
    click I3 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/common/rest/GlobalExceptionHandler.java"
    click I4 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/jpa/PriceJpaQueryAdapter.java"
    click I5 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/repository/IPriceRepository.java"
    click I6 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/entity/PriceEntity.java"
    click I7 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/mapper/IPriceDboMapper.java"
    click I8 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/mapper/IPriceDtoMapper.java"
    click I9 "https://github.com/balmarcha/prices-itx-service/tree/main/infrastructure/src/main/java/es/bxg/ps/brand/adapters/mapper"
    click I10 "https://github.com/balmarcha/prices-itx-service/tree/main/infrastructure/src/main/java/es/bxg/ps/pricelist/adapters/mapper"
    click I11 "https://github.com/balmarcha/prices-itx-service/tree/main/infrastructure/src/main/java/es/bxg/ps/product/adapters/mapper"
    click I12 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/java/es/bxg/ps/price/adapters/filter/PriceFilterAdapter.java"
    
    %% Click Events for Infrastructure Layer - Configurations
    click I13 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/resources/application.yml"
    click I14 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/resources/bd/changelog/00.00.01.yml"
    click I15 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/resources/bd/liquibase-changelog.yml"
    click I16 "https://github.com/balmarcha/prices-itx-service/tree/main/infrastructure/src/main/resources/bd/data/"
    click I17 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/main/resources/openapi/api.yml"

    %% Click Events for Infrastructure Layer - Tests
    click I18 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/test/java/es/bxg/ps/price/adapters/filter/PriceFilterAdapterUnitTest.java"
    click I19 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/test/java/es/bxg/ps/price/adapters/jpa/PriceJpaQueryAdapterUnitTest.java"
    click I20 "https://github.com/balmarcha/prices-itx-service/blob/main/infrastructure/src/test/java/es/bxg/ps/price/rest/PriceQueryRestE2ETest.java"

    %% Styles
    classDef domain fill:#FFEECC,stroke:#AA5500,stroke-width:2px;
    classDef application fill:#CCEEFF,stroke:#0055AA,stroke-width:2px;
    classDef infrastructure fill:#EEFFCC,stroke:#55AA00,stroke-width:2px;
    classDef external fill:#FFCCCC,stroke:#AA0000,stroke-width:2px;
    classDef test fill:#EEEEEE,stroke:#888888,stroke-dasharray: 5 5,stroke-width:2px;
```
