01Layers at a glance
Every layer is plain Python and JSON: no database, no external broker, and no frontend build step. Project state lives directly on disk.
02Subsystems
The repository is organized by domain rather than by framework boilerplate. Private project data, local scripts, credentials, screenplays, and generated media are always excluded from git.
| Area | Responsibilities |
|---|---|
| HTTP entry & security gate | Loads local environment config before imports, enforces HTTP Basic auth when hosted, adds security headers, serves browser pages and allowlisted HTML guides, and mounts API routers at / and /screenplay. |
| Writing subsystem | Deterministic PDF geometry parsing into typed screenplay elements, optional Check-import element-type suggestions, versioned draft storage (up to 50 snapshots per project), and ReportLab A4 screenplay PDF export with bundled Courier Prime fonts. |
| Story analysis & breakdown | Whole-script story bible, timeline, scene staging, shot plan, and consistency review; deterministic project breakdown into beats, camera plans, continuity locks, base prompts, verification checklists, and production shoot boards. |
| Wardrobe & movie look | Global wardrobe catalog with CONTINUED scene inheritance, optional LLM wardrobe extraction, garment plates and virtual try-ons, YouTube look-frame extraction converted to text lighting/grade notes, and SSRF-guarded cast likeness search. |
| Beat planning, generation & verification | Schema-validated per-beat semantic planner (cached by context hash), structured prompt compiler with labeled reference roles, multi-provider image fallback chain, vision verification with per-criterion receipts, bounded repair, atomic checkpoints, and append-only cost auditing. |
| Human review & campaigns | Scene-by-scene review board, defect tagging and repair brief export, second-pass review checkpoints, best-available collection exports, and frozen replacement campaigns. |
| Voice & motion | Consent-gated ElevenLabs voice cloning/design/TTS, masked subtitle clean-plate removal, Seedance 2.5 image-to-video rendering in a persistent background worker with hard spend caps, and ffmpeg animatic/motion assembly with loudness normalization. |
| Browser UI | Five standalone vanilla HTML/CSS/JS views (project library, script editor, 8-step storyboard studio, review board, and overview homepage) sharing one design-token stylesheet. |
03Playbooks — rules as data
Tunable cinematography, continuity, and policy rules live as JSON playbooks read at runtime. Updating a playbook changes pipeline behavior without editing Python code, and every active playbook hash is recorded inside each generation receipt. Committed playbooks remain story-agnostic; per-project story packs overlay generated and hand-edited rules locally.
| Playbook group | What it controls |
|---|---|
| Generation policy & prompts | Core rules (beat scope, identity, continuity, physics, framing, text), prompt section order, brief schema, lighting by time of day, and semantic planner instructions. |
| Cinematography & staging | Shot sizes and glossary, camera angles, movements, coverage rules, default focal lengths by space, declarative blocking templates, and micro-atmosphere beat filtering. |
| Continuity & aesthetics | Anatomy/posture/prop physics triggers, binding spatial locks, location alias normalization, aesthetic clause packs by space/time, film style templates, color LUT presets, and production clustering. |
| Motion & story analysis | Video motion prompt rules, audio routing heuristics, and generic story-analysis vocabulary. |
| Per-project overlays (local only) | Generated and hand-editable story rules and per-scene plans kept inside each project's gitignored folder. |
04HTTP API catalog
All endpoints are mounted at / and again under /screenplay/… for embedding. Storyboard endpoints accept project_id as a query parameter.
Pages and health
| Method | Path | Purpose |
|---|---|---|
| GET | / | Project library |
| GET | /edit?p=<id> | Screenplay editor |
| GET | /prepro?p=<id> | 8-step storyboard & video studio |
| GET | /feedback?p=<id> | Human review board & repair brief export |
| GET | /landing | Homepage for filmmakers & engineers |
| GET | /guides/{name} | Allowlisted HTML documentation pages |
| GET | /healthz | Liveness probe (unauthenticated) |
Writing API
| Method | Path | Purpose |
|---|---|---|
| POST | /api/import-pdf | Parse an uploaded PDF into beats (≤ 35 MB) |
| GET | /api/drafts | List projects |
| GET / POST / DELETE | /api/draft | Read, autosave, or delete a draft |
| POST / GET | /api/draft/version, /api/draft/versions | Save or list named snapshots |
| POST | /api/draft/restore-version | Restore a snapshot into the active draft |
| POST | /api/draft/import-review, /api/draft/import-review/apply | Suggest or apply element-type repairs without rewriting text |
| POST | /api/export-pdf | Render a formatted screenplay PDF |
Storyboard, review, voice & motion API
| Area | Endpoints |
|---|---|
| Project | GET /api/prepro, POST /api/prepro/compute, POST /api/prepro/bootstrap (upload PDF + compute) |
| Scenes & beats | PUT /api/prepro/sequence |
| Cast | POST/PUT/DELETE /api/prepro/character, POST/DELETE /api/prepro/character/likeness, POST /api/prepro/character/likeness/search, POST /api/prepro/character/likeness/from-search |
| Look | POST /api/prepro/look/extract, POST /api/prepro/look/extract-more, GET /api/prepro/look/session/{id}/frame/{index}, POST /api/prepro/look/apply-selection, POST /api/prepro/look/confirm, POST /api/prepro/look/upload |
| Wardrobe | GET /api/prepro/wardrobe, POST /api/prepro/wardrobe/analyze, PUT /api/prepro/wardrobe/assignment, POST /api/prepro/wardrobe/item/generate, POST /api/prepro/wardrobe/item/upload, POST /api/prepro/wardrobe/try-on |
| Generate | POST /api/prepro/generate (called once per beat) |
| Audit & review | POST /api/prepro/audit/start, GET /api/prepro/audit, POST /api/prepro/audit/finish, GET /api/prepro/story-review |
| Video & assets | POST /api/prepro/assemble, GET /api/prepro/asset |
| Feedback | GET /api/prepro/feedback, PUT /api/prepro/feedback/beat, POST /api/prepro/feedback/mark-ok, GET /api/prepro/feedback/thumb, POST /api/prepro/feedback/export |
| Voices & Motion | GET /api/prepro/voice/config, GET /api/prepro/voice/stock, POST/DELETE /api/prepro/character/voice/sample, POST/DELETE /api/prepro/character/voice, POST /api/prepro/character/voice/preview, GET /api/prepro/motion, POST /api/prepro/motion/estimate, POST /api/prepro/motion/start, GET /api/prepro/motion/job, POST /api/prepro/motion/cancel, GET /api/prepro/motion/timeline, PUT /api/prepro/motion/edit, POST /api/prepro/motion/approve |
| External board sync | POST /api/prepro/sync-codex |
05Testing
Run the full test suite offline with python -m unittest discover -s tests — 379 tests with zero network access (providers are patched with fakes and tests load a fictional demo fixture rather than private user projects).
| Coverage area | What is verified |
|---|---|
| Writing & import | Short and multi-page PDF geometry parsing, dialogue/parenthetical preservation, Check-import element-type fixes |
| Story analysis & breakdown | Heuristic and LLM bible, timeline, staging, cue-anchored moves, beat splitting, story-pack overlays, day arcs, location remaps |
| Prompt compiler & beat planner | Pronoun/addressee resolution, active cast, performance/silence rules, physics locks, surface-finish rules, JSON schema validation and caching |
| Generation, repair & audit | Provider fallback chain, reference priority, vision verifier inputs, bounded repair, orphan recovery, aspect-ratio checks, append-only cost pricing |
| Review & campaigns | Human feedback board, repair brief export, second-pass checkpoints, best-available selection, frozen replacement cohorts |
| Voices, motion & security | Consent-gated voice cloning, clean plates, Seedance audio routing, spend caps, job recovery, SSRF-guarded cast image search |
06Technology stack
6.1 Python packages
| Package | Min version | License | Used for |
|---|---|---|---|
| FastAPI | 0.115 | MIT | HTTP API, routing, request validation |
| Uvicorn | 0.32 | BSD-3-Clause | ASGI server; auto-reload in local development |
| Starlette (via FastAPI) | — | BSD-3-Clause | Middleware, static responses |
| Pydantic | 2.0 | MIT | Request bodies and export models |
| python-multipart | 0.0.9 | Apache-2.0 | PDF, image, and audio uploads |
| pypdf | 5.0 | BSD-3-Clause | Screenplay PDF parsing |
| ReportLab | 4.2 | BSD-style | Screenplay PDF export |
| Pillow | 10.0 | MIT-CMU (HPND) | Image checks, LUTs, caption frames, format normalization |
| python-dotenv | 1.0 | BSD-3-Clause | Loading local environment config |
| openai | 2.0 | Apache-2.0 | OpenAI images/chat/vision, and xAI Grok endpoint |
| yt-dlp | 2024.8 | Unlicense | Resolving YouTube streams for look references |
6.2 System tools & frontend
| Item | Detail |
|---|---|
| Python | 3.10+ (Docker uses 3.12; local dev tested on 3.14) |
| ffmpeg / ffprobe | MP4 assembly, audio mixing, voice validation, YouTube frame capture |
| Frontend | Vanilla HTML, CSS, and JavaScript — no framework, no bundler, no CDN JavaScript |
| Fonts | Cormorant Garamond, Outfit, JetBrains Mono (Google Fonts); Courier Prime bundled for PDF export |
| Storage | Local filesystem (atomic JSON and media files, no database) |
6.3 Optional external services (key-gated)
| Service | Env vars | Used for |
|---|---|---|
| OpenAI Images / Chat / Vision | OPENAI_API_KEY | Stills, repairs, try-ons, beat planning, story analysis, vision verification |
| xAI Grok Imagine | XAI_API_KEY | Secondary image provider |
| Pollinations | none | Free text-to-image fallback |
| Google Programmable Search | GOOGLE_CSE_API_KEY, GOOGLE_CSE_CX | Cast likeness search |
| ElevenLabs | ELEVENLABS_API_KEY | Consented character voices (clone, design, TTS, voice changer) |
| BytePlus ModelArk (Seedance 2.5) | ARK_API_KEY | Image-to-video motion clips |
| YouTube | none | Movie-look frame capture via yt-dlp |