# ivanglinkin/cctv architecture

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

- Interactive diagram: https://gitdiagram.com/ivanglinkin/cctv
- Repository: https://github.com/ivanglinkin/cctv

## Overview

CCTV is a Telegram-based nearby-user location collection and mapping tool; the README states Telegram disabled the feature in September 2024, so the documented principal workflow no longer works as described. In the former CLI workflow, start.py moves through configured coordinates, queries Telegram, records sightings, and generates per-run and combined map reports. Supporting stages include avatar retrieval and location lookup. The repository also includes a separate desktop GUI and Leaflet map assets. Edges reflect calls and integrations visible in excerpts or explicitly documented; unsampled code limits certainty about additional wiring.

Main entry points: [`start.py`](https://github.com/ivanglinkin/cctv/blob/main/start.py) (CLI orchestrator), [`backend/json_into_html.py`](https://github.com/ivanglinkin/cctv/blob/main/backend/json_into_html.py) (HTML map renderer), [`backend/combine_data.py`](https://github.com/ivanglinkin/cctv/blob/main/backend/combine_data.py) (Combined report workflow), [`backend/functions.py`](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py) (Avatar retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection workflow"]
  node_cli["CLI orchestrator<br/>[start.py]"]
  node_coordinate_sweep["Coordinate sweep<br/>[start.py]"]
  node_telegram_query["Nearby-user query<br/>[start.py]"]
  node_sighting_data["Sightings data<br/>[start.py]"]
end

subgraph group_support["Collection support"]
  node_settings["Settings setup<br/>[functions.py]"]
  node_coordinate_math["Coordinate helpers<br/>[functions.py]"]
  node_avatar_fetch["Avatar retrieval<br/>[functions.py]"]
  node_reverse_lookup["Location lookup<br/>[functions.py]"]
  node_json_combine["JSON combination<br/>[functions.py]"]
end

subgraph group_reporting["Reports and maps"]
  node_combined_workflow["Combined report workflow<br/>[combine_data.py]"]
  node_html_render["HTML map renderer<br/>[json_into_html.py]"]
  node_map_library["Leaflet mapping<br/>[leaflet-src.js]"]
  node_marker_clusters["Marker clustering"]
end

subgraph group_desktop["Desktop interface"]
  node_desktop_ui["Desktop GUI<br/>[GUI_template.py]"]
end

node_operator(("Operator"))
node_telegram{{"Telegram API"}}
node_telegram_profiles{{"Telegram profiles"}}
node_nominatim{{"Nominatim"}}
node_tile_service{{"OpenStreetMap tiles"}}

node_operator -->|"runs"| node_cli
node_cli -->|"creates settings"| node_settings
node_cli -->|"builds sweep"| node_coordinate_sweep
node_coordinate_sweep -->|"calls"| node_coordinate_math
node_cli -->|"runs queries"| node_telegram_query
node_telegram_query -->|"queries nearby users"| node_telegram
node_telegram_query -->|"records sightings"| node_sighting_data
node_cli -->|"downloads avatars"| node_avatar_fetch
node_avatar_fetch -->|"fetches profile images"| node_telegram_profiles
node_cli -->|"renders report"| node_html_render
node_cli -->|"starts combined report"| node_combined_workflow
node_combined_workflow -->|"combines JSON"| node_json_combine
node_combined_workflow -->|"renders combined map"| node_html_render
node_html_render -->|"uses map library"| node_map_library
node_html_render -->|"clusters markers"| node_marker_clusters
node_html_render -->|"loads map tiles"| node_tile_service
node_operator -->|"opens interface"| node_desktop_ui
node_reverse_lookup -->|"looks up places"| node_nominatim

click node_cli "https://github.com/ivanglinkin/cctv/blob/main/start.py"
click node_settings "https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py"
click node_coordinate_sweep "https://github.com/ivanglinkin/cctv/blob/main/start.py"
click node_coordinate_math "https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py"
click node_telegram_query "https://github.com/ivanglinkin/cctv/blob/main/start.py"
click node_sighting_data "https://github.com/ivanglinkin/cctv/blob/main/start.py"
click node_avatar_fetch "https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py"
click node_reverse_lookup "https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py"
click node_json_combine "https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py"
click node_combined_workflow "https://github.com/ivanglinkin/cctv/blob/main/backend/combine_data.py"
click node_html_render "https://github.com/ivanglinkin/cctv/blob/main/backend/json_into_html.py"
click node_map_library "https://github.com/ivanglinkin/cctv/blob/main/leaflet/leaflet-src.js"
click node_marker_clusters "https://github.com/ivanglinkin/cctv/blob/main/leaflet/js/leaflet.markercluster.js"
click node_desktop_ui "https://github.com/ivanglinkin/cctv/blob/main/GUI_template.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_coordinate_sweep,node_telegram_query,node_sighting_data toneBlue
class node_settings,node_coordinate_math,node_avatar_fetch,node_reverse_lookup,node_json_combine toneAmber
class node_combined_workflow,node_html_render,node_map_library,node_marker_clusters,node_telegram toneMint
class node_desktop_ui toneRose
class node_operator,node_telegram_profiles,node_nominatim,node_tile_service toneIndigo
```

## Components

### Collection workflow

- [CLI orchestrator](https://github.com/ivanglinkin/cctv/blob/main/start.py): `start.py`
- [Coordinate sweep](https://github.com/ivanglinkin/cctv/blob/main/start.py): `start.py`
- [Nearby-user query](https://github.com/ivanglinkin/cctv/blob/main/start.py): `start.py`
- [Sightings data](https://github.com/ivanglinkin/cctv/blob/main/start.py): `start.py`

### Collection support

- [Settings setup](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py): `backend/functions.py`
- [Coordinate helpers](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py): `backend/functions.py`
- [Avatar retrieval](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py): `backend/functions.py`
- [Location lookup](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py): `backend/functions.py`
- [JSON combination](https://github.com/ivanglinkin/cctv/blob/main/backend/functions.py): `backend/functions.py`

### Reports and maps

- [Combined report workflow](https://github.com/ivanglinkin/cctv/blob/main/backend/combine_data.py): `backend/combine_data.py`
- [HTML map renderer](https://github.com/ivanglinkin/cctv/blob/main/backend/json_into_html.py): `backend/json_into_html.py`
- [Leaflet mapping](https://github.com/ivanglinkin/cctv/blob/main/leaflet/leaflet-src.js): `leaflet/leaflet-src.js`
- [Marker clustering](https://github.com/ivanglinkin/cctv/blob/main/leaflet/js/leaflet.markercluster.js): `leaflet/js/leaflet.markercluster.js`

### Desktop interface

- [Desktop GUI](https://github.com/ivanglinkin/cctv/blob/main/GUI_template.py): `GUI_template.py`

### Other components

- **Operator**
- **Telegram API**
- **Telegram profiles**
- **Nominatim**
- **OpenStreetMap tiles**

## Connections

- Operator → CLI orchestrator: runs (evidence: `README.md`)
- CLI orchestrator → Settings setup: creates settings (evidence: `start.py`)
- CLI orchestrator → Coordinate sweep: builds sweep (evidence: `start.py`)
- Coordinate sweep → Coordinate helpers: calls (evidence: `start.py`)
- CLI orchestrator → Nearby-user query: runs queries (evidence: `start.py`)
- Nearby-user query → Telegram API: queries nearby users (evidence: `start.py`)
- Nearby-user query → Sightings data: records sightings (evidence: `start.py`)
- CLI orchestrator → Avatar retrieval: downloads avatars (evidence: `start.py`)
- Avatar retrieval → Telegram profiles: fetches profile images (evidence: `backend/functions.py`)
- CLI orchestrator → HTML map renderer: renders report (evidence: `start.py`)
- CLI orchestrator → Combined report workflow: starts combined report (evidence: `start.py`)
- Combined report workflow → JSON combination: combines JSON (evidence: `backend/combine_data.py`)
- Combined report workflow → HTML map renderer: renders combined map (evidence: `backend/combine_data.py`)
- HTML map renderer → Leaflet mapping: uses map library (evidence: `backend/json_into_html.py`)
- HTML map renderer → Marker clustering: clusters markers (evidence: `backend/json_into_html.py`)
- HTML map renderer → OpenStreetMap tiles: loads map tiles (evidence: `backend/json_into_html.py`)
- Operator → Desktop GUI: opens interface (evidence: `GUI_template.py`)
- Location lookup → Nominatim: looks up places (evidence: `backend/functions.py`)
