# victorrentea/pact architecture

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

- Interactive diagram: https://gitdiagram.com/victorrentea/pact
- Repository: https://github.com/victorrentea/pact

## Overview

##### Project type and purpose
- This is a microservice-based demo application for a Consumer-Driven Contract Testing Workshop.
- It consists of three Spring-Boot microservices (catalog, order-history, product) that illustrate consumer-provider interactions using the Pact library.
- A Pact Broker (run in Docker via docker-compose.yaml) stores and shares contract definitions between services.

##### File structure
- Top-level modules (Maven multimodule project):
- catalog/ – a consumer service that calls the product API
- order-history/ – another consumer service calling the product API
- product/ – the provider service exposing the product API
- Each module has:
- src/main/java for application code (e.g. CatalogApp.java, OrderHistoryApp.java, ProductApp.java)
- src/test/java for Pact tests (consumer tests in catalog & order-history; provider verification tests in product)
- application.properties to configure base URLs, ports, and Pact settings
- Root docker-compose.yaml defines a Pact Broker service on port 9292
- run-all.bat orchestrates startup of all services and test execution

##### README
- Describes starting the Pact Broker via Docker Compose
- Instructs how to publish consumer pacts (`mvn pact:publish`)
- Shows how the provider verifies pacts from the broker (`mvn verify -Dpact.verifier.publishResults=true ...`)
- Emphasizes the broker UI at http://localhost:9292/

##### Elements
- Clear labels on each service/component (Catalog, Order-History, Product, Pact Broker, CI/CD)
- runtime data flow (consumer → provider)
- contract flow (consumer tests → broker → provider tests)
- Ports and endpoints (e.g., /products) to give context
- Annotations for “Maven multimodule project” and “Docker Compose”

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Runtime Interaction"
        Catalog["Catalog Service\n(port 8080)"]:::micro
        OrderHistory["Order-History Service\n(port 8081)"]:::micro
        Product["Product Service\n(port 8082)"]:::micro
        Catalog -->|"HTTP REST calls /products"| Product
        OrderHistory -->|"HTTP REST calls /products"| Product
    end

    subgraph "Contract Testing Pipeline"
        ConsumerCatalogTests["Catalog Consumer Tests"]:::test
        ConsumerOrderTests["Order-History Consumer Tests"]:::test
        PactBroker["Pact Broker\n(port 9292)"]:::broker
        ProviderTests["Product Provider Verification Tests"]:::test
        ConsumerCatalogTests -->|"publish pacts"| PactBroker
        ConsumerOrderTests -->|"publish pacts"| PactBroker
        PactBroker -->|"fetch & verify pacts"| ProviderTests
        ProviderTests -->|"publish results"| PactBroker
    end

    subgraph "Infrastructure / CI"
        DockerCompose["docker-compose.yaml"]:::infra
        RunAll["run-all.bat"]:::infra
        MavenPom["pom.xml"]:::infra
        DockerCompose --> PactBroker
        RunAll --> ConsumerCatalogTests
        RunAll --> ConsumerOrderTests
        RunAll --> ProviderTests
        RunAll --> DockerCompose
        MavenPom --> Catalog
        MavenPom --> OrderHistory
        MavenPom --> Product
    end

    click Catalog "https://github.com/victorrentea/pact/blob/master/catalog/src/main/java/victor/training/pact/consumer/CatalogApp.java"
    click OrderHistory "https://github.com/victorrentea/pact/blob/master/order-history/src/main/java/victor/training/pact/consumer/OrderHistoryApp.java"
    click Product "https://github.com/victorrentea/pact/blob/master/product/src/main/java/victor/training/pact/provider/ProductApp.java"
    click ConsumerCatalogTests "https://github.com/victorrentea/pact/blob/master/catalog/src/test/java/victor/training/pact/consumer/Catalog_Product_PactTest.java"
    click ConsumerCatalogTests "https://github.com/victorrentea/pact/blob/master/catalog/src/test/java/victor/training/pact/consumer/Catalog_ProductAsync_PactTest.java"
    click ConsumerOrderTests "https://github.com/victorrentea/pact/blob/master/order-history/src/test/java/victor/training/pact/consumer/OrderHistory_Product_PactTest.java"
    click ProviderTests "https://github.com/victorrentea/pact/blob/master/product/src/test/java/victor/training/pact/provider/Product_PactVerificationTest.java"
    click ProviderTests "https://github.com/victorrentea/pact/blob/master/product/src/test/java/victor/training/pact/provider/ProductAsync_PactVerificationTest.java"
    click DockerCompose "https://github.com/victorrentea/pact/blob/master/docker-compose.yaml"
    click RunAll "https://github.com/victorrentea/pact/blob/master/run-all.bat"
    click MavenPom "https://github.com/victorrentea/pact/blob/master/pom.xml"
    click Catalog "https://github.com/victorrentea/pact/blob/master/catalog/src/main/resources/application.properties"
    click OrderHistory "https://github.com/victorrentea/pact/blob/master/order-history/src/main/resources/application.properties"
    click Product "https://github.com/victorrentea/pact/blob/master/product/src/main/resources/application.properties"

    classDef micro fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef broker fill:#FFA500,stroke:#000,stroke-width:1px
    classDef test fill:#90EE90,stroke:#000,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px
```
