How rayventura/shortgpt works
Project Type and Purpose
• ShortGPT is an AI-driven video automation framework written in Python.
• It is primarily a backend framework (engines, editing framework, utilities), bundled with a simple Gradio-based GUI and CLI entry points (runShortGPT.py).
• Its purpose is to automate the entire pipeline of short-form video creation, translation, voiceover, captioning, asset sourcing, and editing by orchestrating LLM calls, media APIs, and video editing libraries.
High-Level File Structure Analysis
• Top-level folders:
– gui: Gradio UI and abstract UI components
– shortGPT: core code (subpackages: api_utils, audio, config, database, editing_framework, editing_utils, engine, gpt, prompt_templates, tracking, utils)
– docs: Docusaurus docs site
– public/assets/videos: static/demo assets
• Entry points: runShortGPT.py / runShortGPTColab.py for launching the web UI; setup.py for packaging; Dockerfile + README-Docker.md for containerized deployment.
• Config & persistence: shortGPT/config for app settings, shortGPT/database using TinyDB (template_asset_db.json); .env for secrets; requirements.txt for dependencies.
Key Components and Interactions
• UI Layer
– Gradio Web App (gui/gui_gradio.py) and CLI (shortGPT/utils/cli.py)
– Exposes endpoints/buttons for selecting engine (Short, Video, Translation) and parameters.
• Controller/Runner
– runShortGPT.py loads config, initializes the chosen Engine class (ContentShortEngine, ContentVideoEngine, ContentTranslationEngine).
• Engine Layer
– Each Engine orchestrates:
· Prompt generation (shortGPT/gpt)
· Asset sourcing (shortGPT/api_utils: Pexels, Bing Image; shortGPT/audio)
· Editing pipeline (shortGPT/editing_framework: editing_steps JSON + core_editing_engine)
· Rendering (MoviePy)
· Persistence/tracking (shortGPT/tracking, database)
• Core Services / Libraries
– GPT modules: OpenAI LLM calls
– Voice synthesis: ElevenLabs API, EdgeTTS
– Video editing: MoviePy via editing framework
– TinyDB for storing intermediate state/asset info
• External Services
– OpenAI, ElevenLabs, EdgeTTS, Pexels API, Bing Image Search
Architectural Patterns and Design Principles
• Layered modular monolith: clear separation of UI, orchestration (engines), domain logic (editing framework, GPT utils), persistence, and external API adapters.
• Plug-in style editing framework: JSON-defined editing steps and flows allow adding or modifying operations without code changes.
• Dependency injection via config (shortGPT/config/config.py) and environment variables.
• Single process, synchronous orchestration—no microservices, but could evolve to microservices by breaking out engine groups.
• Editing framework’s JSON flows as a subcomponent under Core Logic.
• Role of shortGPT/gpt and shortGPT/api_utils as adapters to AI and media services.