# tushar1831/ntp-monitoring architecture

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

- Interactive diagram: https://gitdiagram.com/tushar1831/ntp-monitoring
- Repository: https://github.com/tushar1831/ntp-monitoring

## Overview

NTP Client Monitor polls configured time servers, measures offset and delay, optionally corrects the host clock, and publishes XML status and event history. Users can start it through the CLI or a Windows service; the desktop GUI configures and observes the service-owned monitor rather than polling independently. The graph includes configuration, protocol, clock, persistence, and desktop/service-control layers. Relationships are limited to those shown in excerpts or documented in the README; platform service behavior is represented at the adapter boundary.

Main entry points: [`ntp_client/monitor.py`](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/monitor.py) (Monitor cycle), [`ntp_client/desktop.py`](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/desktop.py) (Desktop adapter), [`main.py`](https://github.com/tushar1831/ntp-monitoring/blob/main/main.py) (CLI entry), [`ntp_client/xml_logger.py`](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/xml_logger.py) (XML writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and setup"]
  node_cli["CLI entry<br/>[main.py]"]
  node_config["Config validation<br/>[config.py]"]
end

subgraph group_monitoring["Time monitoring"]
  node_monitor["Monitor cycle<br/>[monitor.py]"]
  node_ntp_query["SNTP query<br/>[ntp_query.py]"]
  node_clock_setter["Clock setter<br/>[system_clock.py]"]
end

subgraph group_records["XML records"]
  node_xml_logger["XML writer<br/>[xml_logger.py]"]
  node_event_history["Event history XML"]
  node_status_snapshot["Status snapshot XML"]
end

subgraph group_desktop["Desktop and services"]
  node_gui["Desktop window<br/>[gui.py]"]
  node_desktop_adapter["Desktop adapter<br/>[desktop.py]"]
  node_win_service["Windows service<br/>[windows_service.py]"]
  node_service_manager["OS service manager"]
end

node_operator(("Operator"))
node_ntp_servers(("NTP servers"))
node_host_clock["System clock"]

node_operator -->|"runs"| node_cli
node_operator -->|"opens"| node_gui
node_cli -->|"loads"| node_config
node_cli -->|"starts"| node_monitor
node_win_service -->|"loads"| node_config
node_win_service -->|"starts"| node_monitor
node_gui -->|"reads and controls"| node_desktop_adapter
node_desktop_adapter -->|"controls"| node_service_manager
node_service_manager -.->|"manages"| node_win_service
node_monitor -->|"queries"| node_ntp_query
node_ntp_query -->|"sends UDP query"| node_ntp_servers
node_monitor -->|"requests correction"| node_clock_setter
node_clock_setter -->|"sets time"| node_host_clock
node_monitor -->|"records cycle"| node_xml_logger
node_xml_logger -->|"writes"| node_event_history
node_xml_logger -->|"replaces"| node_status_snapshot
node_desktop_adapter -->|"reads"| node_status_snapshot
node_desktop_adapter -->|"reads"| node_event_history

click node_cli "https://github.com/tushar1831/ntp-monitoring/blob/main/main.py"
click node_config "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/config.py"
click node_gui "https://github.com/tushar1831/ntp-monitoring/blob/main/gui.py"
click node_desktop_adapter "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/desktop.py"
click node_win_service "https://github.com/tushar1831/ntp-monitoring/blob/main/install/windows_service.py"
click node_monitor "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/monitor.py"
click node_ntp_query "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/ntp_query.py"
click node_clock_setter "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/system_clock.py"
click node_xml_logger "https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/xml_logger.py"

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_cli,node_config toneBlue
class node_monitor,node_ntp_query,node_clock_setter toneAmber
class node_xml_logger,node_event_history,node_status_snapshot,node_ntp_servers toneMint
class node_gui,node_desktop_adapter,node_win_service,node_service_manager toneRose
class node_operator,node_host_clock toneIndigo
```

## Components

### Entry and setup

- [CLI entry](https://github.com/tushar1831/ntp-monitoring/blob/main/main.py): `main.py`
- [Config validation](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/config.py): `ntp_client/config.py`

### Time monitoring

- [Monitor cycle](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/monitor.py): `ntp_client/monitor.py`
- [SNTP query](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/ntp_query.py): `ntp_client/ntp_query.py`
- [Clock setter](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/system_clock.py): `ntp_client/system_clock.py`

### XML records

- [XML writer](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/xml_logger.py): `ntp_client/xml_logger.py`
- **Event history XML**
- **Status snapshot XML**

### Desktop and services

- [Desktop window](https://github.com/tushar1831/ntp-monitoring/blob/main/gui.py): `gui.py`
- [Desktop adapter](https://github.com/tushar1831/ntp-monitoring/blob/main/ntp_client/desktop.py): `ntp_client/desktop.py`
- [Windows service](https://github.com/tushar1831/ntp-monitoring/blob/main/install/windows_service.py): `install/windows_service.py`
- **OS service manager**

### Other components

- **Operator**
- **NTP servers**
- **System clock**

## Connections

- Operator → CLI entry: runs (evidence: `README.md`)
- Operator → Desktop window: opens (evidence: `README.md`)
- CLI entry → Config validation: loads (evidence: `main.py`)
- CLI entry → Monitor cycle: starts (evidence: `main.py`)
- Windows service → Config validation: loads (evidence: `install/windows_service.py`)
- Windows service → Monitor cycle: starts (evidence: `install/windows_service.py`)
- Desktop window → Desktop adapter: reads and controls (evidence: `gui.py`)
- Desktop adapter → OS service manager: controls (evidence: `ntp_client/desktop.py`)
- OS service manager → Windows service: manages
- Monitor cycle → SNTP query: queries (evidence: `ntp_client/monitor.py`)
- SNTP query → NTP servers: sends UDP query (evidence: `ntp_client/ntp_query.py`)
- Monitor cycle → Clock setter: requests correction (evidence: `ntp_client/monitor.py`)
- Clock setter → System clock: sets time (evidence: `ntp_client/system_clock.py`)
- Monitor cycle → XML writer: records cycle (evidence: `ntp_client/monitor.py`)
- XML writer → Event history XML: writes (evidence: `README.md`)
- XML writer → Status snapshot XML: replaces (evidence: `README.md`)
- Desktop adapter → Status snapshot XML: reads (evidence: `ntp_client/desktop.py`)
- Desktop adapter → Event history XML: reads (evidence: `ntp_client/desktop.py`)
