# welir/tcp-python architecture

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

- Interactive diagram: https://gitdiagram.com/welir/tcp-python
- Repository: https://github.com/welir/tcp-python

## Overview

TCP-PYTHON is a socket-based client/server application: clients send session metadata and data, which server handlers process and persist in SQLite. Separate server variants add relay control, GPS acknowledgments, and user registration; a Bottle service reads stored data for web views and geocoding. The README also describes a GUI start/stop path, but its implementation was not sampled, so that relationship is documented rather than verified in source.

Main entry points: [`Server.py`](https://github.com/welir/tcp-python/blob/master/Server.py) (TCP Server), [`Relay_server.py`](https://github.com/welir/tcp-python/blob/master/Relay_server.py) (Relay Server), [`WEBSERVICE.py`](https://github.com/welir/tcp-python/blob/master/WEBSERVICE.py) (Web Service), [`SysLog.py`](https://github.com/welir/tcp-python/blob/master/SysLog.py) (System Log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["TCP Transport"]
  node_tcp_client["TCP Client"]
  node_tcp_server["TCP Server<br/>[Server.py]"]
  node_session_handler["Session Handler<br/>[Server.py]"]
end

subgraph group_persistence["Persistence and Logging"]
  node_database[("Sessions Database<br/>[sessions.db]")]
  node_database_module["Database Module<br/>[DM.py]"]
  node_ini_reader["INI Reader<br/>[INSTALL.py]"]
  node_system_log["System Log<br/>[SysLog.py]"]
end

subgraph group_features["Server Features"]
  node_relay_server["Relay Server<br/>[Relay_server.py]"]
  node_relay_control["Relay Control<br/>[Relay_control.py]"]
  node_temperature_sensor["Temperature Sensor<br/>[Tempered.py]"]
  node_gps_server["GPS Server<br/>[GPS_Server.py]"]
  node_fixime_server["FIXi Server<br/>[FixIME_SERVER.py]"]
end

subgraph group_presentation["User Interfaces"]
  node_web_service["Web Service<br/>[WEBSERVICE.py]"]
  node_table_view["Table View<br/>[maketable.tpl]"]
  node_map_view["Map View"]
  node_gui["Start/Stop GUI<br/>[form.pyw]"]
end

node_operator(("Operator"))
node_gpio["Raspberry Pi GPIO"]
node_geocoding["Geocoding Service"]

node_tcp_client -->|"sends TCP data"| node_tcp_server
node_tcp_server -->|"dispatches clients"| node_session_handler
node_tcp_server -->|"initializes database"| node_database_module
node_tcp_server -->|"reads schema setup"| node_ini_reader
node_session_handler -->|"writes sessions and data"| node_database
node_session_handler -->|"logs events"| node_system_log
node_database_module -->|"creates and updates"| node_database
node_relay_server -->|"extends server"| node_tcp_server
node_relay_server -->|"commands relays"| node_relay_control
node_relay_server -->|"reads temperature"| node_temperature_sensor
node_relay_server -->|"logs events"| node_system_log
node_relay_control -->|"updates relay state"| node_database_module
node_relay_control -->|"sets relay pins"| node_gpio
node_temperature_sensor -->|"samples sensor pin"| node_gpio
node_gps_server -->|"uses server handler"| node_tcp_server
node_gps_server -->|"logs events"| node_system_log
node_fixime_server -->|"extends server"| node_tcp_server
node_fixime_server -->|"logs events"| node_system_log
node_web_service -->|"queries data"| node_database
node_web_service -->|"renders table"| node_table_view
node_web_service -->|"renders map"| node_map_view
node_web_service -->|"requests geocoding"| node_geocoding
node_operator -.->|"starts or stops"| node_gui
node_gui -.->|"starts server"| node_tcp_server

click node_tcp_client "https://github.com/welir/tcp-python/blob/master/client_tcp_threads.py"
click node_tcp_server "https://github.com/welir/tcp-python/blob/master/Server.py"
click node_session_handler "https://github.com/welir/tcp-python/blob/master/Server.py"
click node_database "https://github.com/welir/tcp-python/blob/master/sessions.db"
click node_database_module "https://github.com/welir/tcp-python/blob/master/DM.py"
click node_ini_reader "https://github.com/welir/tcp-python/blob/master/INSTALL.py"
click node_system_log "https://github.com/welir/tcp-python/blob/master/SysLog.py"
click node_relay_server "https://github.com/welir/tcp-python/blob/master/Relay_server.py"
click node_relay_control "https://github.com/welir/tcp-python/blob/master/Relay_control.py"
click node_temperature_sensor "https://github.com/welir/tcp-python/blob/master/Tempered.py"
click node_gps_server "https://github.com/welir/tcp-python/blob/master/GPS_Server.py"
click node_fixime_server "https://github.com/welir/tcp-python/blob/master/FixIME_SERVER.py"
click node_web_service "https://github.com/welir/tcp-python/blob/master/WEBSERVICE.py"
click node_table_view "https://github.com/welir/tcp-python/blob/master/templates/maketable.tpl"
click node_map_view "https://github.com/welir/tcp-python/blob/master/templates/maps"
click node_gui "https://github.com/welir/tcp-python/blob/master/form.pyw"

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_tcp_client,node_tcp_server,node_session_handler toneBlue
class node_database,node_database_module,node_ini_reader,node_system_log toneAmber
class node_relay_server,node_relay_control,node_temperature_sensor,node_gps_server,node_fixime_server toneMint
class node_web_service,node_table_view,node_map_view,node_gui toneRose
class node_operator,node_gpio,node_geocoding toneIndigo
```

## Components

### TCP Transport

- [TCP Client](https://github.com/welir/tcp-python/blob/master/client_tcp_threads.py): `client_tcp_threads.py`
- [TCP Server](https://github.com/welir/tcp-python/blob/master/Server.py): `Server.py`
- [Session Handler](https://github.com/welir/tcp-python/blob/master/Server.py): `Server.py`

### Persistence and Logging

- [Sessions Database](https://github.com/welir/tcp-python/blob/master/sessions.db): `sessions.db`
- [Database Module](https://github.com/welir/tcp-python/blob/master/DM.py): `DM.py`
- [INI Reader](https://github.com/welir/tcp-python/blob/master/INSTALL.py): `INSTALL.py`
- [System Log](https://github.com/welir/tcp-python/blob/master/SysLog.py): `SysLog.py`

### Server Features

- [Relay Server](https://github.com/welir/tcp-python/blob/master/Relay_server.py): `Relay_server.py`
- [Relay Control](https://github.com/welir/tcp-python/blob/master/Relay_control.py): `Relay_control.py`
- [Temperature Sensor](https://github.com/welir/tcp-python/blob/master/Tempered.py): `Tempered.py`
- [GPS Server](https://github.com/welir/tcp-python/blob/master/GPS_Server.py): `GPS_Server.py`
- [FIXi Server](https://github.com/welir/tcp-python/blob/master/FixIME_SERVER.py): `FixIME_SERVER.py`

### User Interfaces

- [Web Service](https://github.com/welir/tcp-python/blob/master/WEBSERVICE.py): `WEBSERVICE.py`
- [Table View](https://github.com/welir/tcp-python/blob/master/templates/maketable.tpl): `templates/maketable.tpl`
- [Map View](https://github.com/welir/tcp-python/blob/master/templates/maps): `templates/maps`
- [Start/Stop GUI](https://github.com/welir/tcp-python/blob/master/form.pyw): `form.pyw`

### Other components

- **Operator**
- **Raspberry Pi GPIO**
- **Geocoding Service**

## Connections

- TCP Client → TCP Server: sends TCP data (evidence: `client_tcp_threads.py`)
- TCP Server → Session Handler: dispatches clients (evidence: `Server.py`)
- TCP Server → Database Module: initializes database (evidence: `Server.py`)
- TCP Server → INI Reader: reads schema setup (evidence: `Server.py`)
- Session Handler → Sessions Database: writes sessions and data (evidence: `Server.py`)
- Session Handler → System Log: logs events (evidence: `Server.py`)
- Database Module → Sessions Database: creates and updates (evidence: `DM.py`)
- Relay Server → TCP Server: extends server (evidence: `Relay_server.py`)
- Relay Server → Relay Control: commands relays (evidence: `Relay_server.py`)
- Relay Server → Temperature Sensor: reads temperature (evidence: `Relay_server.py`)
- Relay Server → System Log: logs events (evidence: `Relay_server.py`)
- Relay Control → Database Module: updates relay state (evidence: `Relay_control.py`)
- Relay Control → Raspberry Pi GPIO: sets relay pins (evidence: `Relay_control.py`)
- Temperature Sensor → Raspberry Pi GPIO: samples sensor pin (evidence: `Tempered.py`)
- GPS Server → TCP Server: uses server handler (evidence: `GPS_Server.py`)
- GPS Server → System Log: logs events (evidence: `GPS_Server.py`)
- FIXi Server → TCP Server: extends server (evidence: `FixIME_SERVER.py`)
- FIXi Server → System Log: logs events (evidence: `FixIME_SERVER.py`)
- Web Service → Sessions Database: queries data (evidence: `WEBSERVICE.py`)
- Web Service → Table View: renders table (evidence: `WEBSERVICE.py`)
- Web Service → Map View: renders map (evidence: `WEBSERVICE.py`)
- Web Service → Geocoding Service: requests geocoding (evidence: `WEBSERVICE.py`)
- Operator → Start/Stop GUI: starts or stops (evidence: `README.md`)
- Start/Stop GUI → TCP Server: starts server (evidence: `README.md`)
