How diepdo1810/moneyprinterturbo works
Project Type and Purpose
• MoneyPrinterTurbo is a full-stack, MVC-architected application for end-to-end automatic short-video generation.
• It exposes:
• A RESTful API (FastAPI) for programmatic access.
• A Streamlit-based Web UI for interactive use.
• Core features include AI-powered copywriting (LLM), video and subtitle synthesis, voice-over, background music, and final video assembly.
File Structure Highlights
• Top-level:
• Dockerfile & docker-compose.yml → containerized deployment
• main.py → FastAPI app entrypoint
• webui/ → Streamlit front-end
• app/ → MVC layers (controllers, services, models, router, config)
• resource/ → static assets (fonts, songs, HTML)
• test/ → unit tests for services
• app/controllers/manager → pluggable state managers (in-memory, Redis)
• app/services → business logic: llm, video, subtitle, voice, material selection
• config.example.toml → central configuration for keys, ffmpeg/ImageMagick paths, model providers
• .streamlit/config.toml → Streamlit UI settings
Key Architectural Components
A. Frontend (Streamlit UI)
• Runs as a separate process (webui/Main.py)
• Interacts with backend API over HTTP
• Serves index.html and static assets from resource/public
B. API Backend
• FastAPI application (main.py → app/asgi.py → app/router.py)
• Controllers (app/controllers/) handle endpoints: ping, v1/llm, v1/video
• Manager layer abstracts state caches (memory or Redis)
• Services implement core logic:
• LLM calls (OpenAI, Moonshot, DeepSeek, etc.)
• Video/material selection (Pexels integration or local assets)
• Subtitle generation (edge or whisper)
• Voice synthesis (Azure, gpt4free, etc.)
• Video composition using ffmpeg and ImageMagick
C. Resource Store
• Fonts for subtitles (resource/fonts)
• Music files (resource/songs)
• Public HTML template (resource/public/index.html)
D. External Dependencies
• LLM API providers
• Pexels API for video clips
• ImageMagick & ffmpeg binaries
• Optional Redis instance for distributed state
Relationships & Data Flow
1. User interacts with Streamlit UI → submits topic/keywords
2. UI issues HTTP request to FastAPI endpoint (e.g., /v1/video)
3. Controller validates input, selects manager (memory/Redis)
4. Service layer:
a. Generates script via LLM service
b. Fetches video clips (Pexels or local)
c. Synthesizes voiceover
d. Generates subtitles
e. Composes video segments with ffmpeg/ImageMagick
5. Final video stored locally and URL returned to UI or client
6. Optionally, state (progress, caching) persisted in Redis
Architectural Patterns & Design Principles
• MVC Separation: controllers (API layer), services (business logic), models (data schemas/exceptions)
• Manager Pattern for caching/state (memory or Redis swap-in)
• Configuration-driven design (config.toml)
• Modular, pluggable LLM and subtitle providers
• Containerized deployment via Docker Compose