# viperadnan-git/google-drive-telegram-bot architecture

> Architecture diagram of the GitHub repository viperadnan-git/google-drive-telegram-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/viperadnan-git/google-drive-telegram-bot
- Repository: https://github.com/viperadnan-git/google-drive-telegram-bot

## Overview

This is a Telegram bot that moves user files into Google Drive. Its main workflow accepts a Telegram file or a direct URL, downloads the content when needed, uploads it to the user’s Drive, and reports the result. Users can also authorize Drive access, choose a destination folder, copy Drive files, and delete files or empty trash. The sampled code shows the download/upload, authorization, and folder-setting paths; copy and delete are documented capabilities with plugin files present, but their implementations were not sampled.

Main entry points: [`bot/helpers/gdrive_utils/gDrive.py`](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/gdrive_utils/gDrive.py) (Drive client), [`bot/plugins/download.py`](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/download.py) (Download handlers), [`bot/plugins/set_parent.py`](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/set_parent.py) (Folder settings), [`bot/plugins/authorize.py`](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/authorize.py) (Authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interface"]
  node_download_handler["Download handlers<br/>[download.py]"]
  node_auth_handler["Authorization<br/>[authorize.py]"]
  node_folder_handler["Folder settings<br/>[set_parent.py]"]
  node_copy_handler["Copy commands<br/>[copy.py]"]
  node_delete_handler["Delete commands<br/>[delete.py]"]
  node_help_handler["Help commands<br/>[help.py]"]
  node_auth_filter["Auth filter<br/>[utils.py]"]
end

subgraph group_transfer["File transfer"]
  node_downloader["URL and video downloader<br/>[downloader.py]"]
end

subgraph group_drive["Google Drive operations"]
  node_drive_client["Drive client<br/>[gDrive.py]"]
end

subgraph group_state["Configuration and state"]
  node_drive_creds[("Drive credentials<br/>[gDriveDB.py]")]
  node_parent_ids[("Upload folder state<br/>[idsDB.py]")]
  node_config["Bot configuration<br/>[config.py]"]
end

node_user(("Telegram user"))
node_telegram_api{{"Telegram"}}
node_url_sources{{"Direct and video sources"}}
node_google_drive{{"Google Drive"}}

node_user -->|"sends files or links"| node_download_handler
node_user -->|"authorizes account"| node_auth_handler
node_user -->|"sets folder"| node_folder_handler
node_download_handler -->|"downloads URL"| node_downloader
node_download_handler -->|"downloads Telegram file"| node_telegram_api
node_downloader -->|"fetches media"| node_url_sources
node_download_handler -->|"uploads or clones"| node_drive_client
node_drive_client -->|"calls Drive API"| node_google_drive
node_auth_handler -->|"stores credentials"| node_drive_creds
node_drive_client -->|"loads credentials"| node_drive_creds
node_drive_client -->|"loads destination"| node_parent_ids
node_folder_handler -->|"checks folder link"| node_drive_client
node_folder_handler -->|"updates folder state"| node_parent_ids
node_download_handler -->|"requires authorization"| node_auth_filter
node_auth_handler -->|"uses OAuth settings"| node_config
node_folder_handler -->|"requires authorization"| node_auth_filter
node_copy_handler -.->|"copies Drive items"| node_drive_client
node_delete_handler -.->|"deletes or empties trash"| node_drive_client
node_user -->|"requests copy"| node_copy_handler
node_user -->|"requests deletion"| node_delete_handler
node_user -.->|"requests help"| node_help_handler

click node_download_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/download.py"
click node_auth_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/authorize.py"
click node_folder_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/set_parent.py"
click node_copy_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/copy.py"
click node_delete_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/delete.py"
click node_help_handler "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/help.py"
click node_auth_filter "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/utils.py"
click node_downloader "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/downloader.py"
click node_drive_client "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/gdrive_utils/gDrive.py"
click node_drive_creds "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/sql_helper/gDriveDB.py"
click node_parent_ids "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/sql_helper/idsDB.py"
click node_config "https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/config.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_download_handler,node_auth_handler,node_folder_handler,node_copy_handler,node_delete_handler,node_help_handler,node_auth_filter,node_user toneBlue
class node_downloader toneAmber
class node_drive_client toneMint
class node_drive_creds,node_parent_ids,node_config toneRose
class node_telegram_api,node_url_sources,node_google_drive toneIndigo
```

## Components

### Telegram interface

- [Download handlers](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/download.py): `bot/plugins/download.py`
- [Authorization](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/authorize.py): `bot/plugins/authorize.py`
- [Folder settings](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/set_parent.py): `bot/plugins/set_parent.py`
- [Copy commands](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/copy.py): `bot/plugins/copy.py`
- [Delete commands](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/delete.py): `bot/plugins/delete.py`
- [Help commands](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/plugins/help.py): `bot/plugins/help.py`
- [Auth filter](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/utils.py): `bot/helpers/utils.py`

### File transfer

- [URL and video downloader](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/downloader.py): `bot/helpers/downloader.py`

### Google Drive operations

- [Drive client](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/gdrive_utils/gDrive.py): `bot/helpers/gdrive_utils/gDrive.py`

### Configuration and state

- [Drive credentials](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/sql_helper/gDriveDB.py): `bot/helpers/sql_helper/gDriveDB.py`
- [Upload folder state](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/helpers/sql_helper/idsDB.py): `bot/helpers/sql_helper/idsDB.py`
- [Bot configuration](https://github.com/viperadnan-git/google-drive-telegram-bot/blob/main/bot/config.py): `bot/config.py`

### Other components

- **Telegram user**
- **Telegram**
- **Direct and video sources**
- **Google Drive**

## Connections

- Telegram user → Download handlers: sends files or links (evidence: `README.md`)
- Telegram user → Authorization: authorizes account (evidence: `README.md`)
- Telegram user → Folder settings: sets folder (evidence: `README.md`)
- Download handlers → URL and video downloader: downloads URL (evidence: `bot/plugins/download.py`)
- Download handlers → Telegram: downloads Telegram file (evidence: `bot/plugins/download.py`)
- URL and video downloader → Direct and video sources: fetches media (evidence: `bot/helpers/downloader.py`)
- Download handlers → Drive client: uploads or clones (evidence: `bot/plugins/download.py`)
- Drive client → Google Drive: calls Drive API (evidence: `bot/helpers/gdrive_utils/gDrive.py`)
- Authorization → Drive credentials: stores credentials (evidence: `bot/plugins/authorize.py`)
- Drive client → Drive credentials: loads credentials (evidence: `bot/helpers/gdrive_utils/gDrive.py`)
- Drive client → Upload folder state: loads destination (evidence: `bot/helpers/gdrive_utils/gDrive.py`)
- Folder settings → Drive client: checks folder link (evidence: `bot/plugins/set_parent.py`)
- Folder settings → Upload folder state: updates folder state (evidence: `bot/plugins/set_parent.py`)
- Download handlers → Auth filter: requires authorization (evidence: `bot/plugins/download.py`)
- Authorization → Bot configuration: uses OAuth settings (evidence: `bot/plugins/authorize.py`)
- Folder settings → Auth filter: requires authorization (evidence: `bot/plugins/set_parent.py`)
- Copy commands → Drive client: copies Drive items
- Delete commands → Drive client: deletes or empties trash
- Telegram user → Copy commands: requests copy (evidence: `README.md`)
- Telegram user → Delete commands: requests deletion (evidence: `README.md`)
- Telegram user → Help commands: requests help
