Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RaiX Studio

RaiX β€” Your AI-Powered Telegram Studio

Download Β· Clip Β· Summarize Β· Study Β· Chat β€” all from Telegram.

Stars Forks Issues License Node Platform

Features β€’ Quick Start β€’ Configuration β€’ Architecture β€’ Commands β€’ Troubleshooting β€’ Contributing


πŸš€ What is RaiX?

RaiX is a self-hosted, button-driven Telegram bot that turns any video link into actionable content β€” downloads, clips, AI summaries, interactive quizzes, flashcards, and more. It is designed to run 24/7 on a Raspberry Pi or any Linux VPS with zero maintenance.

No commands to memorize. Paste a link β†’ pick an action β†’ done.

Two services, one folder. The Express API backend (backend.js) handles yt-dlp, ffmpeg, and AI. The Telegram bot (bot/) presents it all through inline buttons. Both run under PM2 and share a single .env.


✨ Features

🎬 Video & Music

  • Search YouTube directly from Telegram
  • Download in any quality (360p β†’ 1080p)
  • Audio-only extraction (MP3/M4A)
  • Playlist browsing & batch downloads
  • Multi-platform β€” YouTube, Instagram, Twitter/X, TikTok, Facebook, Vimeo, Pinterest, Snapchat

βœ‚οΈ Clip Studio

  • Trim any video to a 60-second clip
  • Reframe to 9:16 (Shorts/Reels) or 1:1 (Feed)
  • AI Viral Finder β€” automatically locates the most engaging 30 seconds
  • Accepts flexible time formats: 90, 1:30, 0:01:30

🧠 AI Studio

  • Summarize β€” brief, detailed, key points, or timestamped chapters
  • Generate titles β€” viral, curiosity, how-to, or listicle tones
  • Generate tags β€” 15 SEO-optimized tags from any title
  • Write descriptions β€” with timestamps, hashtags, CTAs, custom keywords
  • Powered by Groq (free) or OpenRouter with multi-key failover

πŸ“š Study Tools

  • Full transcript β€” timestamped spoken text, downloadable
  • Class notes β€” AI-structured revision notes
  • Interactive quiz β€” 5 exam-style MCQs played inside Telegram
  • Flashcards β€” tap to flip, swipe through the deck
  • Study planner β€” paced daily schedule for any course

πŸ’¬ Video Chat

  • Ask questions about any video's content
  • AI reads the transcript and answers in context
  • Maintains chat history within the session

πŸ›‘οΈ Access Control & Admin

  • Private by default β€” only the owner can use it
  • Request/Approve flow for new users
  • Role system β€” Owner, Admin, User
  • Owner Panel β€” manage users, cookies, restart services, view stats
  • Cookie upload β€” update yt-dlp cookies straight from your phone

πŸ“¦ Quick Start

Prerequisites

Requirement Minimum Notes
OS Debian 11+ / Ubuntu 20.04+ / Raspberry Pi OS Any Linux with apt
Node.js v18+ Installed automatically by setup.sh
RAM 1 GB 2 GB+ recommended for concurrent clips

One-Command Install

git clone https://github.com/raimohan/raixyt.git
cd raixyt
chmod +x setup.sh
./setup.sh

The setup script automatically installs:

Component Purpose
Node.js 20 Runtime for backend + bot
yt-dlp Video extraction (private virtualenv)
ffmpeg Audio/video muxing & clip re-encoding
Deno YouTube n-challenge solver
PM2 Process manager β€” keeps everything alive 24/7

Configure

After setup, edit .env with your tokens:

# Required
BOT_TOKEN=your-token-from-botfather
OWNER_ID=your-telegram-numeric-id

# AI (free tier is enough)
GROQ_API_KEY_1=your-groq-api-key

Then start:

./setup.sh --start

πŸ’‘ Tip: Send /id to your bot (or to @userinfobot) to find your numeric Telegram ID.

Setup Modes

./setup.sh                # Full install + start
./setup.sh --no-start     # Install only, configure later
./setup.sh --start        # Skip install, just (re)start services
./setup.sh --update       # Update yt-dlp + npm deps + restart
./setup.sh --skip-apt     # Skip apt packages (re-runs)

βš™οΈ Configuration

All configuration lives in a single .env file. Copy from the template:

cp .env.example .env
πŸ“‹ Full Environment Variable Reference

Telegram Bot

Variable Required Default Description
BOT_TOKEN βœ… β€” Token from @BotFather
OWNER_ID βœ… β€” Your numeric Telegram ID
ADMIN_IDS β€” Comma-separated admin IDs
OPEN_ACCESS false Set true to allow anyone
BOT_NAME RaiX Studio Shown in the welcome screen

Backend API

Variable Required Default Description
PORT 3000 API server port
API_BASE http://127.0.0.1:3000 Bot β†’ backend URL
ADMIN_TOKEN β€” Token for /api/admin/* routes

AI Provider

Variable Default Description
GROQ_API_KEY_1 … _10 β€” Up to 10 Groq keys (auto-rotate)
GROQ_MODEL llama-3.3-70b-versatile Primary model
GROQ_MODEL_FALLBACKS llama-3.3-70b-versatile,llama-3.1-8b-instant Fallback chain
AI_PROVIDER auto-detect Force groq or openrouter
OPENROUTER_API_KEY_1 … _5 β€” Up to 5 OpenRouter keys

Performance Tuning

Variable Default Description
MAX_UPLOAD_MB 49 Telegram's 50 MB bot upload limit
MAX_CONCURRENT_JOBS 2 Simultaneous heavy jobs
THROTTLE_MAX 4 Rate limit per window
THROTTLE_WINDOW_MS 1000 Rate limit window
API_TIMEOUT_MS 180000 API call timeout
DOWNLOAD_IDLE_TIMEOUT_MS 240000 Stalled transfer timeout

πŸ— Architecture

raixyt/
β”‚
β”œβ”€β”€ backend.js                 # Express API server (yt-dlp + AI + clips)
β”œβ”€β”€ ecosystem.config.js        # PM2 process definitions
β”œβ”€β”€ setup.sh                   # One-shot installer
β”œβ”€β”€ package.json
β”œβ”€β”€ .env.example               # Configuration template
β”‚
└── bot/                       # Telegram bot (Telegraf)
    β”œβ”€β”€ index.js               # Entry point, middleware, graceful shutdown
    β”œβ”€β”€ config.js              # Environment parsing & validation
    β”‚
    β”œβ”€β”€ api/
    β”‚   └── client.js          # Typed HTTP wrapper over backend.js
    β”‚
    β”œβ”€β”€ core/
    β”‚   β”œβ”€β”€ router.js          # Callback/text/document dispatch + error boundary
    β”‚   β”œβ”€β”€ flow.js            # Shared "send me a link / text" prompts
    β”‚   β”œβ”€β”€ cache.js           # Token store for oversized callback payloads
    β”‚   β”œβ”€β”€ session.js         # Per-user state & chat history
    β”‚   └── queue.js           # Concurrency limiter for heavy jobs
    β”‚
    β”œβ”€β”€ middleware/
    β”‚   β”œβ”€β”€ auth.js            # Access gate (owner β†’ admin β†’ user)
    β”‚   └── throttle.js        # Per-user rate limiter
    β”‚
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ users.js           # User registry & persistence
    β”‚   β”œβ”€β”€ prefs.js           # Per-user preferences
    β”‚   β”œβ”€β”€ stats.js           # Usage counters
    β”‚   └── downloads.js       # Streaming download pipeline
    β”‚
    β”œβ”€β”€ ui/
    β”‚   β”œβ”€β”€ render.js          # Message renderer & progress bars
    β”‚   β”œβ”€β”€ keyboards.js       # Inline keyboard builder
    β”‚   └── text.js            # Shared copy & formatting
    β”‚
    └── features/              # Self-registering feature modules
        β”œβ”€β”€ home.js            # Main menu & welcome screen
        β”œβ”€β”€ video.js           # 🎬 Video search & download
        β”œβ”€β”€ music.js           # 🎡 Music search & download
        β”œβ”€β”€ downloader.js      # ⬇️ Universal link downloader
        β”œβ”€β”€ clip.js            # βœ‚οΈ Clip Studio (trim + reframe)
        β”œβ”€β”€ subtitles.js       # πŸ“ Subtitle extraction
        β”œβ”€β”€ ai.js              # 🧠 AI Studio (summarize, tags, titles, descriptions)
        β”œβ”€β”€ study.js           # πŸ“š Study tools (quiz, flashcards, notes, plan)
        β”œβ”€β”€ chat.js            # πŸ’¬ Video Chat (conversational Q&A)
        β”œβ”€β”€ analytics.js       # πŸ“Š Channel & video insights
        β”œβ”€β”€ course.js          # πŸŽ“ Course discovery
        β”œβ”€β”€ settings.js        # βš™οΈ User preferences
        └── admin.js           # πŸ›  Owner Panel (users, cookies, services)

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      HTTP/JSON      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              β”‚ ◄──────────────────► β”‚                  β”‚
β”‚  Telegram    β”‚                     β”‚   backend.js     β”‚
β”‚  Bot (bot/)  β”‚                     β”‚   (Express API)  β”‚
β”‚              β”‚                     β”‚                  β”‚
β”‚  β€’ Telegraf  β”‚                     β”‚  β€’ yt-dlp        β”‚
β”‚  β€’ Buttons   β”‚                     β”‚  β€’ ffmpeg        β”‚
β”‚  β€’ Sessions  β”‚                     β”‚  β€’ Groq/OpenRouterβ”‚
β”‚  β€’ Progress  β”‚                     β”‚  β€’ Cron jobs     β”‚
β”‚              β”‚                     β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                                      β”‚
       β”‚  Telegram Bot API                    β”‚  Spawns
       β–Ό                                      β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Telegram β”‚                         β”‚ yt-dlp      β”‚
  β”‚ Servers  β”‚                         β”‚ ffmpeg      β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β”‚ deno/node   β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Adding a feature = one file in bot/features/, register routes with router.onMany({...}), add a button to the home menu. Nothing else changes.


πŸ”§ Commands

Telegram Commands

Command Description
/start Open the main menu
/menu Back to the main menu
/id Show your Telegram ID
/cancel Cancel the current action

PM2 Management

pm2 logs raix-bot          # Follow bot logs
pm2 logs raix-api          # Follow API logs
pm2 restart raix-bot       # Restart the bot
pm2 restart raix-api       # Restart the API
pm2 monit                  # Live CPU/RAM dashboard
pm2 status                 # Process overview

πŸ’‘ Pro tip: The Owner Panel can restart either service directly from your phone β€” no SSH needed.


πŸͺ Cookie Management

The backend uses Netscape-format cookie files for authenticated downloads.

File Platforms
youtube.txt YouTube, Twitter/X, TikTok, Facebook, Vimeo, Pinterest, Snapchat
instagram.txt Instagram

How to Update Cookies

  1. Install a "Get cookies.txt LOCALLY" browser extension
  2. Log in to the platform and export cookies
  3. Upload via Telegram: Owner Panel β†’ πŸͺ Cookies β†’ Upload

The file is validated, written with 0600 permissions, and picked up immediately β€” no restart needed.

⚠️ Warning: An empty cookie file is worse than none β€” yt-dlp aborts on a rejected jar instead of falling back to anonymous access. Delete empty cookie files.


πŸ”Œ Supported Platforms

Platform Download Cookies Needed
YouTube βœ… Recommended
Instagram βœ… Required
Twitter / X βœ… Recommended
TikTok βœ… Optional
Facebook βœ… Optional
Vimeo βœ… Optional
Pinterest βœ… Optional
Snapchat βœ… Optional

Powered by yt-dlp β€” any site yt-dlp supports will work.


πŸ› Troubleshooting

Bot starts then exits immediately

BOT_TOKEN or OWNER_ID is missing or invalid.

pm2 logs raix-bot --lines 20

Check .env for empty values. Get a fresh token from @BotFather.

"The backend is not reachable"

The API server isn't running.

pm2 start raix-api
curl http://localhost:3000/health
Every YouTube download fails

Usually means no JavaScript runtime for the YouTube n challenge solver.

./deno --version        # Should print deno version
./setup.sh --update     # Re-install if missing

Check logs for: "n challenge solving failed" β€” this confirms the runtime is missing.

"Sign in to confirm you're not a bot"

Cookies are stale. Re-export from your browser and upload via Owner Panel β†’ Cookies.

Downloads are slow

Expected on a Raspberry Pi for 1080p β€” yt-dlp downloads video + audio separately, then ffmpeg muxes them. 720p is ~3Γ— faster.

Out-of-memory restarts

Lower the concurrency in .env:

MAX_CONCURRENT_JOBS=1

🀝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development

# Check all files for syntax errors
npm run check

# Start the backend only
npm start

# Start the bot only
npm run bot

πŸ“„ License

This project is open source. See the LICENSE file for details.


πŸ‘€ Author

raimohan
@raimohan

If you found this useful, consider giving it a ⭐

GitHub

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages