# vincejv/gpon-stats-exporter architecture

> Architecture diagram of the GitHub repository vincejv/gpon-stats-exporter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vincejv/gpon-stats-exporter
- Repository: https://github.com/vincejv/gpon-stats-exporter

## Overview

GPON Parser selects an ONT-specific collector, periodically refreshes its cached data, and serves device, optical, combined, and health responses over HTTP. Telegraf can scrape the JSON endpoints for downstream InfluxDB and Grafana monitoring. Model adapters use different ONT web, JSON, or text interfaces; the sampled code shows several polling and parsing implementations, while README documents the supported models and API capabilities. Adapter internals not shown in excerpts are represented by their source files without inferred internal call chains.

Main entry points: [`gpon-parser.go`](https://github.com/vincejv/gpon-stats-exporter/blob/main/gpon-parser.go) (Startup and routing), [`device/an5506_stock.go`](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/an5506_stock.go) (AN5506 collector), [`svc/gpon.go`](https://github.com/vincejv/gpon-stats-exporter/blob/main/svc/gpon.go) (Stats API handlers), [`device/zltg202.go`](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zltg202.go) (ZLT G202 collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Exporter runtime"]
  node_main["Startup and routing<br/>[gpon-parser.go]"]
  node_poller["Scheduled polling<br/>[cron.go]"]
  node_api["Stats API handlers<br/>[gpon.go]"]
  node_health["Health handler<br/>[health.go]"]
end

subgraph group_collectors["ONT collectors"]
  node_an5506["AN5506 collector<br/>[an5506_stock.go]"]
  node_hg6245["HG6245D collector<br/>[hg6245d_globe.go]"]
  node_zte["ZTE F670 collector<br/>[zte_f670.go]"]
  node_zlt3000["ZLT G3000A collector<br/>[zltg3000a.go]"]
  node_zlt202["ZLT G202 collector<br/>[zltg202.go]"]
  node_skyworth["Skyworth collector<br/>[skyworth_gn.go]"]
  node_nokia["Nokia G010S collector<br/>[g010s.go]"]
end

subgraph group_shared["Shared data"]
  node_stats["Stats structures<br/>[stats.go]"]
  node_cache["Concurrent cache helpers<br/>[mutex.go]"]
  node_parsing["Parsing utilities<br/>[utils.go]"]
  node_telnet["Telnet utilities<br/>[telnet.go]"]
end

subgraph group_integrations["Monitoring integrations"]
  node_telegraf(("Telegraf scraper"))
  node_telegraf_docs["InfluxDB and Grafana"]
end

node_operator(("Operator"))
node_ont["ONT device"]

node_operator -->|"starts exporter"| node_main
node_main -->|"starts jobs"| node_poller
node_main -->|"registers routes"| node_api
node_main -->|"registers route"| node_health
node_main -->|"selects model"| node_an5506
node_main -->|"selects model"| node_hg6245
node_main -->|"selects model"| node_zte
node_main -->|"selects model"| node_zlt3000
node_main -->|"selects model"| node_zlt202
node_main -->|"selects model"| node_skyworth
node_main -->|"selects model"| node_nokia
node_poller -->|"polls through adapter"| node_ont
node_api -->|"returns JSON"| node_stats
node_api -->|"serves JSON endpoints"| node_telegraf
node_telegraf -->|"feeds monitoring"| node_telegraf_docs
node_an5506 -->|"fetches pages"| node_ont
node_hg6245 -->|"fetches page"| node_ont
node_nokia -->|"fetches script output"| node_ont
node_zlt202 -->|"fetches status"| node_ont
node_zlt3000 -->|"posts request"| node_ont
node_skyworth -->|"updates cache"| node_cache
node_an5506 -->|"stores pages"| node_cache
node_nokia -->|"stores output"| node_cache
node_zlt202 -->|"builds statistics"| node_stats
node_zte -->|"uses telnet helpers"| node_telnet
node_an5506 -->|"parses values"| node_parsing
node_skyworth -->|"converts values"| node_parsing
node_ont -.->|"provides stats"| node_api

click node_main "https://github.com/vincejv/gpon-stats-exporter/blob/main/gpon-parser.go"
click node_poller "https://github.com/vincejv/gpon-stats-exporter/blob/main/core/cron.go"
click node_api "https://github.com/vincejv/gpon-stats-exporter/blob/main/svc/gpon.go"
click node_health "https://github.com/vincejv/gpon-stats-exporter/blob/main/svc/health.go"
click node_an5506 "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/an5506_stock.go"
click node_hg6245 "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/hg6245d_globe.go"
click node_zte "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zte_f670.go"
click node_zlt3000 "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zltg3000a.go"
click node_zlt202 "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zltg202.go"
click node_skyworth "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/skyworth_gn.go"
click node_nokia "https://github.com/vincejv/gpon-stats-exporter/blob/main/device/g010s.go"
click node_stats "https://github.com/vincejv/gpon-stats-exporter/blob/main/model/stats.go"
click node_cache "https://github.com/vincejv/gpon-stats-exporter/blob/main/util/mutex.go"
click node_parsing "https://github.com/vincejv/gpon-stats-exporter/blob/main/util/utils.go"
click node_telnet "https://github.com/vincejv/gpon-stats-exporter/blob/main/util/telnet.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_main,node_poller,node_api,node_health toneBlue
class node_an5506,node_hg6245,node_zte,node_zlt3000,node_zlt202,node_skyworth,node_nokia toneAmber
class node_stats,node_cache,node_parsing,node_telnet toneMint
class node_telegraf,node_telegraf_docs toneRose
class node_operator,node_ont toneIndigo
```

## Components

### Exporter runtime

- [Startup and routing](https://github.com/vincejv/gpon-stats-exporter/blob/main/gpon-parser.go): `gpon-parser.go`
- [Scheduled polling](https://github.com/vincejv/gpon-stats-exporter/blob/main/core/cron.go): `core/cron.go`
- [Stats API handlers](https://github.com/vincejv/gpon-stats-exporter/blob/main/svc/gpon.go): `svc/gpon.go`
- [Health handler](https://github.com/vincejv/gpon-stats-exporter/blob/main/svc/health.go): `svc/health.go`

### ONT collectors

- [AN5506 collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/an5506_stock.go): `device/an5506_stock.go`
- [HG6245D collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/hg6245d_globe.go): `device/hg6245d_globe.go`
- [ZTE F670 collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zte_f670.go): `device/zte_f670.go`
- [ZLT G3000A collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zltg3000a.go): `device/zltg3000a.go`
- [ZLT G202 collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/zltg202.go): `device/zltg202.go`
- [Skyworth collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/skyworth_gn.go): `device/skyworth_gn.go`
- [Nokia G010S collector](https://github.com/vincejv/gpon-stats-exporter/blob/main/device/g010s.go): `device/g010s.go`

### Shared data

- [Stats structures](https://github.com/vincejv/gpon-stats-exporter/blob/main/model/stats.go): `model/stats.go`
- [Concurrent cache helpers](https://github.com/vincejv/gpon-stats-exporter/blob/main/util/mutex.go): `util/mutex.go`
- [Parsing utilities](https://github.com/vincejv/gpon-stats-exporter/blob/main/util/utils.go): `util/utils.go`
- [Telnet utilities](https://github.com/vincejv/gpon-stats-exporter/blob/main/util/telnet.go): `util/telnet.go`

### Monitoring integrations

- **Telegraf scraper**
- **InfluxDB and Grafana**

### Other components

- **Operator**
- **ONT device**

## Connections

- Operator → Startup and routing: starts exporter (evidence: `README.md`)
- Startup and routing → Scheduled polling: starts jobs (evidence: `gpon-parser.go`)
- Startup and routing → Stats API handlers: registers routes (evidence: `gpon-parser.go`)
- Startup and routing → Health handler: registers route (evidence: `gpon-parser.go`)
- Startup and routing → AN5506 collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → HG6245D collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → ZTE F670 collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → ZLT G3000A collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → ZLT G202 collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → Skyworth collector: selects model (evidence: `gpon-parser.go`)
- Startup and routing → Nokia G010S collector: selects model (evidence: `gpon-parser.go`)
- Scheduled polling → ONT device: polls through adapter (evidence: `core/cron.go`)
- Stats API handlers → Stats structures: returns JSON (evidence: `svc/gpon.go`)
- Stats API handlers → Telegraf scraper: serves JSON endpoints (evidence: `README.md`)
- Telegraf scraper → InfluxDB and Grafana: feeds monitoring (evidence: `README.md`)
- AN5506 collector → ONT device: fetches pages (evidence: `device/an5506_stock.go`)
- HG6245D collector → ONT device: fetches page (evidence: `device/hg6245d_globe.go`)
- Nokia G010S collector → ONT device: fetches script output (evidence: `device/g010s.go`)
- ZLT G202 collector → ONT device: fetches status (evidence: `device/zltg202.go`)
- ZLT G3000A collector → ONT device: posts request (evidence: `device/zltg3000a.go`)
- Skyworth collector → Concurrent cache helpers: updates cache (evidence: `device/skyworth_gn.go`)
- AN5506 collector → Concurrent cache helpers: stores pages (evidence: `device/an5506_stock.go`)
- Nokia G010S collector → Concurrent cache helpers: stores output (evidence: `device/g010s.go`)
- ZLT G202 collector → Stats structures: builds statistics (evidence: `device/zltg202.go`)
- ZTE F670 collector → Telnet utilities: uses telnet helpers (evidence: `device/zte_f670.go`)
- AN5506 collector → Parsing utilities: parses values (evidence: `device/an5506_stock.go`)
- Skyworth collector → Parsing utilities: converts values (evidence: `device/skyworth_gn.go`)
- ONT device → Stats API handlers: provides stats
