# watlas/spring-advanced-observability-demo architecture

> Architecture diagram of the GitHub repository watlas/spring-advanced-observability-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/watlas/spring-advanced-observability-demo
- Repository: https://github.com/watlas/spring-advanced-observability-demo

## Overview

##### Main Components
- Microservices:
- Order Service – handles order-related API endpoints and logic.
- Product Service – includes Kafka configuration and listens to product events.
- User Service – handles user-related operations.
- Observability & Monitoring Components:
- Logging Infrastructure: Elasticsearch, Logstash, Kibana, Filebeat, and Fleet.
- Metrics and Monitoring: Prometheus, Metricbeat, Heartbeat, Grafana.
- Tracing Systems: Jaeger, Zipkin, OpenTelemetry Collector.
- Additional Graphing / Log Aggregation: Loki and Tempo.
- Supporting Components:
- Docker Compose orchestrator: Under the docker directory, containing multi-container setups for all the systems.
- Database / Data Sources: MongoDB (with Mongo Express) and possibly PostgreSQL (as hinted by the badges). Although the services use Spring Boot, check if they are interacting with a specific database.
- External Dependencies: Kafka and Zookeeper for messaging patterns.

##### Relationships and Interactions
- The three Spring Boot microservices interact through REST APIs and, in the case of the product-service, likely communicate via Kafka.
- Each service outputs logs, metrics, and traces that are collected by the observability stack. They feed data to the ELK stack for logging, Prometheus for metrics, and distributed tracing tools (Jaeger/Zipkin/OpenTelemetry Collector) for tracing.
- Docker Compose is used to tie together these components, so illustrate the orchestration layer that manages both the microservices and the various observability tools.
- The data flow should indicate that the microservices push monitoring data (logs, metrics, traces) to the respective backend (e.g., Filebeat shipping to Logstash/Elasticsearch, metrics to Prometheus, traces to Jaeger/Zipkin).

##### Architectural Patterns and Design Principles
- Microservices pattern: Each core service (order, product, user) is packaged separately with its own Dockerfile and Maven build configuration, following the separation of concerns.
- Observability as a first-class citizen: Integration of multiple observability tools denotes an architecture that emphasizes advanced monitoring, tracing, and logging.
- Containerization and orchestration: Docker Compose is used to manage the stack, indicating a containerized ecosystem.
- Event-driven architecture: The Kafka integration in product-service suggests that some communications might be asynchronous/event-driven.

##### Relevant Technologies
- Programming framework: Spring Boot (Java) with Maven as the build tool.
- Containerization: Docker and Docker Compose.
- Observability stack: Elasticsearch, Logstash, Kibana, Filebeat, Fleet for logging; Prometheus, Metricbeat, Heartbeat for metrics; Jaeger, Zipkin, OpenTelemetry Collector for tracing; Grafana for dashboards; Loki and Tempo for additional log and trace analytics.
- Messaging: Apache Kafka (supported by Zookeeper).

- Use clear, descriptive labels for every component. For example, label “Order Service (Spring Boot)” and “Kafka Broker” rather than generic names.
- From the Services to the Logging systems.
- From the Services to the Metrics and Tracing infrastructure.
- Between services if there is inter-service communication.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Microservices Layer
    subgraph "Microservices Layer"
        OS["Order Service (Spring Boot)"]:::microservices
        PS["Product Service (Spring Boot)"]:::microservices
        US["User Service (Spring Boot)"]:::microservices
        PKC["Kafka Config"]:::microservices
        %% Define inter-service API arrows (if needed)
    end

    %% Observability & Monitoring Layer
    subgraph "Logging Infrastructure"
        FB["Filebeat"]:::observability
        LS["Logstash"]:::observability
        ES["Elasticsearch"]:::observability
        KB["Kibana"]:::observability
        FL["Fleet"]:::observability
    end

    subgraph "Metrics Infrastructure"
        PM["Prometheus"]:::metrics
        MB["Metricbeat"]:::metrics
        HB["Heartbeat"]:::metrics
        GF["Grafana"]:::metrics
    end

    subgraph "Tracing Infrastructure"
        JG["Jaeger"]:::tracing
        ZP["Zipkin"]:::tracing
        OTC["OpenTelemetry Collector"]:::tracing
        LK["Loki"]:::tracing
        TP["Tempo"]:::tracing
    end

    %% External Systems & Infrastructure
    subgraph "External & Infrastructure"
        DCompose["Docker Compose"]:::infrastructure
        KBRO["Kafka Broker"]:::external
        Zoo["Zookeeper"]:::external
        MDB["MongoDB/Mongo Express"]:::external
    end

    %% Data flows from Microservices to Observability
    OS -->|"logs"| FB
    PS -->|"logs"| FB
    US -->|"logs"| FB

    OS -->|"metrics"| PM
    PS -->|"metrics"| PM
    US -->|"metrics"| PM

    OS -->|"traces"| OTC
    PS -->|"traces"| OTC
    US -->|"traces"| OTC

    %% Internal Logging Pipeline
    FB -->|"forwards"| LS
    LS -->|"stores"| ES
    LS -->|"visualizes"| KB
    FB -->|"ships"| FL

    %% Metrics Pipeline
    MB -->|"collects"| PM
    HB -->|"collects"| PM
    PM -->|"dashboards"| GF

    %% Tracing Pipeline
    OTC -->|"processes"| JG
    OTC -->|"processes"| ZP
    OTC -->|"sends"| LK
    OTC -->|"sends"| TP

    %% Product Service Kafka integration
    PS -->|"configures"| PKC
    PKC -->|"publishes"| KBRO

    %% External Dependencies Interactions
    KBRO -->|"coords with"| Zoo
    OS ---|"DB access"| MDB
    PS ---|"DB access"| MDB
    US ---|"DB access"| MDB

    %% Docker Compose orchestrates containers
    DCompose --- OS
    DCompose --- PS
    DCompose --- US
    DCompose --- FB
    DCompose --- PM
    DCompose --- OTC
    DCompose --- KBRO
    DCompose --- MDB

    %% Styles
    classDef microservices fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef observability fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef metrics fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef tracing fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef infrastructure fill:#F5CBA7,stroke:#A04000,stroke-width:2px;
    classDef external fill:#D5DBDB,stroke:#566573,stroke-width:2px;

    %% Click Events
    click OS "https://github.com/watlas/spring-advanced-observability-demo/tree/master/order-service/"
    click PS "https://github.com/watlas/spring-advanced-observability-demo/tree/master/product-service/"
    click PKC "https://github.com/watlas/spring-advanced-observability-demo/blob/master/product-service/src/main/java/br/com/watlas/productservice/configuration/KafkaConfiguration.java"
    click US "https://github.com/watlas/spring-advanced-observability-demo/tree/master/user-service/"
    click ES "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/elasticsearch/"
    click LS "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/logstash/"
    click KB "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/kibana/"
    click FB "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/filebeat/"
    click FL "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/fleet/"
    click PM "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/prometheus/"
    click MB "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/metricbeat/"
    click HB "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/heartbeat/"
    click GF "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/grafana/"
    click LK "https://github.com/watlas/spring-advanced-observability-demo/blob/master/docker/loki/loki.yml"
    click TP "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/tempo/"
    click OTC "https://github.com/watlas/spring-advanced-observability-demo/blob/master/docker/collector/otel-collector.yml"
    click DCompose "https://github.com/watlas/spring-advanced-observability-demo/blob/master/docker/docker-compose.yml"
    click MDB "https://github.com/watlas/spring-advanced-observability-demo/tree/master/docker/mongo/"
```
