# scarrymany/tg-manager architecture

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

- Interactive diagram: https://gitdiagram.com/scarrymany/tg-manager
- Repository: https://github.com/scarrymany/tg-manager

## Overview

TG Manager is a portable Windows desktop app for managing isolated Telegram account containers. The main workflow is to create or edit a container, store its metadata and proxy settings, then launch or stop Telegram in that container; users can also run cleanup or session export as background tasks. The WPF UI coordinates account state and task progress, while a separate Python worker handles tdata conversion and cleanup. The README documents several capabilities whose implementation details are not fully shown; those links are included only where documented or supported by the source index.

Main entry points: [`src/TGManager/Windows/MainWindow.xaml.cs`](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/MainWindow.xaml.cs) (Main window), [`src/TGManager/Services/Launcher.cs`](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Launcher.cs) (Telegram launcher), [`tgmanager/automation/worker.py`](https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/worker.py) (Automation worker), [`src/TGManager/Services/WorkerHost.cs`](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/WorkerHost.cs) (Worker host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_main["Main window<br/>[MainWindow.xaml.cs]"]
  node_account_dialog["Account editor"]
  node_cleanup_dialog["Cleanup dialog"]
  node_task_log["Task log"]
  node_account_vm["Account state<br/>[AccountVm.cs]"]
  node_task_vm["Task state<br/>[TaskVm.cs]"]
end

subgraph group_accounts["Accounts and launch"]
  node_store[("Account store<br/>[Store.cs]")]
  node_models["Account models<br/>[Models.cs]"]
  node_paths["Portable paths<br/>[Paths.cs]"]
  node_proxy_parse["Proxy parser<br/>[ProxyParse.cs]"]
  node_launcher["Telegram launcher<br/>[Launcher.cs]"]
end

subgraph group_automation["Automation worker"]
  node_worker_host["Worker host<br/>[WorkerHost.cs]"]
  node_worker["Automation worker<br/>[worker.py]"]
  node_lock["Session lock<br/>[lock.py]"]
  node_export["Session export<br/>[export_session.py]"]
  node_session_pack["Session pack<br/>[session_pack.py]"]
end

subgraph group_platform["Platform services"]
  node_process["Process control<br/>[ProcessUtil.cs]"]
  node_bridge["HTTP proxy bridge<br/>[HttpBridge.cs]"]
end

node_user(("User"))
node_proxychains["ProxyChains"]
node_telegram["Telegram Desktop"]
node_tdata[("Container tdata")]
node_telegram_service["Telegram service"]

node_user -->|"uses"| node_main
node_main -->|"loads and updates"| node_store
node_main -->|"updates"| node_account_vm
node_main -->|"opens"| node_account_dialog
node_account_dialog -->|"parses proxy"| node_proxy_parse
node_main -->|"starts and stops"| node_launcher
node_launcher -->|"resolves paths"| node_paths
node_launcher -->|"starts HTTP bridge"| node_bridge
node_launcher -->|"launches through"| node_proxychains
node_proxychains -->|"wraps process"| node_telegram
node_launcher -->|"launches isolated"| node_telegram
node_main -->|"starts automation"| node_worker_host
node_main -->|"opens"| node_cleanup_dialog
node_cleanup_dialog -->|"configures task"| node_worker_host
node_task_vm -->|"starts worker"| node_worker_host
node_main -->|"tracks tasks"| node_task_vm
node_task_log -->|"displays progress"| node_task_vm
node_worker_host -->|"starts process"| node_worker
node_worker_host -->|"resolves workdir"| node_paths
node_worker -->|"reads and cleans"| node_tdata
node_worker -->|"uses session lock"| node_lock
node_worker -->|"dispatches export"| node_export
node_export -->|"builds archive"| node_session_pack
node_export -->|"converts session"| node_tdata
node_worker -->|"connects for actions"| node_telegram_service
node_bridge -->|"forwards HTTP CONNECT"| node_telegram_service
node_process -->|"terminates process"| node_telegram
node_store -->|"stores config at"| node_paths

click node_main "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/MainWindow.xaml.cs"
click node_account_dialog "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/AccountWindow.xaml.cs"
click node_cleanup_dialog "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/CleanupWindow.xaml.cs"
click node_task_log "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/TaskLogWindow.xaml.cs"
click node_account_vm "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/ViewModels/AccountVm.cs"
click node_task_vm "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/ViewModels/TaskVm.cs"
click node_store "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Store.cs"
click node_models "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Models.cs"
click node_paths "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Paths.cs"
click node_proxy_parse "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/ProxyParse.cs"
click node_launcher "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Launcher.cs"
click node_process "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/ProcessUtil.cs"
click node_bridge "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/HttpBridge.cs"
click node_worker_host "https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/WorkerHost.cs"
click node_worker "https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/worker.py"
click node_lock "https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/lock.py"
click node_export "https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/export_session.py"
click node_session_pack "https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/session_pack.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_account_dialog,node_cleanup_dialog,node_task_log,node_account_vm,node_task_vm,node_user toneBlue
class node_store,node_models,node_paths,node_proxy_parse,node_launcher,node_tdata toneAmber
class node_worker_host,node_worker,node_lock,node_export,node_session_pack toneMint
class node_process,node_bridge toneRose
class node_proxychains,node_telegram,node_telegram_service toneIndigo
```

## Components

### Desktop interface

- [Main window](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/MainWindow.xaml.cs): `src/TGManager/Windows/MainWindow.xaml.cs`
- [Account editor](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/AccountWindow.xaml.cs): `src/TGManager/Windows/AccountWindow.xaml.cs`
- [Cleanup dialog](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/CleanupWindow.xaml.cs): `src/TGManager/Windows/CleanupWindow.xaml.cs`
- [Task log](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Windows/TaskLogWindow.xaml.cs): `src/TGManager/Windows/TaskLogWindow.xaml.cs`
- [Account state](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/ViewModels/AccountVm.cs): `src/TGManager/ViewModels/AccountVm.cs`
- [Task state](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/ViewModels/TaskVm.cs): `src/TGManager/ViewModels/TaskVm.cs`

### Accounts and launch

- [Account store](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Store.cs): `src/TGManager/Services/Store.cs`
- [Account models](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Models.cs): `src/TGManager/Services/Models.cs`
- [Portable paths](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Paths.cs): `src/TGManager/Services/Paths.cs`
- [Proxy parser](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/ProxyParse.cs): `src/TGManager/Services/ProxyParse.cs`
- [Telegram launcher](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/Launcher.cs): `src/TGManager/Services/Launcher.cs`

### Automation worker

- [Worker host](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/WorkerHost.cs): `src/TGManager/Services/WorkerHost.cs`
- [Automation worker](https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/worker.py): `tgmanager/automation/worker.py`
- [Session lock](https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/lock.py): `tgmanager/automation/lock.py`
- [Session export](https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/export_session.py): `tgmanager/automation/export_session.py`
- [Session pack](https://github.com/scarrymany/tg-manager/blob/main/tgmanager/automation/session_pack.py): `tgmanager/automation/session_pack.py`

### Platform services

- [Process control](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/ProcessUtil.cs): `src/TGManager/Services/ProcessUtil.cs`
- [HTTP proxy bridge](https://github.com/scarrymany/tg-manager/blob/main/src/TGManager/Services/HttpBridge.cs): `src/TGManager/Services/HttpBridge.cs`

### Other components

- **User**
- **ProxyChains**
- **Telegram Desktop**
- **Container tdata**
- **Telegram service**

## Connections

- User → Main window: uses (evidence: `README.md`)
- Main window → Account store: loads and updates (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Main window → Account state: updates (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Main window → Account editor: opens (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Account editor → Proxy parser: parses proxy (evidence: `src/TGManager/Windows/AccountWindow.xaml.cs`)
- Main window → Telegram launcher: starts and stops (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Telegram launcher → Portable paths: resolves paths (evidence: `src/TGManager/Services/Launcher.cs`)
- Telegram launcher → HTTP proxy bridge: starts HTTP bridge (evidence: `src/TGManager/Services/Launcher.cs`)
- Telegram launcher → ProxyChains: launches through (evidence: `README.md`)
- ProxyChains → Telegram Desktop: wraps process (evidence: `README.md`)
- Telegram launcher → Telegram Desktop: launches isolated (evidence: `README.md`)
- Main window → Worker host: starts automation (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Main window → Cleanup dialog: opens (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Cleanup dialog → Worker host: configures task (evidence: `src/TGManager/Windows/CleanupWindow.xaml.cs`)
- Task state → Worker host: starts worker (evidence: `src/TGManager/ViewModels/TaskVm.cs`)
- Main window → Task state: tracks tasks (evidence: `src/TGManager/Windows/MainWindow.xaml.cs`)
- Task log → Task state: displays progress (evidence: `src/TGManager/Windows/TaskLogWindow.xaml.cs`)
- Worker host → Automation worker: starts process (evidence: `README.md`)
- Worker host → Portable paths: resolves workdir (evidence: `src/TGManager/Services/WorkerHost.cs`)
- Automation worker → Container tdata: reads and cleans (evidence: `README.md`)
- Automation worker → Session lock: uses session lock (evidence: `tgmanager/automation/worker.py`)
- Automation worker → Session export: dispatches export (evidence: `tgmanager/automation/worker.py`)
- Session export → Session pack: builds archive (evidence: `tgmanager/automation/export_session.py`)
- Session export → Container tdata: converts session (evidence: `README.md`)
- Automation worker → Telegram service: connects for actions (evidence: `README.md`)
- HTTP proxy bridge → Telegram service: forwards HTTP CONNECT (evidence: `README.md`)
- Process control → Telegram Desktop: terminates process (evidence: `README.md`)
- Account store → Portable paths: stores config at (evidence: `src/TGManager/Services/Store.cs`)
