# vrachieru/samsung-tv-api architecture

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

- Interactive diagram: https://gitdiagram.com/vrachieru/samsung-tv-api
- Repository: https://github.com/vrachieru/samsung-tv-api

## Overview

This is a small Python library for controlling compatible Samsung Smart TVs over a network connection. A caller creates `SamsungTV`, which opens a WebSocket connection and checks the TV’s connection event; control methods then translate power, navigation, channel, volume, and other actions into remote-key commands. The wrapper serializes those commands and sends them through `websocket-client`. The graph focuses on this runtime path; the implementation is concentrated in `samsungtv/remote.py`.

Main entry points: [`samsungtv/remote.py`](https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/remote.py) (TV controls), [`samsungtv/__init__.py`](https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/__init__.py) (Public export)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Library caller"))
node_export["Public export<br/>[__init__.py]"]
node_controls["TV controls<br/>[remote.py]"]
node_dispatcher["Key dispatcher<br/>[remote.py]"]
node_wsclient["WebSocket client"]
node_tv(("Samsung TV"))

node_caller -->|"imports"| node_export
node_export -->|"exports"| node_controls
node_caller -->|"creates"| node_controls
node_controls -->|"sends keys"| node_dispatcher
node_controls -->|"maps channels"| node_dispatcher
node_dispatcher -->|"sends commands"| node_wsclient
node_wsclient -->|"connects via WebSocket"| node_tv
node_tv -->|"returns handshake"| node_controls

click node_export "https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/__init__.py"
click node_controls "https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/remote.py"
click node_dispatcher "https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/remote.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_caller,node_tv toneIndigo
class node_export,node_controls,node_dispatcher toneTeal
class node_wsclient toneBlue
```

## Components

### Other components

- **Library caller**
- [Public export](https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/__init__.py): `samsungtv/__init__.py`
- [TV controls](https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/remote.py): `samsungtv/remote.py`
- [Key dispatcher](https://github.com/vrachieru/samsung-tv-api/blob/master/samsungtv/remote.py): `samsungtv/remote.py`
- **WebSocket client**
- **Samsung TV**

## Connections

- Library caller → Public export: imports (evidence: `README.md`)
- Public export → TV controls: exports (evidence: `samsungtv/__init__.py`)
- Library caller → TV controls: creates (evidence: `README.md`)
- TV controls → Key dispatcher: sends keys (evidence: `samsungtv/remote.py`)
- TV controls → Key dispatcher: maps channels (evidence: `samsungtv/remote.py`)
- Key dispatcher → WebSocket client: sends commands (evidence: `samsungtv/remote.py`)
- WebSocket client → Samsung TV: connects via WebSocket
- Samsung TV → TV controls: returns handshake (evidence: `samsungtv/remote.py`)
