# mroject/freeswitch_exporter architecture

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

- Interactive diagram: https://gitdiagram.com/mroject/freeswitch_exporter
- Repository: https://github.com/mroject/freeswitch_exporter

## Overview

##### Project type and purpose
- This is a single‐binary, full‐stack “Exporter” microservice written in Go.
- Purpose: connect to a FreeSWITCH instance via its mod_event_socket API, collect telephony metrics, and expose them on HTTP (/metrics and /probe) for Prometheus to scrape.

##### File structure
- Top‐level Go files (main.go, collector.go) and go.mod/go.sum: core service code.
- Dockerfile + .github/workflows/docker-image.yml: CI/CD pipeline building and publishing a container image.
- systemd/ directory: local deployment as a systemd service.
- target/golist.json: auto‐generated dependency snapshot (not part of runtime).

##### README for additional insights
- Lists Prometheus flags, metrics collected, and the multi‐target “/probe” pattern.
- Mentions optional web.config YAML for TLS/basic‐auth support.
- Describes expected runtime interactions: exporter ⇄ FreeSWITCH, and Prometheus ⇄ exporter.

##### Essential elements in detail
- Both runtime and build/deployment flows (GitHub Actions → Docker image → container registry).
- Optional paths (e.g., loading web.config for TLS).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    subgraph "External Systems"
        FS["FreeSWITCH\n(mod_event_socket)"]:::external
        PROM["Prometheus Server"]:::external
    end

    %% Exporter Service
    subgraph "Exporter Service"
        subgraph "Configuration"
            Config["Config Loader\n(CLI flags + web.config)"]:::config
        end
        Collector["Collector Module"]:::internal
        PromClient["Prometheus Client Library\n& Metrics Registry"]:::internal
        HTTP["HTTP Server\n(/metrics & /probe)"]:::internal
    end

    %% Dependencies
    subgraph "Dependencies"
        GoMod["go.mod"]:::build
        GoSum["go.sum"]:::build
        GoList["target/golist.json"]:::build
    end

    %% Documentation
    subgraph "Project Documentation"
        README["README.md"]:::build
        License["LICENSE"]:::build
    end

    %% Deployment Artifacts
    subgraph "Deployment Artifacts"
        CI["GitHub Actions Workflow"]:::build
        DockerfileNode["Dockerfile"]:::build
        Container["Docker Image"]:::deployment
        SystemdSvc["systemd Unit\nfreeswitch_exporter.service"]:::deployment
        SystemdDoc["systemd README\nREADME.md"]:::deployment
    end

    %% Runtime Interactions
    Collector -->|"TCP Connection"| FS
    Collector -->|"Records metrics"| PromClient
    Config -->|provides settings| Collector
    Config -->|provides settings| HTTP
    PromClient -->|exposes metrics to| HTTP
    PROM -->|"Scrape /metrics or /probe"| HTTP

    %% Build & Deployment Flow
    CI -->|"builds image using"| DockerfileNode
    DockerfileNode -->|"produces"| Container
    Container -->|"runs"| HTTP
    SystemdSvc -->|"runs"| HTTP

    %% Dependencies & Docs Usage
    GoMod -->|"used by"| Collector
    GoSum -->|"used by"| Collector
    GoList -->|"dependency snapshot"| Collector
    README -->|"docs for"| HTTP
    License -->|"license for"| HTTP

    %% Click Events
    click Collector "https://github.com/mroject/freeswitch_exporter/blob/main/collector.go"
    click HTTP "https://github.com/mroject/freeswitch_exporter/blob/main/main.go"
    click Config "https://github.com/mroject/freeswitch_exporter/blob/main/main.go"
    click DockerfileNode "https://github.com/mroject/freeswitch_exporter/tree/main/Dockerfile"
    click CI "https://github.com/mroject/freeswitch_exporter/blob/main/.github/workflows/docker-image.yml"
    click SystemdSvc "https://github.com/mroject/freeswitch_exporter/blob/main/systemd/freeswitch_exporter.service"
    click SystemdDoc "https://github.com/mroject/freeswitch_exporter/blob/main/systemd/README.md"
    click GoMod "https://github.com/mroject/freeswitch_exporter/blob/main/go.mod"
    click GoSum "https://github.com/mroject/freeswitch_exporter/blob/main/go.sum"
    click GoList "https://github.com/mroject/freeswitch_exporter/blob/main/target/golist.json"
    click README "https://github.com/mroject/freeswitch_exporter/blob/main/README.md"
    click License "https://github.com/mroject/freeswitch_exporter/tree/main/LICENSE"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef internal fill:#bbf,stroke:#333,stroke-width:1px
    classDef config fill:#bfb,stroke:#333,stroke-width:1px
    classDef build fill:#fbf,stroke:#333,stroke-width:1px
    classDef deployment fill:#ffb,stroke:#333,stroke-width:1px
```
