# jonathanmdr/resilience-http-client architecture

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

- Interactive diagram: https://gitdiagram.com/jonathanmdr/resilience-http-client
- Repository: https://github.com/jonathanmdr/resilience-http-client

## Overview

##### Main Components
- Order API Service:
- Found under the “order-api” directory.
- Exposes REST endpoints (via OrderController) for order operations and integrates with the authorization service (HTTP client integration, as shown in its “autorization/integration” packages).
- Contains controllers, persistence (via JPA repositories), use case configurations, and integration messaging for event publishing.

- Authorization API Service:
- Located under “authorization-api”.
- Provides endpoints for handling authorization requests (for both orders and feature toggling).
- Manages authorization persistence and includes exception handling, configuration (OpenAPI, logging, object mapper), and validation.

- Order Worker:
- Located in the “order-worker” module.
- Responsible for background processing—consuming and processing events related to order and authorization updates.
- Contains both order and authorization components including consumers (e.g., AuthorizationProcessedConsumer, AuthorizationProcessedDltConsumer) and access to persistence layers.

- Core Domain Module:
- Located in “domain”.
- Encapsulates core business logic, DDD patterns, domain events, entities, validation, and exception handling.
- Its concepts (such as Order, Authorization, Domain Events, Validators) are reused across APIs and the worker.

- Application Layer:
- Found in “application” (and related packages in each module).
- Contains the business use cases and input/output models that orchestrate interactions between the presentation/API layers and the domain layer.

- Infrastructure / Configurations:
- Migrations (under .migrations) for database schema setups for different domains (ecommerce, authorizations).
- Dockerfile, docker-compose.yaml, and Makefile which indicate containerized deployment and orchestration.
- .otel-dev directory and README details show inclusion of OpenTelemetry for observability and monitoring.

##### External and Supporting Systems
- Messaging System:

- Observability & Telemetry:
- OpenTelemetry components (agent, collector configurations) as external monitoring setups.
- Other tools such as Prometheus, Grafana, Jaeger (with ports mentioned in README) should be shown as external systems capturing metrics, logs, and traces.

- Databases:
- Although not explicitly named as “database”, the migrations and JPA-related packages indicate persistence layers. Create a generic “Database” component attached to each microservice where applicable.

##### Interactions and Dependencies
- That the Order Worker consumes messages/events (from Kafka) published either by the Order API or from internal event processing.
- That all services leverage a shared Domain layer, which serves as the core business logic provider.

##### Architectural Patterns and Design Principles
- DDD (Domain-Driven Design): The separation of domain, application, and infrastructure layers.
- API Gateway / Microservices Pattern: Different services (order-api, authorization-api, order-worker) work together through clear REST interfaces and messaging integrations.
- Resilience Patterns: While not all specific resilience mechanisms are drawn out in code, indications (such as “DefaultAuthorizeOrderUseCase” and explicit integration components) suggest use of fallback, retries, and circuit-breakers.

- Kafka as the messaging backbone between order-api and order-worker.
- Finally, include side panels or notes for development tools (docker-compose, Makefile) that hint at how the environment is managed and deployed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    APL["Application Layer"]:::application
    DOM["Core Domain Module"]:::domain
    OA["Order API Service"]:::microservice
    AA["Authorization API Service"]:::microservice
    OW["Order Worker"]:::microservice
    KAFKA["Kafka Messaging"]:::external
    DB["Database Persistence"]:::external
    OTEL["OpenTelemetry"]:::external
    PROM["Prometheus"]:::external
    JAEGER["Jaeger"]:::external
    GRAFANA["Grafana"]:::external
    INFRA["Infrastructure/Configurations"]:::infrastructure

    %% Core Business Layers
    APL --> DOM

    %% Microservices chain from Application Layer
    DOM --> OA
    OA --> AA
    AA --> OW

    %% Inter-service interactions
    OA -->|"HTTP_call"| AA
    OA -->|"publishes_event"| KAFKA
    KAFKA -->|"consumes_event"| OW

    %% Persistence connections
    OA -->|"persists"| DB
    AA -->|"persists"| DB
    OW -->|"persists"| DB

    %% Observability connections
    OA -->|"observability"| OTEL
    AA -->|"observability"| OTEL
    OW -->|"observability"| OTEL
    OTEL --> PROM
    PROM --> JAEGER
    JAEGER --> GRAFANA

    %% Infrastructure dotted links to external systems
    INFRA --- DB
    INFRA --- OTEL
    INFRA --- KAFKA

    %% Click Events for Component Mapping
    click OA "https://github.com/jonathanmdr/resilience-http-client/tree/main/order-api/src/main/java/com/resilience/orderapi"
    click AA "https://github.com/jonathanmdr/resilience-http-client/tree/main/authorization-api/src/main/java/com/resilience/authorizationapi"
    click OW "https://github.com/jonathanmdr/resilience-http-client/tree/main/order-worker/src/main/java/com/resilience/orderworker"
    click DOM "https://github.com/jonathanmdr/resilience-http-client/tree/main/domain/src/main/java/com/resilience/domain"
    click APL "https://github.com/jonathanmdr/resilience-http-client/tree/main/application/src/main/java/com/resilience/application"
    click INFRA "https://github.com/jonathanmdr/resilience-http-client/blob/main/docker-compose.yaml"

    %% Styles
    classDef microservice fill:#aqua,stroke:#000,stroke-width:2px,color:#000;
    classDef domain fill:#ffcccc,stroke:#000,stroke-width:2px,color:#000;
    classDef application fill:#ccffcc,stroke:#000,stroke-width:2px,color:#000;
    classDef external fill:#d1d1e0,stroke:#000,stroke-width:2px,color:#000;
    classDef infrastructure fill:#ffff99,stroke:#000,stroke-width:2px,color:#000;
```
