# herhu/nestjs-otel-prom-grafana-tempo architecture

> Architecture diagram of the GitHub repository herhu/nestjs-otel-prom-grafana-tempo, 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/herhu/nestjs-otel-prom-grafana-tempo
- Repository: https://github.com/herhu/nestjs-otel-prom-grafana-tempo

## Overview

##### Project Overview & Key Components
- Project Type: Containerized microservices with observability instrumentation.
- Main components:
- Microservices: “actor” and “movie” services (each with their own Dockerfiles, NestJS structure, logger modules, and instrumentation).
- Observability Stack Components:
- Prometheus: Metrics collection (see etc/prometheus.yaml).
- Grafana: Dashboard visualization (configured using data/grafana-data and dashboards JSON/YAML files).
- Tempo: Distributed tracing (configured in etc/tempo.yaml).
- Loki: Log aggregation (configured in etc/loki.yaml & etc/promtail-config.yaml).
- Additional Config: OpenTelemetry Collector (otel-collector.yaml) and Docker Compose configuration (docker-compose.yml) to wire up these containers.

##### Analyzing the File Structure
- The top-level directories separate service code (inside the “services” directory) from observability configurations (inside “etc” and “data” for Grafana).
- The “doc” directory provides additional, but secondary, supporting documentation.
- Both services (“actor” and “movie”) are structured similarly. Each contains an “src” directory with NestJS modules, controllers, services, and logger instrumentation.
- The “docker-compose.yml” suggests that all these components are containerized and orchestrated together.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestration Layer
    Compose["Docker Compose Orchestrator"]:::orchestration

    %% Microservices Layer
    subgraph "Microservices"
        Actor["Actor Service"]:::microservices
        Movie["Movie Service"]:::microservices
    end

    %% Observability Collection Layer
    subgraph "Observability Collection"
        Prom["Prometheus"]:::observability
        OTel["OTel Collector"]:::observability
        Promtail["Promtail"]:::observability
    end

    %% Observability Processing Layer
    subgraph "Observability Processing"
        Tempo["Tempo"]:::observability
        Loki["Loki"]:::observability
    end

    %% Visualization Layer
    Grafana["Grafana"]:::observability

    %% Orchestration connections
    Compose -->|"orchestrates"| Actor
    Compose -->|"orchestrates"| Movie
    Compose -->|"orchestrates"| Prom
    Compose -->|"orchestrates"| OTel
    Compose -->|"orchestrates"| Promtail
    Compose -->|"orchestrates"| Tempo
    Compose -->|"orchestrates"| Loki
    Compose -->|"orchestrates"| Grafana

    %% Microservices to Observability Collection
    Actor -->|"metrics"| Prom
    Actor -->|"traces"| OTel
    Actor -->|"logs"| Promtail

    Movie -->|"metrics"| Prom
    Movie -->|"traces"| OTel
    Movie -->|"logs"| Promtail

    %% Observability Collection to Processing
    Promtail -->|"for_logs"| Loki
    OTel -->|"process_traces"| Tempo

    %% Data flow to Visualization
    Prom -->|"feeds_metrics"| Grafana
    Tempo -->|"feeds_traces"| Grafana

    %% Styling definitions
    classDef microservices fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef observability fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef orchestration fill:#D5DBDB,stroke:#7D7D7D,stroke-width:2px;

    %% Click Events
    click Actor "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/tree/main/services/actor"
    click Movie "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/tree/main/services/movie"
    click Prom "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/etc/prometheus.yaml"
    click Grafana "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/tree/main/data/grafana-data"
    click Tempo "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/etc/tempo.yaml"
    click Loki "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/etc/loki.yaml"
    click Promtail "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/etc/promtail-config.yaml"
    click OTel "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/etc/otel-collector.yaml"
    click Compose "https://github.com/herhu/nestjs-otel-prom-grafana-tempo/blob/main/docker-compose.yml"
```
