Cloud storage powered by Telegram. Store, manage, and share files using Telegram as the storage backend with end-to-end encryption, S3-compatible API, and a modern web interface.
- Unlimited storage — files are stored as encrypted chunks on Telegram
- AES-256-CTR encryption — per-chunk encryption with master secret key management
- Chunked upload/download — support for large files with multi-bot parallel uploads
- File preview — built-in viewers for images, video & audio (Xgplayer), PDF (react-pdf), and code (highlight.js)
- Folder management — create, rename, move, and organize files into folders
- Sharing — generate public share links for files and folders
- Trash bin — soft delete with 7-day auto-cleanup
- S3-compatible API — use
aws-cli,s3cmd, or any S3 client with presigned URL support - Admin dashboard — user management, quota control, system settings
- Multi-language UI — English, Vietnamese, Chinese, Japanese
- Docker deployment — one-command setup with Telegram Local Bot API server
┌──────────────────┐
Users ──────────► │ nginx :80/:443 │
│ (reverse proxy) │
└──┬───────────┬────┘
control plane │ │ data plane
/api/* (most) │ │ /files/*, /s3/*, transfer /api/files/*
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐ ┌──────────┐
│ Backend Core (NestJS) │ │ Backend Transfer (Go) │ │ Frontend │
│ auth, users, folders, │◄─┤ binary I/O: upload+ │ │ Next.js │
│ admin, metadata, quota │─►│ Telegram dispatch, S3 │ │ :3000 │
│ :3001 gRPC :50051 │ │ data plane, ZIP, stream │ └──────────┘
└─────┬──────────┬─────────┘ └────────────┬─────────────┘
│ │ gRPC (bidirectional mTLS)
▼ ▼ ▼
┌──────────┐ ┌────────┐ ┌──────────────┐ ┌────────────────┐
│ Postgres │ │ Redis │ │ nginx :8088 │───►│ telegram-bot- │
│ (Prisma) │ │ (auth, │ │ (file proxy) │ │ api :8081 │
└──────────┘ │ quota, │ └──────────────┘ │ (Local Bot API)│
│ events)│ └────────────────┘
└────────┘
NestJS (control plane) and the Go transfer service (data plane) talk over gRPC with
bidirectional mTLS; they share Redis (auth tokens, quota, the chunked-upload
outstanding counter, and a file:events stream) and Postgres metadata. nginx routes
data-plane paths straight to Go and everything else to NestJS. The Go service can be
split onto its own host(s) for bandwidth — see Horizontal Scaling.
- Docker and Docker Compose (for Docker deployment)
- Node.js 20+ and Go 1.22+ (for local development — NestJS control plane + Go data plane)
- Telegram Bot — create via @BotFather
- Telegram API credentials — get
api_idandapi_hashfrom my.telegram.org - Telegram Channel/Group — add bot as admin, get the chat ID
git clone https://github.com/realldz/tele-drive.git
cd tele-drivecd backend
cp .env.example .env
# Edit .env with your Telegram bot token, chat ID, and secrets
# Start PostgreSQL first, then point DATABASE_URL to it
npm install
npx prisma db push
npm run start:devcd frontend
cp .env.example .env.local
npm install
npm run devOpen http://localhost:3000 in your browser.
# Root .env (for Docker Compose — Telegram API credentials)
cp .env.example .env
# Edit: TELEGRAM_API_ID, TELEGRAM_API_HASH
# These are required for telegram-bot-api to become healthy in Docker
# Backend .env (bot token, chat ID, secrets)
cp backend/.env.example backend/.env
# Edit: TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID, JWT_SECRET, MASTER_SECRETdocker compose up -dAccess at http://localhost.
Compose runs the full stack internally: two app backends plus Postgres, Redis, and the Telegram Local Bot API:
backend-core(NestJS) — auth, users, settings, folders, admin, metadata, quotabackend-transfer(Go) — the binary data plane:/files/*,/s3/*, and transfer-heavy/api/files/*(upload encrypt + Telegram dispatch, S3 object I/O, ZIP assembly, download streaming)
The two talk over gRPC (mTLS) and share Redis + Postgres. Public URLs stay the same because nginx routes each request to the right backend internally.
# Add tunnel token to .env
echo 'CLOUDFLARE_TUNNEL_TOKEN=your_token' >> .env
docker compose --profile tunnel up -dConfigure routing in Cloudflare Zero Trust dashboard:
- Public hostname → Service:
http://nginx:80
.github/workflows/docker-publish.yml builds every image and publishes it to
ghcr.io on each push to master and each v* tag (pull requests only build, to
validate the Dockerfiles). A host can then run those images instead of building.
The bundled installer does exactly this by default now — wizard, env files, then a
pull-first deploy (no compiler on the host):
./install.sh # topology wizard -> env files -> GHCR pull -> up -d
./install.sh --build # compile everything on this host instead
./install.sh --topology=go --image-tag=sha-1a2b3c4 # scripted + pinned release
./install.sh --topology=db # database-only host: Postgres, nothing elseManual commands:
# Private GHCR packages only — skip when the package is public
echo "$GHCR_TOKEN" | docker login ghcr.io -u <github-user> --password-stdin
docker compose -f docker-compose.yml -f docker-compose.ghcr.yml pull
docker compose -f docker-compose.yml -f docker-compose.ghcr.yml up -d| Image | Compose service |
|---|---|
ghcr.io/realldz/tele-drive-backend |
backend-core (NestJS; also the transfer entrypoint) |
ghcr.io/realldz/tele-drive-backend-transfer-go |
backend-transfer (Go data plane) |
ghcr.io/realldz/tele-drive-frontend |
frontend (Next.js standalone) |
ghcr.io/realldz/tele-drive-nginx |
nginx (single-host compose) |
ghcr.io/realldz/tele-drive-nginx-edge |
nginx-edge (control-plane host) |
ghcr.io/realldz/tele-drive-nginx-fastpath |
nginx-fastpath (:8088 Telegram fast path, Go host) |
ghcr.io/realldz/tele-drive-nginx-transfer-public |
nginx-public (standalone transfer domain, Go host) |
Tags: master + latest for branch builds, sha-<short> for every build, and
1.2.3 / 1.2 / 1 for v* tag pushes. Pin TELE_DRIVE_IMAGE_TAG (default
latest) to a release or sha-<short> on production hosts so a restart never
silently changes code.
Multi-host deployments use the matching overlays and the same tag on both hosts:
docker-compose.core.ghcr.yml (control plane) and docker-compose.transfer.ghcr.yml
(data plane). TELE_DRIVE_IMAGE_PREFIX overrides the registry path for forks.
NEXT_PUBLIC_API_URL(repository variable, default/api/v1) is the only frontend build-time value. The dedicated transfer origin and S3 domain are served at runtime by backend-core (GET /api/v1/client-config, sourced fromPUBLIC_TRANSFER_URLandS3_DOMAINinbackend/.env), so enabling them no longer requires rebuilding the frontend image.
| Action | Command |
|---|---|
| Start all | docker compose up -d |
| Stop all | docker compose down |
| Rebuild + restart core API | docker compose up -d --build backend-core |
| Rebuild + restart transfer API | docker compose up -d --build backend-transfer |
| Force rebuild (no cache) | docker compose build --no-cache frontend |
| Force rebuild + restart all | docker compose up -d --build --force-recreate |
| Restart (no rebuild) | docker compose restart frontend |
| View core logs | docker container logs -f tele-drive-backend-core-1 |
| View transfer logs | docker container logs -f tele-drive-backend-transfer-1 |
| Rebuild all | docker compose build |
The default docker-compose.yml runs everything on one host. For heavy traffic you
can split the Go data plane (binary I/O: upload encrypt + Telegram dispatch, S3
object I/O, ZIP assembly, download streaming) onto its own high-bandwidth host,
while the control plane (NestJS core, Postgres, Redis, edge nginx, frontend)
stays small and private on another.
public ─▶ HOST-CORE: nginx-edge :80/:443 ─┬─ backend-core (NestJS) + frontend
│ postgres / redis (private NIC)
│
data-plane HTTP / Redis / gRPC (mTLS) over a PRIVATE network
│
HOST-GO(s): backend-transfer (Go) + telegram-bot-api + nginx-fastpath
(one or more hosts, round-robined by the edge)
Two or three compose files drive it (the database file is optional):
| File | Host | Brings up |
|---|---|---|
docker-compose.core.yml |
control-plane | postgres (skipped with the extdb overlay), redis, backend-core, nginx-edge, frontend |
docker-compose.transfer.yml |
data-plane | backend-transfer (Go), telegram-bot-api, nginx-fastpath |
docker-compose.db.yml |
database-only | postgres, and nothing else |
# On the control-plane host
cp .env.core.example .env.core # set GO_HOST, CORE_PRIVATE_IP, REDIS_PASSWORD, UPLOAD_BUFFER_NFS
docker compose --env-file .env.core -f docker-compose.core.yml up -d
# On the data-plane host (bring up AFTER core — Go waits up to 60s for the core gRPC server)
cp .env.transfer.example .env.transfer # set CORE_HOST, GO_PRIVATE_IP, SAME REDIS_PASSWORD
docker compose --env-file .env.transfer -f docker-compose.transfer.yml up -dGive Postgres its own host (its own storage, backup, and upgrade path) with
docker-compose.db.yml — a single postgres:16-alpine service. No backend, no
Redis, no gRPC certs, no application image built or pulled:
# On the database host. DB_PRIVATE_IP binds the private NIC — never 0.0.0.0.
cp .env.db.example .env.db # set DB_PRIVATE_IP + POSTGRES_PASSWORD
docker compose --env-file .env.db -f docker-compose.db.yml up -d# On the control-plane host, set in .env.core:
# DB_HOST=<db host> DB_PORT=5432 POSTGRES_USER/DB/PASSWORD (SAME password)
# DATABASE_URL=postgresql://tele_drive:<password>@<db host>:5432/tele_drive
docker compose --env-file .env.core \
-f docker-compose.core.yml -f docker-compose.core.extdb.yml up -ddocker-compose.core.extdb.yml profile-gates the core host's own postgres
service out of the project, so the local container is defined but never created
(depends_on ... required: false in the base file makes that legal). Only one
database ever exists, and only the control plane dials it — the Go data plane
reaches Postgres through the core gRPC server.
./install.sh --topology=db performs every db-host step above and prints the
values the core host needs; answering DB_HOST in the core wizard derives
DATABASE_URL into .env.core and adds the overlay for you. Firewall 5432 on the
db host to the core host only. backend-core runs prisma db push at boot, so the
database has to be up before the core host starts.
Requirements and guarantees:
- Private network between the hosts. Redis (password), gRPC (bidirectional
mTLS), and the data-plane HTTP/Telegram ports all bind private NICs only — never
0.0.0.0. Firewall each port to the peer host. - Shared NFS export mounted at
UPLOAD_BUFFER_NFSon both hosts (download-while- draining reads the upload buffer on the Go side). - gRPC certs: run
scripts/gen-grpc-certs.shonce and copycerts/grpc/to both hosts. mTLS hostname verification is pinned to the logical service names (backend-core/backend-transfer), so the same certs work on any host/IP — no per-host SANs needed.
Set GO_UPSTREAM in .env.core to a comma/space-separated list; the edge
round-robins across them with passive health ejection:
GO_UPSTREAM=10.0.0.2:3001,10.0.0.3:3001,10.0.0.4:3001
Each Go host runs its own docker-compose.transfer.yml and shares the control-plane
host's Redis (chunked-upload outstanding counter + file events) and the same NFS
buffer, so a chunked upload spread across hosts still completes correctly. The
Go→NestJS gRPC path already round-robins via dns:///.
Rollback is the untouched single-host docker-compose.yml.
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL |
Yes | postgresql://tele_drive:tele_drive@localhost:5432/tele_drive |
PostgreSQL connection string |
TELEGRAM_BOT_TOKEN |
Yes | — | Bot token from @BotFather |
TELEGRAM_CHAT_ID |
Yes | — | Private channel/group ID |
JWT_SECRET |
Yes | — | JWT signing secret |
MASTER_SECRET |
Yes | — | AES-256-CTR key (32 chars) |
TELEGRAM_API_ROOT |
No | Cloud API | Local Bot API URL |
TELEGRAM_UPLOAD_BOT_TOKENS |
No | — | Extra upload bots (comma-separated) |
TELEGRAM_SEND_RATE_LIMIT |
No | 18 |
Rate limit per bot (msg/min) |
MAX_CHUNK_SIZE |
No | ~19MB | Max chunk size in bytes |
PORT |
No | 3001 |
Server port |
| Variable | Required | Default | Description |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
Yes | http://localhost:3001 |
Backend API URL (/api for Docker) |
| Variable | Required | Description |
|---|---|---|
TELEGRAM_API_ID |
Yes | From my.telegram.org |
TELEGRAM_API_HASH |
Yes | From my.telegram.org |
CLOUDFLARE_TUNNEL_TOKEN |
No | For --profile tunnel |
NGINX_PORT |
No | Nginx exposed port (default: 80) |
NEXT_PUBLIC_API_URL |
No | Frontend API URL, baked at build time (default: /api) |
Tele-Drive exposes an S3-compatible API for integration with standard S3 tools.
# Generate S3 credentials from the web UI (Settings → S3 Keys)
# Configure aws-cli
aws configure --profile tele-drive
# Access Key ID: <from web UI>
# Secret Access Key: <from web UI>
# Usage
aws --profile tele-drive --endpoint-url http://localhost:3001/s3 \
s3 cp ./myfile.pdf s3://my-bucket/myfile.pdf
aws --profile tele-drive --endpoint-url http://localhost:3001/s3 \
s3 ls s3://my-bucket/Supported operations: PutObject, GetObject, DeleteObject, HeadObject, ListObjectsV2, CopyObject, multipart upload, presigned URLs.
Tele-Drive limits concurrent chunk uploads per user (default: 3). aws-cli sends up to 10 multipart parts in parallel by default, which will trigger HTTP 429 errors. Add the following to ~/.aws/config:
[profile tele-drive]
region = us-east-1
s3 =
max_concurrent_requests = 3
multipart_threshold = 64MB
multipart_chunksize = 16MB
cli_read_timeout = 300
cli_connect_timeout = 60| Parameter | Value | Why |
|---|---|---|
max_concurrent_requests |
3 |
Match the server's MAX_CONCURRENT_CHUNKS setting |
multipart_chunksize |
16MB |
Stay below the server's max chunk size (~19 MB) |
multipart_threshold |
64MB |
Only use multipart for files larger than 64 MB |
cli_read_timeout |
300 |
Allow enough time for large chunk uploads on slow connections |
Tele-Drive enforces a per-user limit on concurrent chunk uploads to prevent overloading the Telegram Bot API.
| Setting | Default | Description |
|---|---|---|
MAX_CONCURRENT_CHUNKS |
3 |
Maximum chunks a single user can upload simultaneously |
- Server-side enforcement — When a user exceeds the concurrent chunk limit, the backend returns HTTP 429 Too Many Requests with a
retryAftervalue (seconds). - Client auto-retry — The frontend automatically retries the rejected chunk after waiting
retryAfterseconds, up to 5 attempts per chunk. - Server-driven config — On page load, the frontend fetches
GET /api/files/configto getmaxConcurrentChunksandmaxChunkSize, ensuring the client always respects the current server setting.
Admins can change MAX_CONCURRENT_CHUNKS in the Admin Dashboard → System Settings panel. The change takes effect within 30 seconds (server-side cache TTL).
Note: This limit is per user, not global. Each user can upload up to
MAX_CONCURRENT_CHUNKSchunks at the same time. Files smaller thanmaxChunkSize(~19 MB) are uploaded in a single request and are not affected by this limit.
- Control plane: NestJS + Prisma + PostgreSQL + Telegraf
- Data plane: Go (Echo) — binary upload/download, S3 object I/O, ZIP assembly
- Inter-service: gRPC (bidirectional mTLS) + Redis (shared auth/quota/events)
- Frontend: Next.js 16 + Tailwind CSS + Xgplayer + react-pdf
- Infrastructure: Docker + nginx + Telegram Local Bot API + optional Cloudflare Tunnel
MIT