How the Engine Works

A complete overview of the video generation pipeline

1High-Level Data Flow

User Input
Topic, Character, Environment, Grade
Script AI
GPT-4o Writer Agent
Director AI
JSON Structure Agent
Asset Gen
Runware + ElevenLabs
Remotion
Video Render
Cloudflare
Stream CDN

2Dual-Agent Script System

✍️

Agent 1: Writer

Creates a 20-beat story outline following the "Competence Arc" structure.

• Focuses on narrative flow

• Writes engaging narrator scripts

• Designs character struggles & victories

🎬

Agent 2: Director

Converts the story into structured JSON with visual & audio metadata.

• Generates background-only visuals

• Selects theme & layout modes

• Creates character visual description

3Story Structure: The Competence Arc

Every video follows a proven educational narrative structure:

Act 1: SetupSlides 1-3

Introduce character and environment. Establish a clear goal.

Act 2A: Problem ASlides 4-9

Character fails due to ignoring basic concept. Learns the fundamental rule through struggle. Includes 1 CONCEPT_CARD.

Act 2B: Problem BSlides 10-17

A harder challenge appears. Basic rule isn't enough. Character learns advanced concept. Includes 1-2 CONCEPT_CARDS.

Act 3: Real WorldSlides 18-19

Stop the story. Show how this topic applies to real careers (Engineering, Medicine, Tech, etc.)

ClosingSlides 20

Happy ending shot of character succeeding.

4Asset Generation Pipeline

👤

Character

Runware AI

  1. Generate 4 emotion poses
  2. Remove background
  3. Upload to R2 CDN
🎨

Backgrounds

Runware AI

  1. Generate per-slide visuals
  2. Character-free scenes
  3. Upload to R2 CDN
🎙️

Voiceovers

ElevenLabs

  1. Generate per-slide audio
  2. Measure duration
  3. Upload to R2 CDN

5Dynamic Theme System (15 Themes)

The Director AI selects the optimal theme based on subject matter:

MODERN_GLASS
Science, Nature, Calm topics
COMIC_BUBBLE
Elementary School, Fun, Storytelling
RETRO_TERMINAL
Computer Science, Coding basics
MINIMAL_DARK
Serious academic, Philosophy
NEON_CYBER
Futurism, AI, Robots
GREENLIGHT
Data Science, Modern Tech
HYPER_POP
Pop Culture, Social Studies, Art
HIGH_OCTANE
Physics, Sports, Motivation
OCEAN_GRID
Engineering, Astronomy, Math
LIVE_RED
Biology, Virus/Cells, Crisis
HARBOUR_TEAL
Heavy Industry, Geography
GREY_DISRUPTION
Chemistry, Cyber-Security
DIGITAL_DECAY
History, Gaming, Archaeology
HIGH_VOLTAGE
Architecture, Economics, Fashion
THE_ARCHIVE
History, Government, Law

6Final Output

Video File

  • • Rendered via Remotion (H.264)
  • • Uploaded to Cloudflare Stream
  • • Signed URLs for secure playback
  • • Average generation: 3-5 minutes

Metadata (script_json)

  • • Full slide data with timings
  • • Character & background URLs
  • • Audio URLs & durations
  • • Ready for RAG vector chunking