# am-kantox/telemetria architecture

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

- Interactive diagram: https://gitdiagram.com/am-kantox/telemetria
- Repository: https://github.com/am-kantox/telemetria

## Overview

##### Main Components

a) Core Components:
- Telemetria Application Core
- Module Hooks System
- Backend System
- Messenger System
- Compiler Integration
- Throttler

b) External Integrations:
- OpenTelemetry
- Telemetry
- Slack
- Logger

**Top Layer (Entry Points):**
- Compiler Integration (@telemetria annotations)
- Mix Tasks
- Configuration Provider

**Middle Layer (Core Processing):**
- Module Hooks
- Application Core
- Throttler
- Formatter

**Bottom Layer (Output/Storage):**
- Backend System
- OpenTelemetry Backend
- Telemetry Backend
- Logger Backend
- Messenger System
- Slack Integration
- Logger Integration

##### Key Relationships to Highlight

- How the compiler integration (`mix compiler.telemetria`) processes module annotations
- Flow from module hooks to the backend system
- Demonstrate how the throttler interfaces with the event flow
- Relationship between backends and external services

##### Important Details

- Configuration flow from `.telemetria.config.json`
- Event flow paths
- Instrumentation points
- Backend selection/routing
- Throttling decision points

##### Specific Implementation Notes

- The compile-time integration through Mix compiler
- Runtime event handling and processing
- Multiple backend support
- Messaging system flexibility
- Throttling capabilities
- OpenTelemetry integration

- Compile Time   | --> | Runtime Core    | --> | Output Systems |

- Annotations  |     | - Module Hooks  |     | - Backends    |
- Mix Tasks    |     | - Throttling    |     | - Messengers  |
- Config       |     | - Processing    |     | - External    |

##### Technical Details to Highlight

- Support for different event types
- Integration with existing Elixir applications
- Configuration options and customization points
- Backend abstraction layer
- Messaging system flexibility

Remember to include version compatibility information and note the support for both synchronous and asynchronous operations where applicable.

This system design should help developers understand how Telemetría integrates with their applications and how it processes and routes telemetry data through various backends and messaging systems.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef entry fill:#f1c40f,stroke:#f39c12,color:black
    classDef process fill:#e67e22,stroke:#d35400,color:white
    classDef output fill:#9b59b6,stroke:#8e44ad,color:white
    
    %% Entry Points Layer
    subgraph Entry
        CI["Compiler Integration"]:::entry
        MT["Mix Tasks"]:::entry
        CP["Configuration Provider"]:::entry
    end
    
    %% Core Processing Layer
    subgraph Core
        AC["Application Core"]:::core
        MH["Module Hooks"]:::core
        TH["Throttler"]:::core
        FM["Formatter"]:::core
        EH["Error Handler"]:::core
    end
    
    %% Backend System Layer
    subgraph Backends
        BS["Backend System"]:::output
        OTB["OpenTelemetry Backend"]:::output
        TB["Telemetry Backend"]:::output
        TH_H["Telemetry Handler"]:::output
        TH_P["Telemetry Polling"]:::output
    end
    
    %% Messenger System Layer
    subgraph Messengers
        MS["Messenger System"]:::output
        SI["Slack Integration"]:::output
        LI["Logger Integration"]:::output
    end
    
    %% External Services
    subgraph External
        OT["OpenTelemetry"]:::external
        TM["Telemetry"]:::external
        SL["Slack"]:::external
        LG["Logger"]:::external
    end
    
    %% Relationships
    CI --> AC
    MT --> AC
    CP --> AC
    
    AC --> MH
    AC --> TH
    AC --> FM
    AC --> EH
    
    MH --> BS
    TH --> BS
    
    BS --> OTB
    BS --> TB
    TB --> TH_H
    TB --> TH_P
    
    BS --> MS
    MS --> SI
    MS --> LI
    
    OTB --> OT
    TB --> TM
    SI --> SL
    LI --> LG
    
    %% Click Events
    click CI "https://github.com/am-kantox/telemetria/blob/master/lib/mix/tasks/compile/telemetria.ex"
    click CP "https://github.com/am-kantox/telemetria/blob/master/lib/mix/config_provider.ex"
    click AC "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/application.ex"
    click MH "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/module_hooks.ex"
    click TH "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/throttler.ex"
    click FM "https://github.com/am-kantox/telemetria/blob/master/lib/formatter.ex"
    click EH "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/error.ex"
    click BS "https://github.com/am-kantox/telemetria/tree/master/lib/telemetria/backend/"
    click OTB "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/backend/open_telemetry.ex"
    click TB "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/backend/telemetry.ex"
    click TH_H "https://github.com/am-kantox/telemetria/tree/master/lib/telemetria/backend/helpers/telemetry/handler/"
    click TH_P "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/backend/helpers/telemetry/polling.ex"
    click MS "https://github.com/am-kantox/telemetria/tree/master/lib/telemetria/messenger/"
    click SI "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/messenger/slack.ex"
    click LI "https://github.com/am-kantox/telemetria/blob/master/lib/telemetria/messenger/logger.ex"
```
