# anuar234/higgsapi architecture

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

- Interactive diagram: https://gitdiagram.com/anuar234/higgsapi
- Repository: https://github.com/anuar234/higgsapi

## Overview

Higgsapi is a browser-based video editor centered on regenerating footage at a clip boundary, with AI editing, an in-editor tool-using agent, project/profile features, and local-backend generation services. The primary workflow is to select a timeline clip, prepare neighboring footage and boundary frames, write and review a prompt, generate a replacement, and place it in the same timeline position. The graph uses README-described relationships where implementation excerpts are unavailable; those links are cited to the README rather than presented as inspected source calls.

Main entry points: [`local-backend/server.mjs`](https://github.com/anuar234/higgsapi/blob/main/local-backend/server.mjs) (Backend API), [`apps/web/src/pages/editor.tsx`](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/pages/editor.tsx) (Editor page), [`apps/web/src/engine/qwen-agent.ts`](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/qwen-agent.ts) (Editor tool loop), [`apps/web/src/engine/regenerate.ts`](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/regenerate.ts) (Clip regeneration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editing["Browser editor"]
  node_editor["Editor page<br/>[editor.tsx]"]
  node_timeline["Timeline engine<br/>[controller.ts]"]
  node_engine["Editor engine<br/>[create-engine.ts]"]
  node_runtime["Scene renderer<br/>[render.ts]"]
  node_export["Media encoder<br/>[encoder.ts]"]
end

subgraph group_generation["AI generation"]
  node_regen["Clip regeneration<br/>[regenerate.ts]"]
  node_ai_edit["AI edit planning<br/>[plan.ts]"]
  node_gen_ui["Generation controls"]
end

subgraph group_agent["Agent tools"]
  node_agent_ui["Agent chat<br/>[chat-panel.tsx]"]
  node_agent_loop["Editor tool loop<br/>[qwen-agent.ts]"]
  node_mcp["MCP services<br/>[mcp.mjs]"]
end

subgraph group_services["Local services"]
  node_backend["Backend API<br/>[server.mjs]"]
  node_prompt["Prompt writer<br/>[prompt-ai.mjs]"]
  node_provider["Generation provider<br/>[higgsfield.mjs]"]
  node_storage[("Media storage<br/>[storage.mjs]")]
end

subgraph group_accounts["Projects and profiles"]
  node_projects["Project services<br/>[projects.mjs]"]
  node_profiles["Reference profiles<br/>[profiles.mjs]"]
  node_showcase["Profile showcase"]
  node_supabase[("Supabase auth<br/>[supabase-auth.mjs]")]
end

node_user(("Editor user"))

node_user -->|"opens"| node_editor
node_editor -.->|"edits clips"| node_timeline
node_editor -.->|"drives"| node_engine
node_engine -->|"renders scenes"| node_runtime
node_timeline -.->|"starts regeneration"| node_regen
node_regen -.->|"prepares prompt"| node_gen_ui
node_regen -->|"requests generation"| node_backend
node_backend -->|"writes prompts"| node_prompt
node_backend -->|"runs jobs"| node_provider
node_backend -->|"stores media"| node_storage
node_backend -->|"reads project files"| node_projects
node_user -->|"requests shot edits"| node_ai_edit
node_ai_edit -.->|"configures takes"| node_gen_ui
node_gen_ui -.->|"starts generation"| node_backend
node_user -->|"opens chat"| node_agent_ui
node_agent_ui -.->|"sends instructions"| node_agent_loop
node_agent_loop -->|"issues editor commands"| node_engine
node_agent_loop -->|"requests model turns"| node_backend
node_agent_loop -.->|"uses connected tools"| node_mcp
node_user -->|"manages projects"| node_projects
node_user -->|"manages references"| node_profiles
node_profiles -.->|"stores profile media"| node_storage
node_user -->|"shares profiles"| node_showcase
node_backend -->|"authenticates requests"| node_supabase
node_editor -->|"exports media"| node_export

click node_editor "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/pages/editor.tsx"
click node_timeline "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/timeline/controller.ts"
click node_engine "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/create-engine.ts"
click node_runtime "https://github.com/anuar234/higgsapi/blob/main/packages/runtime/src/systems/render.ts"
click node_export "https://github.com/anuar234/higgsapi/blob/main/packages/encoder/src/encoder.ts"
click node_regen "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/regenerate.ts"
click node_ai_edit "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/ai-edit/plan.ts"
click node_gen_ui "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/components/genai/use-generate-video.tsx"
click node_backend "https://github.com/anuar234/higgsapi/blob/main/local-backend/server.mjs"
click node_prompt "https://github.com/anuar234/higgsapi/blob/main/local-backend/prompt-ai.mjs"
click node_provider "https://github.com/anuar234/higgsapi/blob/main/local-backend/higgsfield.mjs"
click node_storage "https://github.com/anuar234/higgsapi/blob/main/local-backend/storage.mjs"
click node_agent_ui "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/agent-chat/chat-panel.tsx"
click node_agent_loop "https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/qwen-agent.ts"
click node_mcp "https://github.com/anuar234/higgsapi/blob/main/local-backend/mcp.mjs"
click node_projects "https://github.com/anuar234/higgsapi/blob/main/local-backend/projects.mjs"
click node_profiles "https://github.com/anuar234/higgsapi/blob/main/local-backend/profiles.mjs"
click node_showcase "https://github.com/anuar234/higgsapi/blob/main/local-backend/profiles-vitrina.mjs"
click node_supabase "https://github.com/anuar234/higgsapi/blob/main/local-backend/supabase-auth.mjs"

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_editor,node_timeline,node_engine,node_runtime,node_export,node_user toneBlue
class node_regen,node_ai_edit,node_gen_ui toneAmber
class node_agent_ui,node_agent_loop,node_mcp toneMint
class node_backend,node_prompt,node_provider,node_storage toneRose
class node_projects,node_profiles,node_showcase,node_supabase toneIndigo
```

## Components

### Browser editor

- [Editor page](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/pages/editor.tsx): `apps/web/src/pages/editor.tsx`
- [Timeline engine](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/timeline/controller.ts): `apps/web/src/engine/timeline/controller.ts`
- [Editor engine](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/create-engine.ts): `apps/web/src/engine/create-engine.ts`
- [Scene renderer](https://github.com/anuar234/higgsapi/blob/main/packages/runtime/src/systems/render.ts): `packages/runtime/src/systems/render.ts`
- [Media encoder](https://github.com/anuar234/higgsapi/blob/main/packages/encoder/src/encoder.ts): `packages/encoder/src/encoder.ts`

### AI generation

- [Clip regeneration](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/regenerate.ts): `apps/web/src/engine/regenerate.ts`
- [AI edit planning](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/ai-edit/plan.ts): `apps/web/src/engine/ai-edit/plan.ts`
- [Generation controls](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/components/genai/use-generate-video.tsx): `apps/web/src/components/genai/use-generate-video.tsx`

### Agent tools

- [Agent chat](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/agent-chat/chat-panel.tsx): `apps/web/src/agent-chat/chat-panel.tsx`
- [Editor tool loop](https://github.com/anuar234/higgsapi/blob/main/apps/web/src/engine/qwen-agent.ts): `apps/web/src/engine/qwen-agent.ts`
- [MCP services](https://github.com/anuar234/higgsapi/blob/main/local-backend/mcp.mjs): `local-backend/mcp.mjs`

### Local services

- [Backend API](https://github.com/anuar234/higgsapi/blob/main/local-backend/server.mjs): `local-backend/server.mjs`
- [Prompt writer](https://github.com/anuar234/higgsapi/blob/main/local-backend/prompt-ai.mjs): `local-backend/prompt-ai.mjs`
- [Generation provider](https://github.com/anuar234/higgsapi/blob/main/local-backend/higgsfield.mjs): `local-backend/higgsfield.mjs`
- [Media storage](https://github.com/anuar234/higgsapi/blob/main/local-backend/storage.mjs): `local-backend/storage.mjs`

### Projects and profiles

- [Project services](https://github.com/anuar234/higgsapi/blob/main/local-backend/projects.mjs): `local-backend/projects.mjs`
- [Reference profiles](https://github.com/anuar234/higgsapi/blob/main/local-backend/profiles.mjs): `local-backend/profiles.mjs`
- [Profile showcase](https://github.com/anuar234/higgsapi/blob/main/local-backend/profiles-vitrina.mjs): `local-backend/profiles-vitrina.mjs`
- [Supabase auth](https://github.com/anuar234/higgsapi/blob/main/local-backend/supabase-auth.mjs): `local-backend/supabase-auth.mjs`

### Other components

- **Editor user**

## Connections

- Editor user → Editor page: opens (evidence: `README.md`)
- Editor page → Timeline engine: edits clips
- Editor page → Editor engine: drives
- Editor engine → Scene renderer: renders scenes (evidence: `apps/web/src/engine/create-engine.ts`)
- Timeline engine → Clip regeneration: starts regeneration
- Clip regeneration → Generation controls: prepares prompt
- Clip regeneration → Backend API: requests generation (evidence: `README.md`)
- Backend API → Prompt writer: writes prompts (evidence: `local-backend/server.mjs`)
- Backend API → Generation provider: runs jobs (evidence: `local-backend/server.mjs`)
- Backend API → Media storage: stores media (evidence: `local-backend/server.mjs`)
- Backend API → Project services: reads project files (evidence: `local-backend/server.mjs`)
- Editor user → AI edit planning: requests shot edits (evidence: `README.md`)
- AI edit planning → Generation controls: configures takes
- Generation controls → Backend API: starts generation
- Editor user → Agent chat: opens chat (evidence: `README.md`)
- Agent chat → Editor tool loop: sends instructions
- Editor tool loop → Editor engine: issues editor commands (evidence: `README.md`)
- Editor tool loop → Backend API: requests model turns (evidence: `README.md`)
- Editor tool loop → MCP services: uses connected tools
- Editor user → Project services: manages projects (evidence: `README.md`)
- Editor user → Reference profiles: manages references (evidence: `README.md`)
- Reference profiles → Media storage: stores profile media
- Editor user → Profile showcase: shares profiles (evidence: `README.md`)
- Backend API → Supabase auth: authenticates requests (evidence: `local-backend/server.mjs`)
- Editor page → Media encoder: exports media (evidence: `README.md`)
