How fujiwarachoki/moneyprinter works
• High-level shape: MoneyPrinter is a Python-backed, queue-based video generation system with a thin browser UI. The core architecture is split into a frontend, an API service, an asynchronous worker, and a Postgres-backed job store.
• User-facing boundary: Frontend/index.html and Frontend/app.js provide a lightweight client that submits a topic, watches job progress, and surfaces results. The UI does not do generation itself; it talks to the backend over HTTP.
• API service: Backend/main.py is the request entrypoint. Its role is to accept job creation and status requests, persist work in the database, and expose any misc/job endpoints the UI needs. The API is intentionally not the heavy compute layer.
• Persistent queue and state: Backend/db.py and Backend/repository.py form the persistence boundary. They store job records, queue state, progress, and final outputs in Postgres. This is the key reliability feature: jobs survive restarts because the queue is database-backed rather than in-memory.
• Worker process: Backend/worker.py is the execution engine. It pulls queued jobs from the database, runs them through the pipeline, and writes status/progress back. This decouples submission from long-running generation and makes the system restart-safe.
• Orchestration layer: Backend/pipeline.py coordinates the end-to-end generation flow. It is the central workflow boundary that ties together model calls, content search, narration, video assembly, and optional publishing steps.
• LLM integration: Backend/gpt.py is the Ollama-facing adapter. The README makes the project’s AI stance explicit: script generation and metadata are Ollama-first and run against local models rather than a hosted LLM API.
• Media generation subsystem: Backend/video.py handles assembling the final short-form video, likely combining visuals, audio, captions, and timing. Backend/tiktokvoice.py provides narration voice generation. The project also expects local media tooling such as ImageMagick, and the Docker/docs suggest standard containerized media processing.
• Supporting content / integrations: Backend/search.py appears to support topic research or retrieval for content enrichment. Backend/youtube.py is the external publishing boundary for YouTube-related actions, while Backend/utils.py and Backend/models.py provide shared helpers and domain objects used across the pipeline.
• Observability and progress: Backend/logstream.py exists to stream worker logs or live progress back to the UI. Combined with job polling/status updates, it gives the frontend visibility into a multi-step asynchronous workflow.
• Runtime and deployment model: The repo is designed to run with Python, Postgres, and Ollama, typically via docker-compose.yml and the provided Dockerfile. The system is therefore a small distributed app: browser UI → API → database queue → worker → external/local AI and media tools → persisted output.
• Verification boundaries: The test suite (tests/test_api_jobs.py, tests/test_repository.py, tests/test_worker.py, etc.) mirrors the major subsystems, which reinforces the architecture: API behavior, persistence, worker orchestration, and utility functions are tested separately.
Main entry points: pipeline.py Pipeline · app.js UI Logic · main.py API Service · worker.py Job Worker
Components 18
Frontend
Thin browser client for job submission and progress display
- Browser UI · Minimal page for submitting topics and viewing status
Frontend/index.html - UI Logic · Client-side job polling and progress updates
Frontend/app.js
Backend API
HTTP entrypoints and job-facing endpoints
- API Service · Job creation, status, and misc endpoints
Backend/main.py - Live Stream · Streams worker logs or live progress to the UI
Backend/logstream.py
Worker
Asynchronous execution and orchestration layer
- Job Worker · Dequeues jobs and executes the generation pipeline
Backend/worker.py - Pipeline · End-to-end generation flow across content, media, and publishing
Backend/pipeline.py
Persistence
Database-backed queue, job state, and domain models
- DB Layer · Database connection and low-level persistence support
Backend/db.py - Job Store · Job records, queue state, progress, and outputs
Backend/repository.py - Domain Models · Shared job and content objects used across the backend
Backend/models.py
Media & Integrations
Content generation, narration, search, and publishing adapters
- Ollama Adapter · Local-model script and metadata generation
Backend/gpt.py - Research · Topic enrichment and content lookup
Backend/search.py - Video Assembly · Builds the final short-form video output
Backend/video.py - Voice Synth · Generates narration audio for videos
Backend/tiktokvoice.py - YouTube · External publishing boundary for YouTube actions
Backend/youtube.py - Shared Utils · Common backend helper functions
Backend/utils.py
Runtime & Deploy
Containerization, environment, and local tooling
- Dockerfile · Builds the application image
Dockerfile - Compose Setup · Local multi-service runtime for app, database, and Ollama
docker-compose.yml - Env Example · Documented environment variables for local setup
.env.example
Connections 18
- Browser UI → UI Logic: loads · HTML bootstraps the client script
- UI Logic → API Service: HTTP · Submits jobs and polls status
- UI Logic → Live Stream: stream · Receives live progress updates
- API Service → Job Store: persists · Creates and updates job records
- API Service → Domain Models: uses · Serializes and validates domain objects
- Job Worker → Job Store: claims · Reads queued jobs and writes back state
- Job Worker → Pipeline: executes · Runs the end-to-end workflow
- Pipeline → Ollama Adapter: generates · Creates scripts and metadata with local models
- Pipeline → Research: researches · Enriches topics with retrieval or search
- Pipeline → Voice Synth: narrates · Produces spoken audio tracks
- Pipeline → Video Assembly: assembles · Combines media into final output
- Pipeline → YouTube: publishes · Optionally sends finished content outward
- Pipeline → Shared Utils: shares · Uses common helpers during workflow steps
- Job Store → DB Layer: stores in · Backed by Postgres persistence
- DB Layer → Domain Models: maps · Stores structured job data
- Live Stream → Job Worker: observes · Surfaces worker progress and logs
- Compose Setup → Dockerfile: builds · Compose uses the application image
- Compose Setup → Env Example: configures · Environment values drive local runtime