# mekni-aymen/price-microservice architecture

> Architecture diagram of the GitHub repository mekni-aymen/price-microservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mekni-aymen/price-microservice
- Repository: https://github.com/mekni-aymen/price-microservice

## Overview

##### Project type and purpose
- This is a standalone Spring Boot microservice named “Intervista” that manages price data via a REST API.
- It follows a Hexagonal (Ports & Adapters) architecture to isolate business logic from I/O and make it easily testable and extensible.

##### File structure
- Top-level: a Maven project under `intervista/intervista` with standard `pom.xml`, wrapper scripts and `.mvn`.
- `src/main/java/com/example/intervista` contains three main layers:
- domain/model & domain/port
- application (use-case layer)
- infrastructure/adapters, which subdivides into:
– entities
– exception
– persistence (JPA adapters)
– rest (HTTP inbound adapter)
– conf (DataInitializer)
- `src/main/resources` holds `application.properties` (H2 DB config) and `data.sql`.
- Tests mirror the same layers under `src/test/java`.

##### README for additional insights
- It explicitly calls out Hexagonal architecture:
- domain (core business rules)
- application (use-cases)
- infrastructure (inbound and outbound adapters)
- The README even shows how adding MongoDB only requires changes in infrastructure (new Mongo adapters), leaving domain and application untouched.

##### Detail
- Classes by package but show each package as a separate component
- Configuration components (DataInitializer) and exception handlers
- Call out optional branches (Mongo) to demonstrate the extend-without-change benefit of Hexagonal

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["Client (HTTP)"]:::external

    %% Inbound Adapter
    subgraph "Inbound Adapter"
        PriceController["PriceController"]:::inbound
    end

    %% Application Layer
    subgraph "Application Layer"
        ManagerPrice["ManagerPrice"]:::application
    end

    %% Domain Layer
    subgraph "Domain Layer"
        PriceModel["PriceModel"]:::domain
        PriceRepository["PriceRepository (port)"]:::domain
    end

    %% Outbound Adapters & Databases
    subgraph "Outbound Adapters & Databases"
        JpaPriceRepository["JpaPriceRepository"]:::outbound
        SpringDataJpaPriceRepository["SpringDataJpaPriceRepository"]:::outbound
        PriceEntity["Price Entity"]:::outbound
        H2DB["H2 Database"]:::database
        subgraph "Optional MongoDB Adapter"
            MongodbPriceRepository["MongodbPriceRepository"]:::outbound
            SpringDataMongoPriceRepository["SpringDataMongoPriceRepository"]:::outbound
            MongoDB["MongoDB"]:::database
        end
    end

    %% Configuration & Exceptions
    subgraph "Configuration & Exceptions"
        DataInitializer["DataInitializer"]:::config
        ApplicationException["ApplicationException"]:::exception
        ParameterNotFoundException["ParameterNotFoundException"]:::exception
        PriceNotFoundException["PriceNotFoundException"]:::exception
        IntervistaApplication["IntervistaApplication"]:::config
        ApplicationProperties["application.properties"]:::resource
        DataSQL["data.sql"]:::resource
    end

    %% Data Flow
    Client -->|"HTTP Request"| PriceController
    PriceController -->|"calls"| ManagerPrice
    ManagerPrice -->|"uses port"| PriceRepository
    PriceRepository -->|"implemented by"| JpaPriceRepository
    JpaPriceRepository -->|"extends"| SpringDataJpaPriceRepository
    SpringDataJpaPriceRepository -->|"reads/writes"| H2DB
    PriceRepository -->|"implemented by"| MongodbPriceRepository
    MongodbPriceRepository -->|"extends"| SpringDataMongoPriceRepository
    SpringDataMongoPriceRepository -->|"reads/writes"| MongoDB
    DataInitializer -->|"seeds via port"| PriceRepository
    PriceController -->|"handles exceptions"| ApplicationException
    PriceController --> ApplicationException
    ApplicationException --> ParameterNotFoundException
    ApplicationException --> PriceNotFoundException

    %% Click Events
    click PriceController "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/rest/PriceController.java"
    click ManagerPrice "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/application/ManagerPrice.java"
    click PriceModel "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/domain/model/PriceModel.java"
    click PriceRepository "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/domain/port/PriceRepository.java"
    click JpaPriceRepository "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/persistance/JpaPriceRepository.java"
    click SpringDataJpaPriceRepository "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/persistance/SpringDataJpaPriceRepository.java"
    click PriceEntity "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/entities/Price.java"
    click ApplicationException "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/exception/ApplicationException.java"
    click ParameterNotFoundException "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/exception/ParameterNotFoundExcption.java"
    click PriceNotFoundException "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/infrastructure/exception/PriceNotFoundException.java"
    click IntervistaApplication "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/java/com/example/intervista/IntervistaApplication.java"
    click ApplicationProperties "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/resources/application.properties"
    click DataSQL "https://github.com/mekni-aymen/price-microservice/blob/main/intervista/intervista/src/main/resources/data.sql"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef inbound fill:#ccf,stroke:#333,stroke-width:1px
    classDef application fill:#cfc,stroke:#333,stroke-width:1px
    classDef domain fill:#cff,stroke:#333,stroke-width:1px
    classDef outbound fill:#ffc,stroke:#333,stroke-width:1px
    classDef database fill:#fcf,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef config fill:#eef,stroke:#333,stroke-width:1px
    classDef exception fill:#fee,stroke:#333,stroke-width:1px
    classDef resource fill:#eee,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
