# nazeem2001/windows_control_telegram architecture

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

- Interactive diagram: https://gitdiagram.com/nazeem2001/windows_control_telegram
- Repository: https://github.com/nazeem2001/windows_control_telegram

## Overview

Windows Command Telegram Bot accepts Telegram messages and media, authorizes users, and routes commands through AI or classifier-based rule mode to local system actions or replies. AI mode uses an Ollama-backed tool agent; non-AI mode classifies commands and may request confirmation. Separate branches provide webcam/screen streaming and RDP tunneling, file and audio handling, and persistent natural-language reminders. The excerpts establish the Telegram entry point, tool adapter, agent setup, scheduler, reminder persistence, and streaming server; several feature and tool-handler internals are unsampled, so their wiring is shown only where documented or directly evidenced.

Main entry points: [`features.py`](https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py) (Feature router), [`live_webserver.py`](https://github.com/nazeem2001/windows_control_telegram/blob/main/live_webserver.py) (Streaming server), [`scheduler_manager.py`](https://github.com/nazeem2001/windows_control_telegram/blob/main/scheduler_manager.py) (Reminder scheduler), [`main.py`](https://github.com/nazeem2001/windows_control_telegram/blob/main/main.py) (Bot entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interaction"]
  node_main["Bot entry point<br/>[main.py]"]
  node_features["Feature router<br/>[features.py]"]
  node_auth["Authorization<br/>[features.py]"]
  node_media["Media and speech<br/>[features.py]"]
end

subgraph group_assistant["Command understanding"]
  node_classifier["Command classifier"]
  node_chains["AI agent and TTS<br/>[chains.py]"]
  node_toolconfig["Agent tool definitions<br/>[tool_config.py]"]
  node_adaptor["Tool adapter<br/>[tool_adaptor.py]"]
  node_context["Tool context<br/>[tool_context.py]"]
end

subgraph group_control["System control"]
  node_features_control["Command handlers<br/>[features.py]"]
end

subgraph group_reminders["Reminder service"]
  node_scheduler["Reminder scheduler"]
  node_parser["Natural-language parser<br/>[reminder_parser.py]"]
  node_reminderdb[("Reminder storage<br/>[reminder_db.py]")]
  node_executor["Reminder execution"]
end

subgraph group_streaming["Live streaming"]
  node_webserver["Streaming server<br/>[live_webserver.py]"]
  node_pages["Stream pages<br/>[index.html]"]
  node_screenpage["Screen page<br/>[screen.html]"]
end

node_user(("Telegram user"))
node_telegram{{"Telegram Bot API"}}
node_ollama{{"Ollama model"}}
node_local_system{{"Local system"}}
node_ngrok{{"ngrok tunnel"}}

node_user -->|"sends updates"| node_telegram
node_telegram -->|"delivers updates"| node_main
node_main -->|"dispatches commands"| node_features
node_main -->|"starts scheduler"| node_scheduler
node_features -->|"checks access"| node_auth
node_features -->|"predicts command"| node_classifier
node_features -->|"runs AI mode"| node_chains
node_chains -->|"queries model"| node_ollama
node_chains -->|"builds tools"| node_toolconfig
node_toolconfig -->|"dispatches tools"| node_adaptor
node_adaptor -->|"uses context"| node_context
node_adaptor -->|"calls handler"| node_features_control
node_features -->|"executes commands"| node_features_control
node_features_control -->|"controls system"| node_local_system
node_features -->|"handles media"| node_media
node_features -->|"starts streaming"| node_webserver
node_features_control -.->|"opens tunnel"| node_ngrok
node_features_control -->|"manages reminders"| node_scheduler
node_scheduler -->|"loads and saves"| node_reminderdb
node_scheduler -->|"schedules execution"| node_executor
node_executor -->|"reads and deletes"| node_reminderdb
node_executor -->|"runs command"| node_features_control
node_features_control -->|"parses reminder"| node_parser
node_webserver -->|"renders page"| node_pages
node_webserver -->|"renders screen"| node_screenpage
node_webserver -->|"captures camera and screen"| node_local_system
node_features -->|"sends replies"| node_telegram
node_media -->|"downloads media"| node_telegram

click node_main "https://github.com/nazeem2001/windows_control_telegram/blob/main/main.py"
click node_features "https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py"
click node_auth "https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py"
click node_media "https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py"
click node_classifier "https://github.com/nazeem2001/windows_control_telegram/blob/main/text_classifier.joblib"
click node_chains "https://github.com/nazeem2001/windows_control_telegram/blob/main/chains.py"
click node_toolconfig "https://github.com/nazeem2001/windows_control_telegram/blob/main/tool_config.py"
click node_adaptor "https://github.com/nazeem2001/windows_control_telegram/blob/main/adaptors/tool_adaptor.py"
click node_context "https://github.com/nazeem2001/windows_control_telegram/blob/main/models/tool_context.py"
click node_features_control "https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py"
click node_webserver "https://github.com/nazeem2001/windows_control_telegram/blob/main/live_webserver.py"
click node_pages "https://github.com/nazeem2001/windows_control_telegram/blob/main/templates/index.html"
click node_screenpage "https://github.com/nazeem2001/windows_control_telegram/blob/main/templates/screen.html"
click node_scheduler "https://github.com/nazeem2001/windows_control_telegram/blob/main/scheduler_manager.py"
click node_parser "https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_parser.py"
click node_reminderdb "https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_db.py"
click node_executor "https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_executor.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_main,node_features,node_auth,node_media,node_user toneBlue
class node_classifier,node_chains,node_toolconfig,node_adaptor,node_context toneAmber
class node_features_control,node_telegram toneMint
class node_scheduler,node_parser,node_reminderdb,node_executor toneRose
class node_webserver,node_pages,node_screenpage,node_ollama,node_local_system,node_ngrok toneIndigo
```

## Components

### Telegram interaction

- [Bot entry point](https://github.com/nazeem2001/windows_control_telegram/blob/main/main.py): `main.py`
- [Feature router](https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py): `features.py`
- [Authorization](https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py): `features.py`
- [Media and speech](https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py): `features.py`

### Command understanding

- [Command classifier](https://github.com/nazeem2001/windows_control_telegram/blob/main/text_classifier.joblib): `text_classifier.joblib`
- [AI agent and TTS](https://github.com/nazeem2001/windows_control_telegram/blob/main/chains.py): `chains.py`
- [Agent tool definitions](https://github.com/nazeem2001/windows_control_telegram/blob/main/tool_config.py): `tool_config.py`
- [Tool adapter](https://github.com/nazeem2001/windows_control_telegram/blob/main/adaptors/tool_adaptor.py): `adaptors/tool_adaptor.py`
- [Tool context](https://github.com/nazeem2001/windows_control_telegram/blob/main/models/tool_context.py): `models/tool_context.py`

### System control

- [Command handlers](https://github.com/nazeem2001/windows_control_telegram/blob/main/features.py): `features.py`

### Reminder service

- [Reminder scheduler](https://github.com/nazeem2001/windows_control_telegram/blob/main/scheduler_manager.py): `scheduler_manager.py`
- [Natural-language parser](https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_parser.py): `reminder_parser.py`
- [Reminder storage](https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_db.py): `reminder_db.py`
- [Reminder execution](https://github.com/nazeem2001/windows_control_telegram/blob/main/reminder_executor.py): `reminder_executor.py`

### Live streaming

- [Streaming server](https://github.com/nazeem2001/windows_control_telegram/blob/main/live_webserver.py): `live_webserver.py`
- [Stream pages](https://github.com/nazeem2001/windows_control_telegram/blob/main/templates/index.html): `templates/index.html`
- [Screen page](https://github.com/nazeem2001/windows_control_telegram/blob/main/templates/screen.html): `templates/screen.html`

### Other components

- **Telegram user**
- **Telegram Bot API**
- **Ollama model**
- **Local system**
- **ngrok tunnel**

## Connections

- Telegram user → Telegram Bot API: sends updates
- Telegram Bot API → Bot entry point: delivers updates
- Bot entry point → Feature router: dispatches commands
- Bot entry point → Reminder scheduler: starts scheduler
- Feature router → Authorization: checks access
- Feature router → Command classifier: predicts command
- Feature router → AI agent and TTS: runs AI mode
- AI agent and TTS → Ollama model: queries model
- AI agent and TTS → Agent tool definitions: builds tools
- Agent tool definitions → Tool adapter: dispatches tools
- Tool adapter → Tool context: uses context
- Tool adapter → Command handlers: calls handler
- Feature router → Command handlers: executes commands
- Command handlers → Local system: controls system
- Feature router → Media and speech: handles media
- Feature router → Streaming server: starts streaming
- Command handlers → ngrok tunnel: opens tunnel
- Command handlers → Reminder scheduler: manages reminders
- Reminder scheduler → Reminder storage: loads and saves
- Reminder scheduler → Reminder execution: schedules execution
- Reminder execution → Reminder storage: reads and deletes
- Reminder execution → Command handlers: runs command
- Command handlers → Natural-language parser: parses reminder
- Streaming server → Stream pages: renders page
- Streaming server → Screen page: renders screen
- Streaming server → Local system: captures camera and screen
- Feature router → Telegram Bot API: sends replies
- Media and speech → Telegram Bot API: downloads media
