# rampump/ntripcaster architecture

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

- Interactive diagram: https://gitdiagram.com/rampump/ntripcaster
- Repository: https://github.com/rampump/ntripcaster

## Overview

2RTK NTRIP Caster is a Python service for receiving and distributing RTCM streams, with browser-based administration and optional multi-process sharding and external-caster relay. The main user workflow is: an administrator configures users and mount points in the web UI; NTRIP sources upload data and authenticated clients subscribe to it; the caster forwards the stream and exposes live connection and mount information. RTCM parsing supports STR correction and opt-in live visualization. Relationships are limited to README statements and the supplied source excerpts/index; unsampled implementation links are omitted where evidence is insufficient.

Main entry points: [`src/ntrip_reactor.py`](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_reactor.py) (Epoll reactor), [`src/web.py`](https://github.com/rampump/ntripcaster/blob/main/src/web.py) (Admin API and UI), [`src/shard_supervisor.py`](https://github.com/rampump/ntripcaster/blob/main/src/shard_supervisor.py) (Shard supervisor), [`src/forwarder.py`](https://github.com/rampump/ntripcaster/blob/main/src/forwarder.py) (RTCM fan-out)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin["Web administration"]
  node_web["Admin API and UI<br/>[web.py]"]
  node_database[("SQLite records<br/>[database.py]")]
  node_frontend["Browser interface<br/>[app.js]"]
end

subgraph group_data["NTRIP data plane"]
  node_reactor["Epoll reactor<br/>[ntrip_reactor.py]"]
  node_thread_caster["Thread caster<br/>[ntrip.py]"]
  node_protocol["Handshake protocol<br/>[ntrip_protocol.py]"]
  node_auth["Client authentication<br/>[ntrip_auth.py]"]
  node_registrar["Mount registration<br/>[ntrip_registrar.py]"]
  node_connections["Connection state<br/>[connection.py]"]
  node_forwarder["RTCM fan-out<br/>[forwarder.py]"]
  node_responses["Protocol responses<br/>[ntrip_response.py]"]
end

subgraph group_cluster["Sharding and state"]
  node_supervisor["Shard supervisor"]
  node_bus["Process message bus<br/>[ntrip_bus.py]"]
  node_cluster_state["Cluster state<br/>[cluster_state.py]"]
  node_cluster_view["Aggregated web view<br/>[cluster_view.py]"]
end

subgraph group_rtcm["RTCM insights"]
  node_rtcm_parser["RTCM decoder<br/>[rtcm2.py]"]
  node_parser_manager["Parser manager<br/>[rtcm2_manager.py]"]
  node_parser_registry["Web parse subscriptions"]
end

subgraph group_integrations["External relay"]
  node_external_relay["External caster relay<br/>[external_caster.py]"]
end

node_admin_actor(("Administrator"))
node_ntrip_actor(("NTRIP clients"))
node_upstream_caster(("Upstream caster"))

node_admin_actor -->|"administers"| node_web
node_ntrip_actor -->|"connects to"| node_reactor
node_ntrip_actor -->|"connects to"| node_thread_caster
node_web -->|"manages records"| node_database
node_frontend -.->|"uses API"| node_web
node_reactor -->|"parses handshakes"| node_protocol
node_reactor -->|"authenticates sources"| node_auth
node_reactor -->|"registers sources"| node_registrar
node_reactor -->|"tracks sessions"| node_connections
node_reactor -->|"forwards streams"| node_forwarder
node_reactor -->|"sends responses"| node_responses
node_thread_caster -->|"verifies clients"| node_auth
node_thread_caster -->|"forwards streams"| node_forwarder
node_forwarder -.->|"updates connection stats"| node_connections
node_supervisor -->|"starts shards"| node_reactor
node_supervisor -->|"coordinates shards"| node_bus
node_bus -->|"transfers source frames"| node_reactor
node_supervisor -->|"aggregates shard reports"| node_cluster_view
node_supervisor -->|"uses shared state"| node_cluster_state
node_web -->|"reads cluster details"| node_cluster_view
node_forwarder -.->|"provides stream data"| node_rtcm_parser
node_parser_manager -->|"manages parsers"| node_rtcm_parser
node_web -->|"serves parse subscriptions"| node_parser_registry
node_parser_registry -.->|"manages parse threads"| node_parser_manager
node_reactor -->|"handles tap requests"| node_bus
node_reactor -.->|"relays external mounts"| node_external_relay
node_external_relay -.->|"fetches and relays"| node_upstream_caster

click node_web "https://github.com/rampump/ntripcaster/blob/main/src/web.py"
click node_database "https://github.com/rampump/ntripcaster/blob/main/src/database.py"
click node_frontend "https://github.com/rampump/ntripcaster/blob/main/static/app.js"
click node_reactor "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_reactor.py"
click node_thread_caster "https://github.com/rampump/ntripcaster/blob/main/src/ntrip.py"
click node_protocol "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_protocol.py"
click node_auth "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_auth.py"
click node_registrar "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_registrar.py"
click node_connections "https://github.com/rampump/ntripcaster/blob/main/src/connection.py"
click node_forwarder "https://github.com/rampump/ntripcaster/blob/main/src/forwarder.py"
click node_responses "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_response.py"
click node_supervisor "https://github.com/rampump/ntripcaster/blob/main/src/shard_supervisor.py"
click node_bus "https://github.com/rampump/ntripcaster/blob/main/src/ntrip_bus.py"
click node_cluster_state "https://github.com/rampump/ntripcaster/blob/main/src/cluster_state.py"
click node_cluster_view "https://github.com/rampump/ntripcaster/blob/main/src/cluster_view.py"
click node_rtcm_parser "https://github.com/rampump/ntripcaster/blob/main/src/rtcm2.py"
click node_parser_manager "https://github.com/rampump/ntripcaster/blob/main/src/rtcm2_manager.py"
click node_parser_registry "https://github.com/rampump/ntripcaster/blob/main/src/web_parser_registry.py"
click node_external_relay "https://github.com/rampump/ntripcaster/blob/main/src/external_caster.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_web,node_database,node_frontend,node_ntrip_actor toneBlue
class node_reactor,node_thread_caster,node_protocol,node_auth,node_registrar,node_connections,node_forwarder,node_responses toneAmber
class node_supervisor,node_bus,node_cluster_state,node_cluster_view toneMint
class node_rtcm_parser,node_parser_manager,node_parser_registry toneRose
class node_external_relay,node_admin_actor,node_upstream_caster toneIndigo
```

## Components

### Web administration

- [Admin API and UI](https://github.com/rampump/ntripcaster/blob/main/src/web.py): `src/web.py`
- [SQLite records](https://github.com/rampump/ntripcaster/blob/main/src/database.py): `src/database.py`
- [Browser interface](https://github.com/rampump/ntripcaster/blob/main/static/app.js): `static/app.js`

### NTRIP data plane

- [Epoll reactor](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_reactor.py): `src/ntrip_reactor.py`
- [Thread caster](https://github.com/rampump/ntripcaster/blob/main/src/ntrip.py): `src/ntrip.py`
- [Handshake protocol](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_protocol.py): `src/ntrip_protocol.py`
- [Client authentication](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_auth.py): `src/ntrip_auth.py`
- [Mount registration](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_registrar.py): `src/ntrip_registrar.py`
- [Connection state](https://github.com/rampump/ntripcaster/blob/main/src/connection.py): `src/connection.py`
- [RTCM fan-out](https://github.com/rampump/ntripcaster/blob/main/src/forwarder.py): `src/forwarder.py`
- [Protocol responses](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_response.py): `src/ntrip_response.py`

### Sharding and state

- [Shard supervisor](https://github.com/rampump/ntripcaster/blob/main/src/shard_supervisor.py): `src/shard_supervisor.py`
- [Process message bus](https://github.com/rampump/ntripcaster/blob/main/src/ntrip_bus.py): `src/ntrip_bus.py`
- [Cluster state](https://github.com/rampump/ntripcaster/blob/main/src/cluster_state.py): `src/cluster_state.py`
- [Aggregated web view](https://github.com/rampump/ntripcaster/blob/main/src/cluster_view.py): `src/cluster_view.py`

### RTCM insights

- [RTCM decoder](https://github.com/rampump/ntripcaster/blob/main/src/rtcm2.py): `src/rtcm2.py`
- [Parser manager](https://github.com/rampump/ntripcaster/blob/main/src/rtcm2_manager.py): `src/rtcm2_manager.py`
- [Web parse subscriptions](https://github.com/rampump/ntripcaster/blob/main/src/web_parser_registry.py): `src/web_parser_registry.py`

### External relay

- [External caster relay](https://github.com/rampump/ntripcaster/blob/main/src/external_caster.py): `src/external_caster.py`

### Other components

- **Administrator**
- **NTRIP clients**
- **Upstream caster**

## Connections

- Administrator → Admin API and UI: administers (evidence: `README.md`)
- NTRIP clients → Epoll reactor: connects to (evidence: `README.md`)
- NTRIP clients → Thread caster: connects to (evidence: `README.md`)
- Admin API and UI → SQLite records: manages records (evidence: `README.md`)
- Browser interface → Admin API and UI: uses API
- Epoll reactor → Handshake protocol: parses handshakes (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → Client authentication: authenticates sources (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → Mount registration: registers sources (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → Connection state: tracks sessions (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → RTCM fan-out: forwards streams (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → Protocol responses: sends responses (evidence: `src/ntrip_reactor.py`)
- Thread caster → Client authentication: verifies clients (evidence: `src/ntrip.py`)
- Thread caster → RTCM fan-out: forwards streams (evidence: `src/ntrip.py`)
- RTCM fan-out → Connection state: updates connection stats (evidence: `src/forwarder.py`)
- Shard supervisor → Epoll reactor: starts shards (evidence: `README.md`)
- Shard supervisor → Process message bus: coordinates shards (evidence: `README.md`)
- Process message bus → Epoll reactor: transfers source frames (evidence: `README.md`)
- Shard supervisor → Aggregated web view: aggregates shard reports (evidence: `src/shard_supervisor.py`)
- Shard supervisor → Cluster state: uses shared state (evidence: `src/shard_supervisor.py`)
- Admin API and UI → Aggregated web view: reads cluster details (evidence: `src/web.py`)
- RTCM fan-out → RTCM decoder: provides stream data (evidence: `src/rtcm2.py`)
- Parser manager → RTCM decoder: manages parsers (evidence: `src/rtcm2_manager.py`)
- Admin API and UI → Web parse subscriptions: serves parse subscriptions (evidence: `src/web.py`)
- Web parse subscriptions → Parser manager: manages parse threads
- Epoll reactor → Process message bus: handles tap requests (evidence: `src/ntrip_reactor.py`)
- Epoll reactor → External caster relay: relays external mounts (evidence: `src/ntrip_reactor.py`)
- External caster relay → Upstream caster: fetches and relays (evidence: `README.md`)
