# nawids/networkanalyzer architecture

> Architecture diagram of the GitHub repository nawids/networkanalyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nawids/networkanalyzer
- Repository: https://github.com/nawids/networkanalyzer

## Overview

Network Quality Monitor is a background service that periodically probes configured internet endpoints, persists quality measurements, evaluates alert thresholds, and serves a local dashboard. Its main workflow runs download, upload, and latency probes; stores the resulting metrics; and makes them available for charts and alerting. The README also documents endpoint rotation, retention, configuration reload, and graceful shutdown. The supplied tree omits the documented command and monitor packages, so their orchestration links are shown only where the README supports them; unsampled wiring is not inferred.

Main entry points: [`internal/config/config.go`](https://github.com/nawids/networkanalyzer/blob/master/internal/config/config.go) (Config loader), [`internal/engine/engine.go`](https://github.com/nawids/networkanalyzer/blob/master/internal/engine/engine.go) (Probe engine), [`internal/store/store.go`](https://github.com/nawids/networkanalyzer/blob/master/internal/store/store.go) (SQLite store), [`internal/alert/alert.go`](https://github.com/nawids/networkanalyzer/blob/master/internal/alert/alert.go) (Threshold evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_config_file["YAML settings"]
  node_config["Config loader<br/>[config.go]"]
  node_reload["Config reload"]
end

subgraph group_probe["Measurement"]
  node_scheduler["Probe scheduler"]
  node_engine["Probe engine<br/>[engine.go]"]
  node_calculations["Metric calculations<br/>[calc.go]"]
  node_models["Probe and alert models<br/>[types.go]"]
end

subgraph group_persistence["Persistence"]
  node_store["SQLite store<br/>[store.go]"]
  node_sqlite[("SQLite database")]
end

subgraph group_presentation["Dashboard"]
  node_dashboard["HTTP dashboard<br/>[dashboard.go]"]
  node_statistics["Statistics<br/>[stats.go]"]
end

subgraph group_notifications["Alerting"]
  node_alert_engine["Threshold evaluation<br/>[alert.go]"]
  node_notifier["Email notifier<br/>[notifier.go]"]
end

node_operator(("Operator"))
node_endpoints{{"Network endpoints"}}
node_latency_host{{"Latency target"}}
node_viewer(("Dashboard user"))
node_smtp{{"SMTP service"}}

node_operator -.->|"sets options"| node_config_file
node_config_file -->|"loads YAML"| node_config
node_config -.->|"configures"| node_scheduler
node_operator -->|"signals reload"| node_reload
node_reload -.->|"reloads settings"| node_config
node_scheduler -.->|"runs probes"| node_engine
node_config -->|"configures"| node_engine
node_engine -->|"measures speeds"| node_endpoints
node_engine -->|"dials TCP"| node_latency_host
node_engine -->|"computes metrics"| node_calculations
node_engine -->|"returns result"| node_models
node_scheduler -.->|"persists results"| node_store
node_store -->|"reads and writes"| node_sqlite
node_store -->|"maps results"| node_models
node_viewer -->|"requests dashboard"| node_dashboard
node_dashboard -->|"queries results"| node_store
node_dashboard -->|"computes stats"| node_statistics
node_statistics -->|"aggregates metrics"| node_models
node_scheduler -.->|"evaluates results"| node_alert_engine
node_config -->|"provides thresholds"| node_alert_engine
node_alert_engine -->|"builds alert"| node_models
node_alert_engine -->|"dispatches alert"| node_notifier
node_config -->|"provides SMTP settings"| node_notifier
node_notifier -->|"sends email"| node_smtp

click node_config_file "https://github.com/nawids/networkanalyzer/blob/master/config.example.yaml"
click node_config "https://github.com/nawids/networkanalyzer/blob/master/internal/config/config.go"
click node_engine "https://github.com/nawids/networkanalyzer/blob/master/internal/engine/engine.go"
click node_calculations "https://github.com/nawids/networkanalyzer/blob/master/internal/engine/calc.go"
click node_models "https://github.com/nawids/networkanalyzer/blob/master/internal/types/types.go"
click node_store "https://github.com/nawids/networkanalyzer/blob/master/internal/store/store.go"
click node_dashboard "https://github.com/nawids/networkanalyzer/blob/master/internal/dashboard/dashboard.go"
click node_statistics "https://github.com/nawids/networkanalyzer/blob/master/internal/dashboard/stats.go"
click node_alert_engine "https://github.com/nawids/networkanalyzer/blob/master/internal/alert/alert.go"
click node_notifier "https://github.com/nawids/networkanalyzer/blob/master/internal/alert/notifier.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config_file,node_config,node_reload,node_viewer toneBlue
class node_scheduler,node_engine,node_calculations,node_models toneAmber
class node_store,node_sqlite toneMint
class node_dashboard,node_statistics toneRose
class node_alert_engine,node_notifier,node_operator,node_endpoints,node_latency_host,node_smtp toneIndigo
```

## Components

### Configuration

- [YAML settings](https://github.com/nawids/networkanalyzer/blob/master/config.example.yaml): `config.example.yaml`
- [Config loader](https://github.com/nawids/networkanalyzer/blob/master/internal/config/config.go): `internal/config/config.go`
- **Config reload**

### Measurement

- **Probe scheduler**
- [Probe engine](https://github.com/nawids/networkanalyzer/blob/master/internal/engine/engine.go): `internal/engine/engine.go`
- [Metric calculations](https://github.com/nawids/networkanalyzer/blob/master/internal/engine/calc.go): `internal/engine/calc.go`
- [Probe and alert models](https://github.com/nawids/networkanalyzer/blob/master/internal/types/types.go): `internal/types/types.go`

### Persistence

- [SQLite store](https://github.com/nawids/networkanalyzer/blob/master/internal/store/store.go): `internal/store/store.go`
- **SQLite database**

### Dashboard

- [HTTP dashboard](https://github.com/nawids/networkanalyzer/blob/master/internal/dashboard/dashboard.go): `internal/dashboard/dashboard.go`
- [Statistics](https://github.com/nawids/networkanalyzer/blob/master/internal/dashboard/stats.go): `internal/dashboard/stats.go`

### Alerting

- [Threshold evaluation](https://github.com/nawids/networkanalyzer/blob/master/internal/alert/alert.go): `internal/alert/alert.go`
- [Email notifier](https://github.com/nawids/networkanalyzer/blob/master/internal/alert/notifier.go): `internal/alert/notifier.go`

### Other components

- **Operator**
- **Network endpoints**
- **Latency target**
- **Dashboard user**
- **SMTP service**

## Connections

- Operator → YAML settings: sets options (evidence: `README.md`)
- YAML settings → Config loader: loads YAML (evidence: `internal/config/config.go`)
- Config loader → Probe scheduler: configures (evidence: `README.md`)
- Operator → Config reload: signals reload (evidence: `README.md`)
- Config reload → Config loader: reloads settings (evidence: `README.md`)
- Probe scheduler → Probe engine: runs probes (evidence: `README.md`)
- Config loader → Probe engine: configures (evidence: `internal/engine/engine.go`)
- Probe engine → Network endpoints: measures speeds (evidence: `internal/engine/engine.go`)
- Probe engine → Latency target: dials TCP (evidence: `internal/engine/engine.go`)
- Probe engine → Metric calculations: computes metrics (evidence: `internal/engine/engine.go`)
- Probe engine → Probe and alert models: returns result (evidence: `internal/engine/engine.go`)
- Probe scheduler → SQLite store: persists results (evidence: `README.md`)
- SQLite store → SQLite database: reads and writes (evidence: `internal/store/store.go`)
- SQLite store → Probe and alert models: maps results (evidence: `internal/store/store.go`)
- Dashboard user → HTTP dashboard: requests dashboard (evidence: `README.md`)
- HTTP dashboard → SQLite store: queries results (evidence: `internal/dashboard/dashboard.go`)
- HTTP dashboard → Statistics: computes stats (evidence: `internal/dashboard/dashboard.go`)
- Statistics → Probe and alert models: aggregates metrics (evidence: `internal/dashboard/stats.go`)
- Probe scheduler → Threshold evaluation: evaluates results (evidence: `README.md`)
- Config loader → Threshold evaluation: provides thresholds (evidence: `internal/alert/alert.go`)
- Threshold evaluation → Probe and alert models: builds alert (evidence: `internal/alert/alert.go`)
- Threshold evaluation → Email notifier: dispatches alert (evidence: `internal/alert/alert.go`)
- Config loader → Email notifier: provides SMTP settings (evidence: `internal/alert/notifier.go`)
- Email notifier → SMTP service: sends email (evidence: `internal/alert/notifier.go`)
