# medevs/primalbound architecture

> Architecture diagram of the GitHub repository medevs/primalbound, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/medevs/primalbound
- Repository: https://github.com/medevs/primalbound

## Overview

#### Purpose and deploy boundary
Primal Bound is a brand monorepo for a documentary YouTube channel and its marketing/editorial site. The deployable product is exclusively the static Next.js site under `website/`; `OpenMontage/` is a locally operated video-production system. Primary website entries are `website/app/page.tsx`, `website/app/layout.tsx`, and `website/app/blog/page.tsx`.

#### Website application and content
The site uses Next.js 16, Tailwind 4, TypeScript, and pnpm. App-router routes provide the landing page, mission page, blog index, and MDX article content: `website/app/page.tsx`, `website/app/mission/page.tsx`, `website/app/blog/why-tribes-dont-get-lonely/page.mdx`. Global presentation and site-level navigation are centralized in `website/app/globals.css` and `website/components/SiteHeader.tsx`.

#### Scroll-world experience
The landing page’s defining interactive subsystem is a scroll-synchronized “world” composed from video assets. `website/components/ScrollWorld.tsx` renders the experience, driven by scene/media definitions in `website/lib/world-config.ts` and scroll behavior in `website/lib/scrub-engine.js`. Runtime media is pre-encoded and served as static files from `website/public/world/`, with desktop/mobile variants such as `website/public/world/city.mp4` and `website/public/world/city-m.mp4`.

#### Asset generation pipeline
Scroll-world media is generated outside the web build. `website/generation/world.py` calls fal.ai using `FAL_KEY` loaded from `OpenMontage/.env`; intermediate material is intended for local-only `website/generation/work/`, while approved encodes are published into `website/public/world/`. Supporting regeneration/QA wiring resides in `website/generation/bridge_bound.py` and `website/generation/qa.mjs`. This is a clear boundary: generation needs the OpenMontage Python environment; the deployed site only consumes resulting static assets.

#### Video-production platform
`OpenMontage/` is a vendored, locally modified Python production pipeline for planning, generating, composing, reviewing, and exporting videos. Its main CLI/server entry points are `OpenMontage/setup.py`, `OpenMontage/backlot/__main__.py`, and `OpenMontage/render_demo.py`. Pipeline variants are declarative YAML definitions, notably the locally relevant `OpenMontage/pipeline_defs/vox-explainer.yaml`, alongside cinematic, animation, avatar, and documentary variants.

#### Pipeline contracts and orchestration
OpenMontage treats production stages as artifact-driven workflows. JSON schemas define handoffs for briefs, scripts, scene plans, manifests, editing decisions, reviews, render reports, and publishing: `OpenMontage/schemas/artifacts/brief.schema.json`, `OpenMontage/schemas/artifacts/scene_plan.schema.json`, `OpenMontage/schemas/artifacts/render_report.schema.json`. Shared orchestration concerns—configuration, checkpoints, eventing, provider selection, and scoring—are concentrated in `OpenMontage/lib/config_model.py`, `OpenMontage/lib/checkpoint.py`, and `OpenMontage/lib/pipeline_loader.py`.

#### Media runtimes, providers, and review
The production runtime combines Python tools, FFmpeg-oriented media processing, optional GPU/local generation dependencies, and a TypeScript Remotion compositor. Remotion compositions start at `OpenMontage/remotion-composer/src/Root.tsx`; video assembly and provider routing live in `OpenMontage/tools/video/video_compose.py` and `OpenMontage/tools/video/video_selector.py`. External integrations include fal.ai for website imagery and multiple configurable AI/media services represented by adapters such as `OpenMontage/tools/_kling/client.py`, `OpenMontage/tools/_comfyui/client.py`, and `OpenMontage/tools/audio/elevenlabs_tts.py`. The Backlot server/UI provides production-state visibility and gate-oriented review through `OpenMontage/backlot/server.py`, `OpenMontage/backlot/state.py`, and `OpenMontage/backlot/ui/board.js`.

Main entry points: [`OpenMontage/lib/pipeline_loader.py`](https://github.com/medevs/primalbound/blob/main/OpenMontage/lib/pipeline_loader.py) (Pipeline orchestration), [`website/components/ScrollWorld.tsx`](https://github.com/medevs/primalbound/blob/main/website/components/ScrollWorld.tsx) (Scroll world), [`website/generation/world.py`](https://github.com/medevs/primalbound/blob/main/website/generation/world.py) (World generator), [`website/app/page.tsx`](https://github.com/medevs/primalbound/blob/main/website/app/page.tsx) (App routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_website["Static website"]
  node_site_routes["App routes<br/>Next.js routes<br/>[page.tsx]"]
  node_site_layout["Site shell<br/>layout<br/>[layout.tsx]"]
  node_site_header["Site header<br/>[SiteHeader.tsx]"]
  node_scroll_world["Scroll world<br/>interactive component<br/>[ScrollWorld.tsx]"]
  node_world_config["World definitions<br/>scene config<br/>[world-config.ts]"]
  node_scrub_engine["Scroll scrub engine<br/>scroll runtime<br/>[scrub-engine.js]"]
  node_world_assets[("Published world media<br/>static media<br/>[city.mp4]")]
end

subgraph group_generation["World asset generation"]
  node_world_generator["World generator<br/>Python pipeline<br/>[world.py]"]
  node_generation_qa["Generation bridge and QA<br/>pipeline tooling<br/>[bridge_bound.py]"]
  node_generation_env{{"OpenMontage environment<br/>local environment<br/>[.env.example]"}}
end

subgraph group_production["OpenMontage production"]
  node_production_entry["Production entry points<br/>CLI and server<br/>[setup.py]"]
  node_pipeline_defs["Pipeline definitions<br/>YAML workflows<br/>[vox-explainer.yaml]"]
  node_artifact_contracts["Artifact contracts<br/>JSON schemas<br/>[brief.schema.json]"]
  node_orchestration["Pipeline orchestration<br/>Python runtime<br/>[pipeline_loader.py]"]
  node_media_assembly["Media assembly<br/>video tools<br/>[video_compose.py]"]
  node_remotion["Remotion compositor<br/>TypeScript runtime<br/>[Root.tsx]"]
  node_providers{{"AI and media providers<br/>provider adapters<br/>[client.py]"}}
  node_backlot["Backlot review<br/>server and UI<br/>[server.py]"]
end

node_site_routes -->|"renders within"| node_site_layout
node_site_layout -->|"includes"| node_site_header
node_site_routes -->|"landing page renders"| node_scroll_world
node_scroll_world -->|"uses scenes"| node_world_config
node_scroll_world -->|"uses scroll timing"| node_scrub_engine
node_scroll_world -->|"plays"| node_world_assets
node_world_generator -.->|"loads FAL_KEY"| node_generation_env
node_world_generator -->|"regenerated and checked by"| node_generation_qa
node_generation_qa -->|"publishes approved encodes"| node_world_assets
node_production_entry -->|"selects"| node_pipeline_defs
node_pipeline_defs -->|"drives"| node_orchestration
node_artifact_contracts -->|"governs handoffs"| node_orchestration
node_orchestration -->|"routes to"| node_providers
node_orchestration -->|"orchestrates"| node_media_assembly
node_media_assembly -->|"composites with"| node_remotion
node_orchestration -->|"reports state to"| node_backlot
node_backlot -->|"reviews artifacts"| node_artifact_contracts
node_generation_env -.->|"supports local runtime"| node_world_generator

click node_site_routes "https://github.com/medevs/primalbound/blob/main/website/app/page.tsx"
click node_site_layout "https://github.com/medevs/primalbound/blob/main/website/app/layout.tsx"
click node_site_header "https://github.com/medevs/primalbound/blob/main/website/components/SiteHeader.tsx"
click node_scroll_world "https://github.com/medevs/primalbound/blob/main/website/components/ScrollWorld.tsx"
click node_world_config "https://github.com/medevs/primalbound/blob/main/website/lib/world-config.ts"
click node_scrub_engine "https://github.com/medevs/primalbound/blob/main/website/lib/scrub-engine.js"
click node_world_assets "https://github.com/medevs/primalbound/blob/main/website/public/world/city.mp4"
click node_world_generator "https://github.com/medevs/primalbound/blob/main/website/generation/world.py"
click node_generation_qa "https://github.com/medevs/primalbound/blob/main/website/generation/bridge_bound.py"
click node_generation_env "https://github.com/medevs/primalbound/blob/main/OpenMontage/.env.example"
click node_production_entry "https://github.com/medevs/primalbound/blob/main/OpenMontage/setup.py"
click node_pipeline_defs "https://github.com/medevs/primalbound/blob/main/OpenMontage/pipeline_defs/vox-explainer.yaml"
click node_artifact_contracts "https://github.com/medevs/primalbound/blob/main/OpenMontage/schemas/artifacts/brief.schema.json"
click node_orchestration "https://github.com/medevs/primalbound/blob/main/OpenMontage/lib/pipeline_loader.py"
click node_media_assembly "https://github.com/medevs/primalbound/blob/main/OpenMontage/tools/video/video_compose.py"
click node_remotion "https://github.com/medevs/primalbound/blob/main/OpenMontage/remotion-composer/src/Root.tsx"
click node_providers "https://github.com/medevs/primalbound/blob/main/OpenMontage/tools/_kling/client.py"
click node_backlot "https://github.com/medevs/primalbound/blob/main/OpenMontage/backlot/server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_site_routes,node_site_layout,node_site_header,node_scroll_world,node_world_config,node_scrub_engine,node_world_assets toneBlue
class node_world_generator,node_generation_qa,node_generation_env toneAmber
class node_production_entry,node_pipeline_defs,node_artifact_contracts,node_orchestration,node_media_assembly,node_remotion,node_providers,node_backlot toneMint
```

## Components

### Static website

Deployable Next.js application.

- [App routes](https://github.com/medevs/primalbound/blob/main/website/app/page.tsx): Next.js routes · Landing, mission, blog, and MDX content. · `website/app/page.tsx`
- [Site shell](https://github.com/medevs/primalbound/blob/main/website/app/layout.tsx): layout · Global layout, styles, and navigation. · `website/app/layout.tsx`
- [Site header](https://github.com/medevs/primalbound/blob/main/website/components/SiteHeader.tsx): `website/components/SiteHeader.tsx`
- [Scroll world](https://github.com/medevs/primalbound/blob/main/website/components/ScrollWorld.tsx): interactive component · Scroll-synchronized video world on the landing page. · `website/components/ScrollWorld.tsx`
- [World definitions](https://github.com/medevs/primalbound/blob/main/website/lib/world-config.ts): scene config · `website/lib/world-config.ts`
- [Scroll scrub engine](https://github.com/medevs/primalbound/blob/main/website/lib/scrub-engine.js): scroll runtime · `website/lib/scrub-engine.js`
- [Published world media](https://github.com/medevs/primalbound/blob/main/website/public/world/city.mp4): static media · Desktop and mobile pre-encoded video assets. · `website/public/world/city.mp4`

### World asset generation

Local pipeline publishing static media.

- [World generator](https://github.com/medevs/primalbound/blob/main/website/generation/world.py): Python pipeline · Generates world media through fal.ai. · `website/generation/world.py`
- [Generation bridge and QA](https://github.com/medevs/primalbound/blob/main/website/generation/bridge_bound.py): pipeline tooling · `website/generation/bridge_bound.py`
- [OpenMontage environment](https://github.com/medevs/primalbound/blob/main/OpenMontage/.env.example): local environment · Supplies FAL_KEY and Python dependencies. · `OpenMontage/.env.example`

### OpenMontage production

Locally operated video-production platform.

- [Production entry points](https://github.com/medevs/primalbound/blob/main/OpenMontage/setup.py): CLI and server · Setup, Backlot CLI, and demo render entry points. · `OpenMontage/setup.py`
- [Pipeline definitions](https://github.com/medevs/primalbound/blob/main/OpenMontage/pipeline_defs/vox-explainer.yaml): YAML workflows · Declarative production pipeline variants. · `OpenMontage/pipeline_defs/vox-explainer.yaml`
- [Artifact contracts](https://github.com/medevs/primalbound/blob/main/OpenMontage/schemas/artifacts/brief.schema.json): JSON schemas · Stage handoffs for planning, rendering, review, and publishing. · `OpenMontage/schemas/artifacts/brief.schema.json`
- [Pipeline orchestration](https://github.com/medevs/primalbound/blob/main/OpenMontage/lib/pipeline_loader.py): Python runtime · Configuration, checkpoints, events, providers, and scoring. · `OpenMontage/lib/pipeline_loader.py`
- [Media assembly](https://github.com/medevs/primalbound/blob/main/OpenMontage/tools/video/video_compose.py): video tools · FFmpeg-oriented composition and provider selection. · `OpenMontage/tools/video/video_compose.py`
- [Remotion compositor](https://github.com/medevs/primalbound/blob/main/OpenMontage/remotion-composer/src/Root.tsx): TypeScript runtime · `OpenMontage/remotion-composer/src/Root.tsx`
- [AI and media providers](https://github.com/medevs/primalbound/blob/main/OpenMontage/tools/_kling/client.py): provider adapters · Configurable generation and audio/media services. · `OpenMontage/tools/_kling/client.py`
- [Backlot review](https://github.com/medevs/primalbound/blob/main/OpenMontage/backlot/server.py): server and UI · Production-state visibility and gate-oriented review. · `OpenMontage/backlot/server.py`

## Connections

- App routes → Site shell: renders within
- Site shell → Site header: includes
- App routes → Scroll world: landing page renders
- Scroll world → World definitions: uses scenes
- Scroll world → Scroll scrub engine: uses scroll timing
- Scroll world → Published world media: plays
- World generator → OpenMontage environment: loads FAL_KEY
- World generator → Generation bridge and QA: regenerated and checked by
- Generation bridge and QA → Published world media: publishes approved encodes
- Production entry points → Pipeline definitions: selects
- Pipeline definitions → Pipeline orchestration: drives
- Artifact contracts → Pipeline orchestration: governs handoffs
- Pipeline orchestration → AI and media providers: routes to
- Pipeline orchestration → Media assembly: orchestrates
- Media assembly → Remotion compositor: composites with
- Pipeline orchestration → Backlot review: reports state to
- Backlot review → Artifact contracts: reviews artifacts
- OpenMontage environment → World generator: supports local runtime
