# jeetrex17/tdrive architecture

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

- Interactive diagram: https://gitdiagram.com/jeetrex17/tdrive
- Repository: https://github.com/jeetrex17/tdrive

## Overview

TDrive is a desktop/mobile file manager and CLI that uses a user's Telegram account as drive storage. The principal workflow is to authenticate, select a personal or shared drive, organize or transfer files, and preview or stream them; the README also documents encrypted backup, mounts, live sync, and recovery. The graph combines those documented capabilities with sampled frontend bridge and photo-backup code. Several backend subsystem links are documented capabilities rather than inspected call paths, so those edges are dashed with no evidence path.

Main entry points: [`frontend/src/main.ts`](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/main.ts) (Desktop/mobile UI), [`frontend/bindings/TDrive/app.ts`](https://github.com/jeetrex17/tdrive/blob/master/frontend/bindings/TDrive/app.ts) (Wails bindings), [`backend/services/file/service.go`](https://github.com/jeetrex17/tdrive/blob/master/backend/services/file/service.go) (File and folder operations), [`backend/tgclient/client.go`](https://github.com/jeetrex17/tdrive/blob/master/backend/tgclient/client.go) (Telegram client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["App and CLI"]
  node_desktopmobile["Desktop/mobile UI<br/>[main.ts]"]
  node_api["Frontend API<br/>[api.ts]"]
  node_bindings["Wails bindings<br/>[app.ts]"]
  node_cli["Scriptable CLI<br/>[main.go]"]
end

subgraph group_services["Drive services"]
  node_auth["Authentication<br/>[auth.go]"]
  node_fileops["File and folder operations<br/>[service.go]"]
  node_channels["Drive sharing<br/>[service.go]"]
  node_encryption["Vault encryption<br/>[service.go]"]
  node_projection["Drive projection<br/>[read.go]"]
end

subgraph group_storage["Telegram and state"]
  node_telegram(("Telegram account"))
  node_tgclient["Telegram client<br/>[client.go]"]
  node_sqlite[("Local SQLite state<br/>[storage_sqlite.go]")]
  node_sync["Live synchronization<br/>[sync.go]"]
end

subgraph group_media["Gallery and media"]
  node_gallery["Photo gallery<br/>[gallery.go]"]
  node_media["Media streaming<br/>[server.go]"]
  node_thumbnails["Image thumbnails<br/>[generate.go]"]
end

subgraph group_platform["Backup and mount"]
  node_backupui["Backup controls<br/>[controller.ts]"]
  node_backupapi["Backup API<br/>[photo-backup.ts]"]
  node_backupengine["Backup engine<br/>[engine.go]"]
  node_mountui["Mount controls"]
  node_mount["Drive mount<br/>[controller.go]"]
  node_webdav["Local WebDAV<br/>[server.go]"]
end

node_person(("User"))

node_person -->|"uses"| node_desktopmobile
node_person -->|"scripts with"| node_cli
node_desktopmobile -.->|"requests"| node_api
node_api -.->|"invokes"| node_bindings
node_bindings -.->|"dispatches to"| node_auth
node_bindings -.->|"dispatches to"| node_fileops
node_cli -.->|"runs transfers"| node_fileops
node_auth -.->|"authenticates with"| node_telegram
node_fileops -.->|"transfers through"| node_tgclient
node_tgclient -->|"reads and writes"| node_telegram
node_channels -->|"hosts shared drives"| node_telegram
node_fileops -.->|"updates drive state"| node_projection
node_projection -.->|"persists state"| node_sqlite
node_sync -->|"observes activity"| node_telegram
node_sync -->|"rebuilds local state"| node_sqlite
node_encryption -->|"encrypts contents"| node_fileops
node_desktopmobile -->|"browses photos"| node_gallery
node_gallery -.->|"loads media"| node_tgclient
node_desktopmobile -->|"streams previews"| node_media
node_media -->|"streams from"| node_tgclient
node_media -.->|"generates previews"| node_thumbnails
node_desktopmobile -->|"configures backup"| node_backupui
node_backupui -->|"calls"| node_backupapi
node_backupapi -->|"invokes"| node_bindings
node_bindings -.->|"dispatches to"| node_backupengine
node_backupengine -.->|"uploads assets"| node_tgclient
node_desktopmobile -->|"controls"| node_mountui
node_mountui -.->|"requests mount"| node_mount
node_mount -->|"serves endpoint"| node_webdav
node_webdav -->|"exposes mounted drive"| node_person

click node_desktopmobile "https://github.com/jeetrex17/tdrive/blob/master/frontend/src/main.ts"
click node_api "https://github.com/jeetrex17/tdrive/blob/master/frontend/src/api.ts"
click node_bindings "https://github.com/jeetrex17/tdrive/blob/master/frontend/bindings/TDrive/app.ts"
click node_cli "https://github.com/jeetrex17/tdrive/blob/master/cmd/tdrive/main.go"
click node_auth "https://github.com/jeetrex17/tdrive/blob/master/backend/auth/auth.go"
click node_fileops "https://github.com/jeetrex17/tdrive/blob/master/backend/services/file/service.go"
click node_channels "https://github.com/jeetrex17/tdrive/blob/master/backend/services/channel/service.go"
click node_encryption "https://github.com/jeetrex17/tdrive/blob/master/backend/services/encryption/service.go"
click node_projection "https://github.com/jeetrex17/tdrive/blob/master/backend/projection/read.go"
click node_tgclient "https://github.com/jeetrex17/tdrive/blob/master/backend/tgclient/client.go"
click node_sqlite "https://github.com/jeetrex17/tdrive/blob/master/backend/storage_sqlite.go"
click node_sync "https://github.com/jeetrex17/tdrive/blob/master/backend/sync/sync.go"
click node_gallery "https://github.com/jeetrex17/tdrive/blob/master/backend/projection/gallery.go"
click node_media "https://github.com/jeetrex17/tdrive/blob/master/backend/media/server.go"
click node_thumbnails "https://github.com/jeetrex17/tdrive/blob/master/backend/thumbnail/generate.go"
click node_backupui "https://github.com/jeetrex17/tdrive/blob/master/frontend/src/modules/photo-backup/controller.ts"
click node_backupapi "https://github.com/jeetrex17/tdrive/blob/master/frontend/src/api/photo-backup.ts"
click node_backupengine "https://github.com/jeetrex17/tdrive/blob/master/backend/photobackup/engine.go"
click node_mountui "https://github.com/jeetrex17/tdrive/blob/master/frontend/src/ui/mount/mount-controller.ts"
click node_mount "https://github.com/jeetrex17/tdrive/blob/master/backend/mountcontroller/controller.go"
click node_webdav "https://github.com/jeetrex17/tdrive/blob/master/backend/mountdav/server.go"

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_desktopmobile,node_api,node_bindings,node_cli,node_person toneBlue
class node_auth,node_fileops,node_channels,node_encryption,node_projection toneAmber
class node_telegram,node_tgclient,node_sqlite,node_sync toneMint
class node_gallery,node_media,node_thumbnails toneRose
class node_backupui,node_backupapi,node_backupengine,node_mountui,node_mount,node_webdav toneIndigo
```

## Components

### App and CLI

- [Desktop/mobile UI](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/main.ts): `frontend/src/main.ts`
- [Frontend API](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/api.ts): `frontend/src/api.ts`
- [Wails bindings](https://github.com/jeetrex17/tdrive/blob/master/frontend/bindings/TDrive/app.ts): `frontend/bindings/TDrive/app.ts`
- [Scriptable CLI](https://github.com/jeetrex17/tdrive/blob/master/cmd/tdrive/main.go): `cmd/tdrive/main.go`

### Drive services

- [Authentication](https://github.com/jeetrex17/tdrive/blob/master/backend/auth/auth.go): `backend/auth/auth.go`
- [File and folder operations](https://github.com/jeetrex17/tdrive/blob/master/backend/services/file/service.go): `backend/services/file/service.go`
- [Drive sharing](https://github.com/jeetrex17/tdrive/blob/master/backend/services/channel/service.go): `backend/services/channel/service.go`
- [Vault encryption](https://github.com/jeetrex17/tdrive/blob/master/backend/services/encryption/service.go): `backend/services/encryption/service.go`
- [Drive projection](https://github.com/jeetrex17/tdrive/blob/master/backend/projection/read.go): `backend/projection/read.go`

### Telegram and state

- **Telegram account**
- [Telegram client](https://github.com/jeetrex17/tdrive/blob/master/backend/tgclient/client.go): `backend/tgclient/client.go`
- [Local SQLite state](https://github.com/jeetrex17/tdrive/blob/master/backend/storage_sqlite.go): `backend/storage_sqlite.go`
- [Live synchronization](https://github.com/jeetrex17/tdrive/blob/master/backend/sync/sync.go): `backend/sync/sync.go`

### Gallery and media

- [Photo gallery](https://github.com/jeetrex17/tdrive/blob/master/backend/projection/gallery.go): `backend/projection/gallery.go`
- [Media streaming](https://github.com/jeetrex17/tdrive/blob/master/backend/media/server.go): `backend/media/server.go`
- [Image thumbnails](https://github.com/jeetrex17/tdrive/blob/master/backend/thumbnail/generate.go): `backend/thumbnail/generate.go`

### Backup and mount

- [Backup controls](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/modules/photo-backup/controller.ts): `frontend/src/modules/photo-backup/controller.ts`
- [Backup API](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/api/photo-backup.ts): `frontend/src/api/photo-backup.ts`
- [Backup engine](https://github.com/jeetrex17/tdrive/blob/master/backend/photobackup/engine.go): `backend/photobackup/engine.go`
- [Mount controls](https://github.com/jeetrex17/tdrive/blob/master/frontend/src/ui/mount/mount-controller.ts): `frontend/src/ui/mount/mount-controller.ts`
- [Drive mount](https://github.com/jeetrex17/tdrive/blob/master/backend/mountcontroller/controller.go): `backend/mountcontroller/controller.go`
- [Local WebDAV](https://github.com/jeetrex17/tdrive/blob/master/backend/mountdav/server.go): `backend/mountdav/server.go`

### Other components

- **User**

## Connections

- User → Desktop/mobile UI: uses (evidence: `README.md`)
- User → Scriptable CLI: scripts with (evidence: `README.md`)
- Desktop/mobile UI → Frontend API: requests
- Frontend API → Wails bindings: invokes
- Wails bindings → Authentication: dispatches to
- Wails bindings → File and folder operations: dispatches to
- Scriptable CLI → File and folder operations: runs transfers
- Authentication → Telegram account: authenticates with
- File and folder operations → Telegram client: transfers through
- Telegram client → Telegram account: reads and writes (evidence: `README.md`)
- Drive sharing → Telegram account: hosts shared drives (evidence: `README.md`)
- File and folder operations → Drive projection: updates drive state
- Drive projection → Local SQLite state: persists state
- Live synchronization → Telegram account: observes activity (evidence: `README.md`)
- Live synchronization → Local SQLite state: rebuilds local state (evidence: `README.md`)
- Vault encryption → File and folder operations: encrypts contents (evidence: `README.md`)
- Desktop/mobile UI → Photo gallery: browses photos (evidence: `README.md`)
- Photo gallery → Telegram client: loads media
- Desktop/mobile UI → Media streaming: streams previews (evidence: `README.md`)
- Media streaming → Telegram client: streams from (evidence: `README.md`)
- Media streaming → Image thumbnails: generates previews
- Desktop/mobile UI → Backup controls: configures backup (evidence: `README.md`)
- Backup controls → Backup API: calls (evidence: `frontend/src/modules/photo-backup/controller.ts`)
- Backup API → Wails bindings: invokes (evidence: `frontend/src/api/photo-backup.ts`)
- Wails bindings → Backup engine: dispatches to
- Backup engine → Telegram client: uploads assets
- Desktop/mobile UI → Mount controls: controls (evidence: `README.md`)
- Mount controls → Drive mount: requests mount
- Drive mount → Local WebDAV: serves endpoint (evidence: `README.md`)
- Local WebDAV → User: exposes mounted drive (evidence: `README.md`)
