# ksanicc/pc_bot architecture

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

- Interactive diagram: https://gitdiagram.com/ksanicc/pc_bot
- Repository: https://github.com/ksanicc/pc_bot

## Overview

This is a Telegram bot for remotely controlling a Windows or Linux PC. An administrator sends commands through Telegram; the bot routes them to admin handlers, which report system status, launch shell commands, reboot, or on Linux set the next Windows boot entry and reboot. A separate user handler rejects non-admin starts. Configuration supplies credentials, proxy, shell, and boot order. The README also describes optional service installation, but that is setup machinery rather than the bot’s runtime workflow. Relationships below follow the sampled entry point and handlers.

Main entry points: [`handlers/admin.py`](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py) (Admin commands), [`main.py`](https://github.com/ksanicc/pc_bot/blob/master/main.py) (Polling entry point), [`handlers/user.py`](https://github.com/ksanicc/pc_bot/blob/master/handlers/user.py) (Non-admin response), [`config.py`](https://github.com/ksanicc/pc_bot/blob/master/config.py) (Bot configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_entry["Polling entry point<br/>[main.py]"]
end

subgraph group_commands["Command handling"]
  node_admin_handlers["Admin commands<br/>[admin.py]"]
  node_user_handlers["Non-admin response<br/>[user.py]"]
end

subgraph group_host["Host operations"]
  node_terminal["Shell execution<br/>[admin.py]"]
  node_status["System status<br/>[admin.py]"]
  node_reboot["PC reboot<br/>[admin.py]"]
  node_boot_switch["Windows boot switch<br/>[admin.py]"]
end

subgraph group_settings["Configuration"]
  node_config["Bot configuration<br/>[config.py]"]
end

node_admin(("Administrator"))
node_telegram{{"Telegram API"}}

node_admin -->|"sends commands"| node_telegram
node_telegram -->|"delivers updates"| node_entry
node_entry -->|"reads settings"| node_config
node_entry -->|"registers router"| node_admin_handlers
node_entry -->|"registers router"| node_user_handlers
node_admin_handlers -->|"reads settings"| node_config
node_admin_handlers -->|"executes command"| node_terminal
node_admin_handlers -->|"runs metrics command"| node_status
node_admin_handlers -->|"dispatches reboot"| node_reboot
node_admin_handlers -->|"sets boot entry"| node_boot_switch
node_terminal -->|"replies with output"| node_telegram
node_status -->|"replies with metrics"| node_telegram
node_reboot -->|"sends notice"| node_telegram
node_boot_switch -->|"reboots after setup"| node_reboot
node_user_handlers -->|"replies to user"| node_telegram

click node_entry "https://github.com/ksanicc/pc_bot/blob/master/main.py"
click node_admin_handlers "https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py"
click node_user_handlers "https://github.com/ksanicc/pc_bot/blob/master/handlers/user.py"
click node_config "https://github.com/ksanicc/pc_bot/blob/master/config.py"
click node_terminal "https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py"
click node_status "https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py"
click node_reboot "https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py"
click node_boot_switch "https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.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_entry toneBlue
class node_admin_handlers,node_user_handlers toneAmber
class node_terminal,node_status,node_reboot,node_boot_switch,node_telegram toneMint
class node_config toneRose
class node_admin toneIndigo
```

## Components

### Bot runtime

- [Polling entry point](https://github.com/ksanicc/pc_bot/blob/master/main.py): `main.py`

### Command handling

- [Admin commands](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py): `handlers/admin.py`
- [Non-admin response](https://github.com/ksanicc/pc_bot/blob/master/handlers/user.py): `handlers/user.py`

### Host operations

- [Shell execution](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py): `handlers/admin.py`
- [System status](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py): `handlers/admin.py`
- [PC reboot](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py): `handlers/admin.py`
- [Windows boot switch](https://github.com/ksanicc/pc_bot/blob/master/handlers/admin.py): `handlers/admin.py`

### Configuration

- [Bot configuration](https://github.com/ksanicc/pc_bot/blob/master/config.py): `config.py`

### Other components

- **Administrator**
- **Telegram API**

## Connections

- Administrator → Telegram API: sends commands (evidence: `README.md`)
- Telegram API → Polling entry point: delivers updates (evidence: `main.py`)
- Polling entry point → Bot configuration: reads settings (evidence: `main.py`)
- Polling entry point → Admin commands: registers router (evidence: `main.py`)
- Polling entry point → Non-admin response: registers router (evidence: `main.py`)
- Admin commands → Bot configuration: reads settings (evidence: `handlers/admin.py`)
- Admin commands → Shell execution: executes command (evidence: `handlers/admin.py`)
- Admin commands → System status: runs metrics command (evidence: `handlers/admin.py`)
- Admin commands → PC reboot: dispatches reboot (evidence: `handlers/admin.py`)
- Admin commands → Windows boot switch: sets boot entry (evidence: `handlers/admin.py`)
- Shell execution → Telegram API: replies with output (evidence: `handlers/admin.py`)
- System status → Telegram API: replies with metrics (evidence: `handlers/admin.py`)
- PC reboot → Telegram API: sends notice (evidence: `handlers/admin.py`)
- Windows boot switch → PC reboot: reboots after setup (evidence: `handlers/admin.py`)
- Non-admin response → Telegram API: replies to user (evidence: `handlers/user.py`)
