This is the backend beast that powers the
This is the tactical client that completes the ecosystem. It connects seamlessly with
BodyaSync-Compose, replaces the fallen
BodyaSync-Server, Backend
BodyaSync-Gallery(Flutter),
and is the frontend for the BodyaGram App.
This isn't just a file server. It's a highly optimized media processing unit designed to run on anything from a high-end rack server to a Raspberry Pi in a shoebox.
It handles the dirty work: compressing images, managing storage, generating AI memories, and "smuggling" files directly into Telegram so your phone doesn't have to lifting a finger.
Your hard drives make noise and eat power. We hate that.
- The Solution: This server loads thumbnails and metadata directly into RAM.
- The Result: Your HDDs stay parked (sleeping). Browsing the gallery is silent and instant. We only wake up the drives when you actually download a full-size original.
- Photos: Converted to WebP. Quality 70-75%. Size ~5-10KB.
- Videos: FFmpeg generates instant snapshots.
- Network: Optimized so you can browse 10,000 photos over a weak 3G connection without lagging.
It doesn't just store files; it remembers.
- Captioning: Uses Gradio/HuggingFace to see what's in your photos.
- Storytelling: Uses Ollama to write nostalgic, warm descriptions in Ukrainian (or any language configured).
- Collages: Auto-generates backgrounds based on dominant colors and stitches photos together.
Integrated Telethon Userbot.
- You click a button in the app.
- The server grabs the file from the disk.
- The server sends it directly to your Telegram chat.
- Zero data usage on your phone.
Automatically moves the moov atom to the beginning of MP4 files. This means videos start playing immediately while streaming, no buffering required.
Before you deploy, you need the right tools.
You need FFmpeg for video processing. Don't skip this, or the server will jam.
sudo apt update
sudo apt install ffmpeg libsm6 libxext6 -yInstall the required libraries.
pip install -r requirements.txt(If you don't have a requirements.txt yet, copy the one at the bottom of this README).
This server needs credentials to talk to Telegram. Create a file named .env in the root directory.
File: .env
# Get these from https://my.telegram.org/apps
API_ID=123456
API_HASH=abcdef1234567890
# Optional: Adjust if needed, but the code handles defaults
# HOST=0.0.0.0
# PORT=8000Warning: Never commit your
.envfile to GitHub. That's how you get hacked.
Fire up the engine. We use uvicorn as the ASGI server.
# Standard Launch
uvicorn server:app --host 0.0.0.0 --port 8000
# For Development (Auto-reload)
uvicorn server:app --host 0.0.0.0 --port 8000 --reloadOnce running, the server will:
- Connect to Telegram (you might need to enter a code in the terminal on first run).
- Scan your storage (
/mnt/storage). - Load the RAM cache.
- Wait for orders.
Create a requirements.txt file and paste this list of ammo:
fastapi
uvicorn
python-multipart
python-dotenv
Pillow
telethon
ffmpeg-python
hachoir
requests
gradio_client
pydantic
The server expects a specific directory structure. It will try to create it, but keep this in mind:
/
├── server.py # The Brain
├── .env # Credentials
├── assets/ # Fonts, frames, resources
└── /mnt/storage/ # YOUR DATA (Mount your HDD here)
├── originals/ # Full resolution photos/videos
├── thumbnails/ # Generated WebP previews
├── memories/ # AI generated stories
├── music/ # Music for memories
└── metadata.json # Cache file