Secure Private Cloud Storage via Telegram Backend
TeleVault is a self-hosted, private cloud storage system that uses Telegram as a raw byte storage layer. Users interact exclusively through a modern, responsive local web application. Telegram is never accessed directly by the end user for file operations.
All files uploaded to Telegram are unrecognizable, AES-256 encrypted, and fragmented. They have absolutely no value without the local system to reconstruct them.
- Zero Trust Architecture: Files are chunked and encrypted before leaving your machine. Telegram only stores nameless, encrypted binary blobs.
- Local Sovereignty: All file metadata, search indexes, chunk maps, and encryption keys stay on your local PostgreSQL/SQLite database.
- Unlimited Storage: Store as much data as you want, leveraging Telegram's massive cloud infrastructure.
- Resumable Transfers: Built-in fault tolerance. If your server crashes or network disconnects, uploads and downloads resume exactly where they left off.
- Lightning Fast Search: Search your files by name or custom tags instantly without querying Telegram.
Before starting, ensure you have the following software installed on your machine. Here is where you can download them:
- Git: Required to download the repository. Download Git here.
- Docker Desktop: Required to run the database (PostgreSQL) and job queue (Redis) seamlessly. It includes Docker Compose. Download Docker here.
- Node.js (v18+): Required to build and run the frontend Web UI. Download Node.js here.
- Python (v3.11+): Required to run the FastApi backend and chunking engine. (Note for Windows users: Make sure to check the box "Add Python to PATH" during installation). Download Python here.
Download the project source code from GitHub:
git clone https://github.com/yourusername/televault.git
cd televaultTeleVault requires a few libraries for both the backend and frontend.
1. Install Backend Dependencies (Python):
Open your terminal inside the televault folder and run:
cd backend
pip install -r requirements.txt
cd ..Manual Fallback: If the command above fails, you can manually install the required libraries by running:
pip install fastapi "uvicorn[standard]" pydantic pydantic-settings "sqlalchemy[asyncio]" asyncpg alembic redis arq telethon cryptography argon2-cffi "python-jose[cryptography]" python-multipart httpx aiofiles aiosqlite loguru2. Install Frontend Dependencies (Node.js): In the same terminal, run:
cd frontend
npm install
cd ..To let TeleVault communicate with Telegram, you need an API ID and Hash.
- Go to my.telegram.org and log in with your Telegram phone number.
- Click on "API development tools".
- Fill out the form (you can enter anything for the App title and Short name).
- Click Create application.
- Copy your
App api_idandApp api_hash. Keep these secret!
This is where TeleVault will store the encrypted file chunks.
- Open your Telegram app.
- Create a New Channel.
- Name it something like "TeleVault Storage" and set the Channel Type to Private.
- You need the Channel ID (it must start with
-100).- Tip to get the Channel ID: Log into Telegram Web (web.telegram.org/a/), open the channel, and look at the URL. It will look like
https://web.telegram.org/a/#-1001234567890. Copy the-100...number.
- Tip to get the Channel ID: Log into Telegram Web (web.telegram.org/a/), open the channel, and look at the URL. It will look like
-
Copy the sample environment file:
cp .env.example .env
-
Open
.envand fill in your details:TELEGRAM_API_ID=your_api_id TELEGRAM_API_HASH=your_api_hash TELEGRAM_STORAGE_CHANNEL_ID=-100...
-
Generate Secure Passwords: Your
.envfile contains fields likePOSTGRES_PASSWORD,REDIS_PASSWORD, andSECRET_KEY. You must replace the defaultchange_mevalues with your own strong, randomly generated passwords to keep your storage safe. Recommendation: To easily generate a cryptographically secure 32-character hex string for yourSECRET_KEYand passwords, run one of these commands in your terminal:# Using OpenSSL: openssl rand -hex 32 # OR using Python: python -c "import secrets; print(secrets.token_hex(32))"
-
Generate the Telegram Session String: To allow TeleVault to upload files seamlessly in the background without constantly asking you for an SMS login code, you need a session string. Make sure you have Python installed, then open your terminal and run:
pip install telethon python -c "from telethon.sync import TelegramClient; from telethon.sessions import StringSession; c=TelegramClient(StringSession(),'YOUR_API_ID','YOUR_API_HASH'); c.start(); print(c.session.save())"(Make sure to replace
YOUR_API_IDandYOUR_API_HASHwith the credentials you got in Step 3). It will ask you for your phone number and the login code Telegram sends you. After you log in, it will print a very long string of random characters. Copy that entire string and paste it into your.envfile like this:TELEGRAM_SESSION_STRING=1BVts...
TeleVault comes with handy startup scripts for both Windows and Linux/macOS.
On Windows (PowerShell or CMD):
.\televault.ps1 start
# OR
.\televault.bat startThis script will automatically start the Docker containers (for the database and Redis), launch the FastAPI backend, and start the Vite frontend server.
Once the services are running, open your browser and navigate to: http://localhost:5173
The first time you access the UI, you'll set a Master Password. Do not lose this password! It is used to derive the Key Encryption Key (KEK). If you lose it, your files will be permanently unrecoverable.
TeleVault is split into three main components:
- Frontend (React/Vite): A stunning, responsive UI to manage your files, view transfers, and search metadata.
- Backend (FastAPI): Orchestrates file chunking, AES-256 encryption, HMAC integrity verification, and database interactions.
- Storage Layer (Telegram MTProto): The backend uses
Telethonto securely stream encrypted chunks directly into your private Telegram channel.
- Data at Rest (Telegram): Chunked, Obfuscated, AES-256-CBC Encrypted.
- Data in Transit: TLS secured (MTProto).
- Integrity Verification: Every downloaded chunk is verified against an HMAC-SHA256 signature before decryption to prevent tampering.
- Local Keys: Keys are stored locally, encrypted by a master password using Argon2id.
TeleVault provides a unified control script (televault.ps1 for Windows PowerShell, or televault.bat). Running the script opens an interactive menu that manages the entire lifecycle:
- Start TeleDrive: Launches the FastAPI backend and Vite frontend in separate terminal windows so you can monitor logs live.
- Start in Background: Runs both services in the background without opening new windows. Real-time logs are instead routed to
logs/backend.logandlogs/frontend.log. - Stop TeleDrive: Safely kills all TeleDrive background processes and free up the network ports.
- Check Status Details: Shows exactly whether the Backend (Port 8000) and Frontend (Port 5173) are running, including their Windows Process IDs.
When you drag and drop a file into the TeleVault UI, here is what happens entirely locally on your machine:
- Key Derivation: Your master password drives an Argon2id algorithm to decrypt a unique AES-256 key and HMAC-SHA256 key for that specific file.
- Chunking: The file is split into 1.5 MB pieces to adhere to Telegram's limits and maximize upload speed.
- Encryption: Each chunk is individually encrypted using AES-256-CBC with a random, unique Initialization Vector (IV).
- Integrity Tagging: A cryptographic HMAC tag is appended to the encrypted chunk to prevent tampering.
- Upload to Telegram: The
TelethonMTProto client streams the meaningless chunks to your private Telegram channel. - Indexing: A chunk map (mapping chunk sequence order to Telegram Message IDs) is saved securely to your local PostgreSQL database.
Q: I lost my Master Password. Can I recover my files?
No. The Master Password is not stored anywhere in the database or code. It drives the Key Encryption Key (KEK) used to decrypt your AES file keys. If you lose it, your data is mathematically unrecoverable.
Q: Why did an upload fail with FloodWaitError?
Telegram has strict API rate limits. TeleVault automatically handles this by pausing and retrying after a cooldown period, but if you upload thousands of files instantly, Telegram may block the API client temporarily. The system will recover automatically.
Q: My frontend doesn't start; port 5173 is in use.
Run .\teledrive.ps1 status to see what is running. If another background process is using port 5173, you'll need to stop it or edit vite.config.js to map to a different port.
MIT License. See LICENSE for details.