# rigo85/internet-speed-monitor-ng architecture

> Architecture diagram of the GitHub repository rigo85/internet-speed-monitor-ng, 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/rigo85/internet-speed-monitor-ng
- Repository: https://github.com/rigo85/internet-speed-monitor-ng

## Overview

##### Project Type and Purpose
- The project is a desktop application built with an Angular frontend integrated with an Electron shell.
- It uses external speed test executables (from Ookla Speedtest) for both Linux and Windows platforms, and it features core business logic along with a data-persistence layer.
- The purpose is to provide a user interface (Angular) for monitoring internet speed, executing platform-specific speed tests (via core/ookla-speedtest), and storing/retrieving test history and settings (via the DB repositories in core/db).

##### Key Components and Their Directories
a. Frontend (Angular):
- Located under the “src” folder.
- Contains Angular components (e.g., in src/app/components for History, Main, Settings), services (like electron.service.ts), and configuration files (e.g., app.routes.ts, app.config.ts).
- This layer manages the UI, routing, and overall client-side logic.
b. Electron Integration:
- Found in “src-electron-app”, with files such as ElectronApp.ts, main.ts, preload.ts, browserWindowHelper.ts, etc.
- Acts as the bridge between the Angular frontend and native system resources, managing application windows and inter-process communication (IPC).
c. Core Business Logic and Data Handling:
- Located in the “core” directory. Here you have classes like OoklaSpeedTester.ts and Settings.ts that encapsulate the business logic.
- The “core/db” folder holds repositories and data access objects (AppDAO, SettingsRepository, and SpeedTestRepository) that abstract persistence operations.
d. External Executable Integrations:
- Under “core/ookla-speedtest”, there’s a separation between Linux and Windows executables (for example, speedtest on Linux and speedtest.exe on win32) along with their documentation files.
- These binaries represent an integration point to perform actual speed tests using native code.

##### Architectural Relationships and Interactions
- The Angular frontend communicates with the Electron backend using an electron service (likely via IPC) to offload system-level tasks.
- The Electron main process (and preload scripts) act as controllers to initiate tasks such as running a speed test.
- The core logic (e.g., OoklaSpeedTester) is called either directly via Electron or indirectly through services, executing external binaries based on the operating system.
- The DB repositories in the “core/db” layer are responsible for recording the test results and user settings, thereby enabling historical speed monitoring.

##### Elements
- Clear labels for each component (Angular Frontend, Electron Main Process, Core Logic, Database Repositories, External Speed Test Modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        A["Angular Frontend (UI)"]:::frontend
    end

    subgraph "Electron Layer"
        B["Electron Integration (Main/Preload)"]:::electron
    end

    subgraph "Core Layer"
        C["Core Business Logic"]:::core
        D["Database Repositories"]:::db
    end

    subgraph "External Modules"
        E["External Speed Test Modules (Linux/Windows)"]:::external
    end

    A -->|"IPC_Request"| B
    B -->|"Invoke_Core"| C
    C -->|"Run_Test"| E
    C -->|"PersistFetch_Data"| D
    D -->|"Return_Data"| A

    click A "https://github.com/rigo85/internet-speed-monitor-ng/tree/master/src"
    click B "https://github.com/rigo85/internet-speed-monitor-ng/tree/master/src-electron-app"
    click C "https://github.com/rigo85/internet-speed-monitor-ng/tree/master/core"
    click D "https://github.com/rigo85/internet-speed-monitor-ng/tree/master/core/db"
    click E "https://github.com/rigo85/internet-speed-monitor-ng/tree/master/core/ookla-speedtest"

    classDef frontend fill:#A8D5BA,stroke:#333,stroke-width:2px;
    classDef electron fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef core fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef db fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#333,stroke-width:2px;
```
