# nexu-io/html-video architecture

> Architecture diagram of the GitHub repository nexu-io/html-video, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nexu-io/html-video
- Repository: https://github.com/nexu-io/html-video

## Overview

#### Purpose and entry points
`html-video` is a local-first monorepo that turns a prompt, article URL, or GitHub repository into an animated MP4. It coordinates a coding agent, template metadata, an engine adapter, and local encoding. Main executable entry point: `packages/cli/src/bin.ts`; command composition and studio-facing operations live in `packages/cli/src/index.ts` and `packages/cli/src/commands/project.ts`.

#### Project domain and orchestration
Core owns project-domain types, asset handling, engine registration, failures, and optional audio generation/muxing:
- `packages/core/src/project.ts`
- `packages/core/src/registry.ts`
- `packages/core/src/asset-store.ts`
- `packages/core/src/minimax.ts`

This package is the boundary between project/studio workflows and rendering engines. It should depend on adapter contracts rather than engine-specific implementation.

#### Agent runtime layer
The runtime abstracts 14 local or API-backed coding agents behind detection, registry, process spawning, and ACP communication:
- `packages/runtime/src/detect.ts`
- `packages/runtime/src/registry.ts`
- `packages/runtime/src/spawn.ts`
- `packages/runtime/src/acp-client.ts`

Agent definitions under `packages/runtime/src/defs/` encode invocation differences (CLI stdin, ACP-over-stdio, or Anthropic API). The CLI/studio selects an available agent, passes fetched source/template context, and consumes its generated storyboard and frame content.

#### Storyboard and source ingestion flow
The primary path is source → agent → storyboard → rendered frames. URL/repository material is fetched server-side and normalized before agents receive it:
- `packages/cli/src/fetch-source.ts`
- `packages/cli/src/studio-server.ts`

The content graph is the engine-independent multi-frame IR, representing nodes and relationships and determining ordered scenes:
- `packages/content-graph/src/index.ts`
- `packages/core/src/types/index.ts`

Single-frame work can bypass this storyboard stage. The graph boundary is central: agents create content intent and sequencing; adapters only consume render-ready frame inputs.

#### Templates as portable render inputs
Templates are self-contained assets with an agent-readable manifest describing intent, inputs, output constraints, and license provenance. The CLI discovers/searches them through:
- `packages/cli/src/commands/templates.ts`
- `templates/frame-data-chart-nyt/template.html-video.yaml`
- `templates/frame-product-promo-30s/template.html-video.yaml`

Most templates are animated HTML sources; some support React/Remotion-style source layouts. Template files are content packages, not application code, and should remain engine-agnostic at the metadata level.

#### Rendering adapter boundary
Engine adapters implement capability declaration, validation, and rendering under a common conceptual `render(input, ctx)` contract:
- `packages/adapter-hyperframes/src/index.ts`
- `packages/adapter-hyperframes/src/validate.ts`
- `packages/adapter-hyperframes/src/render.ts`

Hyperframes is the currently material implementation: headless Chromium captures animated HTML, then ffmpeg encodes/concatenates MP4 output. The Remotion adapter exists as a separate integration boundary, including a React bridge:
- `packages/adapter-remotion/src/render.ts`
- `packages/adapter-remotion/src/bridge/Root.tsx`

External local dependencies are Node.js, Chromium/Playwright, and ffmpeg/libx264. MiniMax is optional for music and narration, with ffmpeg used for final audio mixing.

#### User surfaces and runtime topology
The CLI supports diagnostics, engine listing, templates, projects, and starts the local studio server:
- `packages/cli/src/commands/doctor.ts`
- `packages/cli/src/commands/list-engines.ts`
- `packages/cli/src/studio-server.ts`

The shipped browser studio is static client code served locally:
- `packages/project-studio/public/index.html`
- `packages/project-studio/public/app.js`

A separate Vite/React studio iteration exists in `packages/studio-next/src/App.tsx`, but it is distinct from the static studio package. No hosted application or required render service is implied; network use is limited to source retrieval, agent APIs where selected, and optional MiniMax generation.

Main entry points: [`packages/core/src/project.ts`](https://github.com/nexu-io/html-video/blob/main/packages/core/src/project.ts) (Project domain), [`packages/cli/src/index.ts`](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/index.ts) (Commands and projects), [`packages/adapter-hyperframes/src/render.ts`](https://github.com/nexu-io/html-video/blob/main/packages/adapter-hyperframes/src/render.ts) (Hyperframes adapter), [`packages/cli/src/studio-server.ts`](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/studio-server.ts) (Local studio server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["Local user surfaces"]
  node_cli["CLI executable<br/>Node CLI<br/>[bin.ts]"]
  node_cli_ops["Commands and projects<br/>CLI operations<br/>[index.ts]"]
  node_studio_server["Local studio server<br/>Node server<br/>[studio-server.ts]"]
  node_static_studio["Static browser studio<br/>browser client<br/>[app.js]"]
  node_next_studio["Next studio iteration<br/>Vite React client<br/>[App.tsx]"]
end

subgraph group_orchestration["Project orchestration"]
  node_project_core["Project domain<br/>core API<br/>[project.ts]"]
  node_engine_registry["Engine registry<br/>adapter contracts<br/>[registry.ts]"]
  node_asset_store[("Asset store<br/>local assets<br/>[asset-store.ts]")]
  node_audio["Optional audio generation<br/>MiniMax integration<br/>[minimax.ts]"]
end

subgraph group_agents["Agent runtime"]
  node_agent_detect["Agent detection<br/>runtime detection<br/>[detect.ts]"]
  node_agent_registry["Agent registry<br/>agent definitions<br/>[registry.ts]"]
  node_agent_transport["Agent execution<br/>spawn and ACP<br/>[acp-client.ts]"]
end

subgraph group_content["Content and templates"]
  node_source_fetch["Source ingestion<br/>server fetcher<br/>[fetch-source.ts]"]
  node_content_graph["Content graph IR<br/>multi-frame storyboard<br/>[index.ts]"]
  node_template_catalog["Template discovery<br/>template catalog<br/>[templates.ts]"]
  node_template_manifest["Template manifests<br/>portable render input"]
end

subgraph group_rendering["Rendering adapters"]
  node_hyperframes["Hyperframes adapter<br/>render adapter<br/>[render.ts]"]
  node_remotion["Remotion adapter<br/>render adapter<br/>[render.ts]"]
  node_react_bridge["Remotion React bridge<br/>React composition bridge<br/>[Root.tsx]"]
  node_local_encoder["Local capture and encode<br/>Chromium and ffmpeg"]
end

node_cli -->|"invokes"| node_cli_ops
node_cli_ops -->|"starts"| node_studio_server
node_studio_server -->|"serves"| node_static_studio
node_studio_server -->|"fetches"| node_source_fetch
node_cli_ops -->|"manages projects"| node_project_core
node_cli_ops -->|"searches templates"| node_template_catalog
node_template_catalog -->|"discovers"| node_template_manifest
node_project_core -->|"stores assets"| node_asset_store
node_source_fetch -->|"provides normalized context"| node_agent_detect
node_agent_detect -->|"selects available agent"| node_agent_registry
node_agent_registry -->|"configures invocation"| node_agent_transport
node_template_manifest -->|"provides template context"| node_agent_transport
node_agent_transport -->|"generates storyboard"| node_content_graph
node_content_graph -->|"supplies ordered frame intent"| node_project_core
node_project_core -->|"resolves engine"| node_engine_registry
node_engine_registry -->|"registers"| node_hyperframes
node_engine_registry -->|"registers"| node_remotion
node_template_manifest -->|"render input"| node_hyperframes
node_content_graph -->|"render-ready frames"| node_hyperframes
node_hyperframes -->|"captures and encodes"| node_local_encoder
node_remotion -->|"uses"| node_react_bridge
node_project_core -.->|"optionally generates audio"| node_audio
node_audio -.->|"mixes final audio"| node_local_encoder

click node_cli "https://github.com/nexu-io/html-video/blob/main/packages/cli/src/bin.ts"
click node_cli_ops "https://github.com/nexu-io/html-video/blob/main/packages/cli/src/index.ts"
click node_studio_server "https://github.com/nexu-io/html-video/blob/main/packages/cli/src/studio-server.ts"
click node_static_studio "https://github.com/nexu-io/html-video/blob/main/packages/project-studio/public/app.js"
click node_next_studio "https://github.com/nexu-io/html-video/blob/main/packages/studio-next/src/App.tsx"
click node_project_core "https://github.com/nexu-io/html-video/blob/main/packages/core/src/project.ts"
click node_engine_registry "https://github.com/nexu-io/html-video/blob/main/packages/core/src/registry.ts"
click node_asset_store "https://github.com/nexu-io/html-video/blob/main/packages/core/src/asset-store.ts"
click node_audio "https://github.com/nexu-io/html-video/blob/main/packages/core/src/minimax.ts"
click node_source_fetch "https://github.com/nexu-io/html-video/blob/main/packages/cli/src/fetch-source.ts"
click node_content_graph "https://github.com/nexu-io/html-video/blob/main/packages/content-graph/src/index.ts"
click node_template_catalog "https://github.com/nexu-io/html-video/blob/main/packages/cli/src/commands/templates.ts"
click node_template_manifest "https://github.com/nexu-io/html-video/blob/main/templates/frame-data-chart-nyt/template.html-video.yaml"
click node_agent_detect "https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/detect.ts"
click node_agent_registry "https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/registry.ts"
click node_agent_transport "https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/acp-client.ts"
click node_hyperframes "https://github.com/nexu-io/html-video/blob/main/packages/adapter-hyperframes/src/render.ts"
click node_remotion "https://github.com/nexu-io/html-video/blob/main/packages/adapter-remotion/src/render.ts"
click node_react_bridge "https://github.com/nexu-io/html-video/blob/main/packages/adapter-remotion/src/bridge/Root.tsx"

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_cli,node_cli_ops,node_studio_server,node_static_studio,node_next_studio toneBlue
class node_project_core,node_engine_registry,node_asset_store,node_audio toneAmber
class node_agent_detect,node_agent_registry,node_agent_transport toneMint
class node_source_fetch,node_content_graph,node_template_catalog,node_template_manifest toneRose
class node_hyperframes,node_remotion,node_react_bridge,node_local_encoder toneIndigo
```

## Components

### Local user surfaces

- [CLI executable](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/bin.ts): Node CLI · Main local command entry point. · `packages/cli/src/bin.ts`
- [Commands and projects](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/index.ts): CLI operations · Composes project, diagnostics, engine, and template operations. · `packages/cli/src/index.ts`
- [Local studio server](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/studio-server.ts): Node server · Serves studio and fetches source material locally. · `packages/cli/src/studio-server.ts`
- [Static browser studio](https://github.com/nexu-io/html-video/blob/main/packages/project-studio/public/app.js): browser client · `packages/project-studio/public/app.js`
- [Next studio iteration](https://github.com/nexu-io/html-video/blob/main/packages/studio-next/src/App.tsx): Vite React client · Separate from the shipped static studio. · `packages/studio-next/src/App.tsx`

### Project orchestration

- [Project domain](https://github.com/nexu-io/html-video/blob/main/packages/core/src/project.ts): core API · Owns projects, assets, failures, and engine-facing workflows. · `packages/core/src/project.ts`
- [Engine registry](https://github.com/nexu-io/html-video/blob/main/packages/core/src/registry.ts): adapter contracts · Registers engines behind engine-independent contracts. · `packages/core/src/registry.ts`
- [Asset store](https://github.com/nexu-io/html-video/blob/main/packages/core/src/asset-store.ts): local assets · `packages/core/src/asset-store.ts`
- [Optional audio generation](https://github.com/nexu-io/html-video/blob/main/packages/core/src/minimax.ts): MiniMax integration · Generates music or narration and muxes it with ffmpeg. · `packages/core/src/minimax.ts`

### Agent runtime

- [Agent detection](https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/detect.ts): runtime detection · Finds available local or API-backed agents. · `packages/runtime/src/detect.ts`
- [Agent registry](https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/registry.ts): agent definitions · Selects invocation behavior across supported agents. · `packages/runtime/src/registry.ts`
- [Agent execution](https://github.com/nexu-io/html-video/blob/main/packages/runtime/src/acp-client.ts): spawn and ACP · Runs CLI/API agents and communicates over ACP stdio. · `packages/runtime/src/acp-client.ts`

### Content and templates

- [Source ingestion](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/fetch-source.ts): server fetcher · Fetches and normalizes URL or repository material. · `packages/cli/src/fetch-source.ts`
- [Content graph IR](https://github.com/nexu-io/html-video/blob/main/packages/content-graph/src/index.ts): multi-frame storyboard · Engine-independent nodes, relationships, and ordered scenes. · `packages/content-graph/src/index.ts`
- [Template discovery](https://github.com/nexu-io/html-video/blob/main/packages/cli/src/commands/templates.ts): template catalog · Searches portable template manifests. · `packages/cli/src/commands/templates.ts`
- [Template manifests](https://github.com/nexu-io/html-video/blob/main/templates/frame-data-chart-nyt/template.html-video.yaml): portable render input · Describe intent, inputs, constraints, and provenance. · `templates/frame-data-chart-nyt/template.html-video.yaml`

### Rendering adapters

- [Hyperframes adapter](https://github.com/nexu-io/html-video/blob/main/packages/adapter-hyperframes/src/render.ts): render adapter · Validates inputs and renders animated HTML frames. · `packages/adapter-hyperframes/src/render.ts`
- [Remotion adapter](https://github.com/nexu-io/html-video/blob/main/packages/adapter-remotion/src/render.ts): render adapter · Separate React-based rendering integration. · `packages/adapter-remotion/src/render.ts`
- [Remotion React bridge](https://github.com/nexu-io/html-video/blob/main/packages/adapter-remotion/src/bridge/Root.tsx): React composition bridge · `packages/adapter-remotion/src/bridge/Root.tsx`
- **Local capture and encode**: Chromium and ffmpeg · Chromium captures frames; ffmpeg/libx264 produces MP4.

## Connections

- CLI executable → Commands and projects: invokes
- Commands and projects → Local studio server: starts
- Local studio server → Static browser studio: serves
- Local studio server → Source ingestion: fetches
- Commands and projects → Project domain: manages projects
- Commands and projects → Template discovery: searches templates
- Template discovery → Template manifests: discovers
- Project domain → Asset store: stores assets
- Source ingestion → Agent detection: provides normalized context
- Agent detection → Agent registry: selects available agent
- Agent registry → Agent execution: configures invocation
- Template manifests → Agent execution: provides template context
- Agent execution → Content graph IR: generates storyboard
- Content graph IR → Project domain: supplies ordered frame intent
- Project domain → Engine registry: resolves engine
- Engine registry → Hyperframes adapter: registers
- Engine registry → Remotion adapter: registers
- Template manifests → Hyperframes adapter: render input
- Content graph IR → Hyperframes adapter: render-ready frames
- Hyperframes adapter → Local capture and encode: captures and encodes
- Remotion adapter → Remotion React bridge: uses
- Project domain → Optional audio generation: optionally generates audio
- Optional audio generation → Local capture and encode: mixes final audio
