# mmarkin/gps-ntp-timeserver architecture

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

- Interactive diagram: https://gitdiagram.com/mmarkin/gps-ntp-timeserver
- Repository: https://github.com/mmarkin/gps-ntp-timeserver

## Overview

This is an ESP8266 Wi-Fi access-point NTP server that derives time from GPS, falls back to an RTC, and serves NTP clients. The main workflow is GPS parsing and synchronization, UDP request handling and response, with OLED and LED status feedback. The README also documents Wi-Fi controls, position display, optional client display, and RTC support. Most behavior lives in src/main.cpp; excerpts omit portions of setup, synchronization, and request dispatch, so only clearly evidenced calls are linked.

Main entry points: [`src/main.cpp`](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp) (Time synchronization), [`include/definitions.h`](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/include/definitions.h) (Hardware and settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_time["Timekeeping"]
  node_gpsparse["GPS parsing<br/>[main.cpp]"]
  node_sync["Time synchronization<br/>[main.cpp]"]
  node_rtcupdate["RTC updates<br/>[main.cpp]"]
end

subgraph group_network["Network service"]
  node_ntp["NTP packet service<br/>[main.cpp]"]
  node_wifi["Wi-Fi access point<br/>[main.cpp]"]
  node_root["Connection page<br/>[main.cpp]"]
end

subgraph group_interface["Status interface"]
  node_display["Time display<br/>[main.cpp]"]
  node_position["Position display<br/>[main.cpp]"]
  node_clientdisplay["Client display<br/>[main.cpp]"]
  node_controls["Display and Wi-Fi controls<br/>[main.cpp]"]
end

node_user(("Clock client"))
node_gps["GPS receiver"]
node_rtc[("DS3231 RTC")]
node_esp["ESP8266 server"]
node_config["Hardware and settings<br/>[definitions.h]"]

node_user -->|"joins network"| node_wifi
node_user -->|"requests time"| node_ntp
node_ntp -->|"sends NTP reply"| node_user
node_gps -.->|"provides serial data"| node_gpsparse
node_gpsparse -.->|"provides GPS time"| node_sync
node_sync -->|"updates RTC"| node_rtcupdate
node_rtc -.->|"fallback time"| node_sync
node_wifi -->|"routes page"| node_root
node_controls -->|"toggles"| node_wifi
node_ntp -.->|"records client"| node_clientdisplay
node_display -->|"uses display setup"| node_config
node_position -->|"uses display setup"| node_config
node_clientdisplay -->|"uses display setup"| node_config
node_sync -.->|"supplies time status"| node_display
node_gpsparse -.->|"supplies coordinates"| node_position
node_esp -->|"uses hardware definitions"| node_config

click node_ntp "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_wifi "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_root "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_gpsparse "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_sync "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_rtcupdate "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_display "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_position "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_clientdisplay "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_controls "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp"
click node_config "https://github.com/mmarkin/gps-ntp-timeserver/blob/main/include/definitions.h"

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_gpsparse,node_sync,node_rtcupdate,node_user toneBlue
class node_ntp,node_wifi,node_root,node_rtc toneAmber
class node_display,node_position,node_clientdisplay,node_controls,node_esp toneMint
class node_gps toneIndigo
class node_config toneTeal
```

## Components

### Timekeeping

- [GPS parsing](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Time synchronization](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [RTC updates](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`

### Network service

- [NTP packet service](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Wi-Fi access point](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Connection page](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`

### Status interface

- [Time display](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Position display](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Client display](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`
- [Display and Wi-Fi controls](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/src/main.cpp): `src/main.cpp`

### Other components

- **Clock client**
- **GPS receiver**
- **DS3231 RTC**
- **ESP8266 server**
- [Hardware and settings](https://github.com/mmarkin/gps-ntp-timeserver/blob/main/include/definitions.h): `include/definitions.h`

## Connections

- Clock client → Wi-Fi access point: joins network (evidence: `README.md`)
- Clock client → NTP packet service: requests time (evidence: `README.md`)
- NTP packet service → Clock client: sends NTP reply (evidence: `src/main.cpp`)
- GPS receiver → GPS parsing: provides serial data
- GPS parsing → Time synchronization: provides GPS time (evidence: `src/main.cpp`)
- Time synchronization → RTC updates: updates RTC (evidence: `src/main.cpp`)
- DS3231 RTC → Time synchronization: fallback time
- Wi-Fi access point → Connection page: routes page (evidence: `src/main.cpp`)
- Display and Wi-Fi controls → Wi-Fi access point: toggles (evidence: `src/main.cpp`)
- NTP packet service → Client display: records client (evidence: `src/main.cpp`)
- Time display → Hardware and settings: uses display setup (evidence: `include/definitions.h`)
- Position display → Hardware and settings: uses display setup (evidence: `include/definitions.h`)
- Client display → Hardware and settings: uses display setup (evidence: `include/definitions.h`)
- Time synchronization → Time display: supplies time status (evidence: `src/main.cpp`)
- GPS parsing → Position display: supplies coordinates (evidence: `src/main.cpp`)
- ESP8266 server → Hardware and settings: uses hardware definitions
