# technik-tueftler/speedtest architecture

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

- Interactive diagram: https://gitdiagram.com/technik-tueftler/speedtest
- Repository: https://github.com/technik-tueftler/speedtest

## Overview

##### Main Components

a) Core Application Components:
- Network Load Monitor
- Fritzbox Speed Monitor
- Online Speedtest Service Connector
- Database Interface
- Timer Controller

b) External Systems:
- Fritzbox Router
- Speedtest.net Service
- Database System (Multiple options supported)

**┌─ Application Container (Docker) ─────────────────────────┐**

- ┌─ Core Application ─────────────────────┐             │

- ┌─ Timer Controller ─┐                │             │

- Main Timer     │                │             │
- Retry Timer    │                │             │
- ┘                │             │

- ┌─ Network Monitor ─┐                 │             │

- Load Checker   │                 │             │
- Threshold      │                 │             │
- Validator      │                 │             │
- ┘                 │             │

- ┌─ Speed Testers ───┐                 │             │

- Fritzbox      │                 │             │
- Monitor       │                 │             │
- Online Speed  │                 │             │
- Test         │                 │             │
- ┘                 │             │

- ┌─ Database Layer ──┐                 │             │

- Connection    │                 │             │
- Manager      │                 │             │
- Data Model   │                 │             │
- ┘                 │             │

- ┘             │

- ┘

##### Key Elements to Highlight

- Timer triggers → Network Monitor
- Network Monitor → Speed Testers
- Speed Testers → Database Layer
- Database Layer → External Database Systems

b) External Connections:
- Connection to Fritzbox (via IP/hostname)
- Connection to Speedtest.net
- Database connections (SQLite/MariaDB/PostgreSQL)

##### Important Details

a) Configuration Parameters:
- Network thresholds
- Timer intervals
- Database connection strings

b) Error Handling Paths:
- Network load check failures
- Speed test failures
- Database connection issues

##### Notes for Implementation

- The cyclical nature of the application (timer-based execution)
- The conditional execution based on network load
- The parallel execution of Fritzbox and online speed tests
- The flexibility in database connectivity
- The containerized nature of the application

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Container[Docker Container]
        subgraph CoreApp[Core Application]
            Timer[Timer Controller]:::core
            Network[Network Load Monitor]:::core
            SpeedTest[Speed Testers]:::core
            DB[Database Interface]:::core

            Timer --> Network
            Network --> SpeedTest
            SpeedTest --> DB
        end

        subgraph Config[Configuration]
            AppConfig[Application Config]:::config
            DockerConfig[Docker Settings]:::config
        end

        subgraph CI[CI/CD Pipeline]
            Build[Build Process]:::ci
            Quality[Code Quality]:::ci
        end
    end

    subgraph External[External Services]
        Fritz[Fritzbox Router]:::external
        SpeedTestNet[Speedtest.net]:::external
        Database[(Database System)]:::database
    end

    SpeedTest --> Fritz
    SpeedTest --> SpeedTestNet
    DB --> Database
    AppConfig --> CoreApp
    DockerConfig --> Container

    %% Component Mappings
    click DB "https://github.com/Technik-Tueftler/Speedtest/blob/main/source/db.py"
    click Timer "https://github.com/Technik-Tueftler/Speedtest/blob/main/source/main.py"
    click Network "https://github.com/Technik-Tueftler/Speedtest/blob/main/source/main.py"
    click SpeedTest "https://github.com/Technik-Tueftler/Speedtest/blob/main/source/main.py"
    click AppConfig "https://github.com/Technik-Tueftler/Speedtest/blob/main/files/config.cfg"
    click DockerConfig "https://github.com/Technik-Tueftler/Speedtest/tree/main/Dockerfile"
    click Build "https://github.com/Technik-Tueftler/Speedtest/blob/main/.github/workflows/build.yml"
    click Quality "https://github.com/Technik-Tueftler/Speedtest/blob/main/.github/workflows/pylint.yml"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef config fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#e74c3c,stroke:#c0392b,color:white
    classDef ci fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Configuration]:::config
        L3[External Services]:::external
        L4[(Database)]:::database
        L5[CI/CD]:::ci
    end
```
