$ show xhongc/ai_story
This repository is an AI-driven story-to-video production platform. It is a full-stack Django 3.2 backend with Vue 2 frontend, Celery task queue, Redis pub/sub, and Docker deployment. The system ingests user story ideas and orchestrates a multi-stage pipeline: rewrite → storyboard → image generation (text2image/image2video) → camera movement → video generation → Jianying (剪映) draft export. All AI capabilities are consumed via external APIs (OpenAI, ComfyUI, Volcano Engine, etc.) through a pluggable AI client abstraction layer. Key entry points include RESTful APIs (DRF), SSE streaming for real-time progress, MCP (Model Context Protocol) JSON-RPC endpoints for agent integration, and a Vue-based canvas UI for visual workflow editing. The architecture follows a modular Django app pattern with clear separation: core infrastructure (pipeline orchestration, AI clients, Redis streaming), domain apps (projects, prompts, models, workflows, content, agent, MCP), and a frontend SPA. External dependencies include Redis, Celery, MySQL/PostgreSQL, external AI vendor APIs, and optional Jianying draft generation. The codebase demonstrates strong engineering practices with reusable patterns for AI client abstraction, Redis pub/sub streaming, MCP tool registration, and pipeline stage processors, but has notable technical debt: Django 3.2 (EOL), mixed async/gevent, Vue 2 (EOL), and some closed-source compiled components.
The LLM identified 3 files worth highlighting for reuse:
Provides a clean abstraction layer for different AI model modalities (LLM, text2image, image2video, image edit). Uses a factory pattern (`create_ai_client_for_user`) to instantiate clients based on provider configuration, and a registry (`registry.py`) for dynamic executor class resolution. Each client implements a consistent interface with streaming support. This module is highly reusable: any project needing to integrate multiple AI providers behind a unified interface can extract it with minimal adaptation.
Implements a robust Redis Pub/Sub infrastructure for real-time streaming of AI generation progress, tokens, and events. The `RedisStreamPublisher` publishes incremental updates to project-stage channels, while `RedisStreamSubscriber` consumes them. This pattern is used extensively across the pipeline and SSE endpoints. It is self-contained, documented in its own README, and can be reused in any application needing decoupled real-time event distribution.
Implements a lightweight tool registration and discovery mechanism for the Model Context Protocol (MCP). Tools are grouped into toolsets (e.g., `image.generate`, `artifact.save`) and registered via decorators. The registry supports listing available tools and calling them by name, with serialization helpers. This pattern enables a clean separation between tool definitions and RPC handlers, making it easy to add new capabilities without modifying the core MCP server. It could be extracted for any project needing a similar JSON-RPC tool service.