How gokul7904231/shortforge works
Purpose and Entry Points
FactoryVids is an AI-operated short-form video production system: it turns a topic or quiz request into a vertical, narrated, subtitled video, then stores and publishes it. The primary control plane is the Next.js application at apps/web/app/page.js, with operator UI under apps/web/app/(os)/ and server APIs under apps/web/app/api/. Video generation enters through apps/web/app/api/generate-video/route.ts; job progress is read via apps/web/app/api/job-status/[id]/route.ts and factory state can stream through apps/web/app/api/factory-state/sse/route.ts.
Control Plane, Identity, and State
The Node/Next runtime is the user-facing boundary: it authenticates users, applies role/capability and quota controls, accepts generation requests, and exposes operational dashboards. Authentication implementation is concentrated in apps/web/lib/auth/AuthService.ts, apps/web/lib/auth/firebase-admin.ts, and route middleware at apps/web/middleware.ts. Persistent state spans Firestore-oriented user/quota records, MongoDB or disk/in-memory FactoryOS state, and SQLite-backed render queues; queue persistence is represented by apps/web/lib/core/SQLiteRenderQueue.ts and apps/web/lib/queue-db.ts.
AI and Content Planning Layer
Provider-agnostic AI routing selects configured models and capabilities rather than binding pipeline stages directly to one vendor. Core routing/factory abstractions are apps/web/ai/factory.ts, apps/web/ai/intelligent-router.ts, and apps/web/ai/capability-registry.ts; concrete providers include Gemini, Groq, OpenRouter, Hugging Face, NVIDIA, and local AI under apps/web/ai/providers/. Content engines define domain-specific workflows—such as quiz, facts, story, and news—loaded and executed through apps/web/content-engines/_loader/index.ts and apps/web/content-engines/_runtime/workflow-runtime.ts.
Production Orchestration and Governance
FactoryOS is the durable autonomous orchestration core. apps/web/factoryos/core/runtime/FactoryRuntime.ts composes workflows; apps/web/factoryos/core/production/ProductionRunner.ts executes production jobs and state transitions; apps/web/factoryos/core/controller/AutonomousFactoryController.ts manages autonomous operation. The Overseer control plane plans task DAGs, records decisions, and accepts operator commands through apps/web/factoryos/core/overseer/OverseerControlPlane.ts, apps/web/factoryos/core/overseer/TaskDAGPlanner.ts, and apps/web/lib/overseer/OverseerToolGateway.ts. Guardian, validator, watchdog, recovery, and cost-governor subsystems form policy/safety boundaries before or after work is committed.
Video Assembly and Render Fabric
The application plans scripts, scenes, assets, voice, subtitles, and timelines using modules such as apps/web/lib/content-pipeline.ts, apps/web/lib/voice/AudioPipeline.ts, and apps/web/lib/core/TimelineOrchestrator.ts. Render jobs are queued/routed by apps/web/lib/rendering/RenderQueueManager.ts and apps/web/lib/rendering/AzureWorkerManager.ts. The physical rendering boundary is Python/FastAPI in services/rendering-engine/main.py, with worker execution in services/rendering-engine/basic_render_worker.py; it uses Pillow and FFmpeg to produce media. Local generation alternatives live in apps/web/local-ai/scripts/.
Pipeline Floors and Handoffs
A parallel Python “floor” architecture models staged handoffs: strategy, scripting, asset realization, media synthesis, timeline composition, and rendering. Representative service boundaries are services/pipeline/floor01_strategy/app/pipeline.py, services/pipeline/floor02_scripting/app/pipeline.py, and services/pipeline/floor04_media_synthesis/app/services/pipeline.py. Each floor owns domain handoff contracts, logical workers, validation/reconciliation, and provider adapters; the shared guardian at services/pipeline/guardian/core/guardian.py applies policy, verification, transaction, circuit-breaker, and recovery decisions across floors.
External Infrastructure and Delivery Flow
A generation request reserves user capacity, creates a queue/job record, then targets a warm FastAPI render service or GitHub Actions fallback through apps/web/app/api/rendering/github/dispatch/route.ts. Workers claim work and callback through apps/web/app/api/rendering/claim/route.ts and apps/web/app/api/rendering/callback/route.ts; callbacks must be idempotent and update durable job state. Artifacts are stored or delivered through Cloudinary/Google Drive abstractions in apps/web/storage/storage-registry.ts and apps/web/lib/drive/DriveConnectionManager.ts, while publishing is provider-based in apps/web/publishing/publishing-registry.ts. Deployment targets include Docker, GitHub Actions workflows, Firebase Hosting, Vercel, and Azure infrastructure defined in apps/web/azure/main.bicep.
Main entry points: route.ts Generation API · ProductionRunner.ts Production runner · content-pipeline.ts Media planning · basic_render_worker.py Render worker
Components 21
Next.js Control Plane
Operator-facing API, identity, and durable queue boundary.
- Operator UI
- Generation API · Accepts video generation requests.
apps/web/app/api/generate-video/route.ts - Job status & SSE · Exposes job progress and factory state.
apps/web/app/api/job-status/[id]/route.ts - Identity & quotas · Authenticates users and enforces capabilities and capacity.
apps/web/lib/auth/AuthService.ts - Durable render queue · Persists render jobs for worker claiming.
apps/web/lib/core/SQLiteRenderQueue.ts
AI & Content
Model routing and content workflow execution.
- AI capability router · Selects configured providers and model capabilities.
apps/web/ai/intelligent-router.ts - Content workflows · Runs quiz, facts, story, and news engines.
apps/web/content-engines/_runtime/workflow-runtime.ts
FactoryOS Governance
Durable orchestration, autonomous control, and oversight.
- Factory runtime · Composes durable production workflows.
apps/web/factoryos/core/runtime/FactoryRuntime.ts - Production runner · Executes production jobs and state transitions.
apps/web/factoryos/core/production/ProductionRunner.ts - Autonomous controller · Manages autonomous factory operation.
apps/web/factoryos/core/controller/AutonomousFactoryController.ts - Overseer control plane · Plans task DAGs, records decisions, and accepts commands.
apps/web/factoryos/core/overseer/OverseerControlPlane.ts
Production & Render
Media planning, distributed rendering, and pipeline floors.
- Media planning · Plans scripts, scenes, assets, voice, subtitles, and timelines.
apps/web/lib/content-pipeline.ts - Voice & audio
apps/web/lib/voice/AudioPipeline.ts - Timeline composition
apps/web/lib/core/TimelineOrchestrator.ts - Render dispatcher · Routes jobs to workers or fallback infrastructure.
apps/web/lib/rendering/RenderQueueManager.ts - Render service · Physical media rendering boundary using Pillow and FFmpeg.
services/rendering-engine/main.py - Render worker · Executes claimed media render jobs.
services/rendering-engine/basic_render_worker.py - Pipeline floors · Strategy, scripting, asset, synthesis, composition, and rendering handoffs.
services/pipeline/floor01_strategy/app/pipeline.py - Shared guardian · Applies verification, transaction, circuit-breaker, and recovery decisions.
services/pipeline/guardian/core/guardian.py
Storage & Publishing
Artifact delivery and publication providers.
- Artifact storage · Delivers artifacts through Cloudinary and Google Drive abstractions.
apps/web/storage/storage-registry.ts - Publishing providers
apps/web/publishing/publishing-registry.ts
Connections 23
- Operator UI → Generation API: submits request
- Operator UI → Job status & SSE: reads progress
- Generation API → Identity & quotas: authorizes and reserves capacity
- Generation API → Durable render queue: creates job
- Generation API → Factory runtime: starts workflow
- Factory runtime → Production runner: composes execution
- Autonomous controller → Factory runtime: operates
- Overseer control plane → Autonomous controller: plans and commands
- Production runner → AI capability router: requests AI capabilities
- AI capability router → Content workflows: supplies selected models
- Content workflows → Media planning: produces content plan
- Media planning → Voice & audio: creates narration
- Media planning → Timeline composition: supplies scenes and assets
- Voice & audio → Timeline composition: supplies voice
- Timeline composition → Render dispatcher: submits timeline
- Durable render queue → Render dispatcher: provides queued job
- Render dispatcher → Render service: routes render
- Render service → Render worker: executes job
- Pipeline floors → Shared guardian: policy and recovery checks
- Production runner → Pipeline floors: staged handoffs
- Render worker → Artifact storage: stores output
- Artifact storage → Publishing providers: delivers artifact
- Render worker → Job status & SSE: idempotent job updates