# somewherelostt/unfold architecture

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

- Interactive diagram: https://gitdiagram.com/somewherelostt/unfold
- Repository: https://github.com/somewherelostt/unfold

## Overview

Unfold turns uploaded footage and a brief into an editable reel: analyze media, generate an editorial plan, preview and revise it, then render an MP4. The README also describes supporting clips, reference guidance, alternate takes, caption and sound controls, and optional background jobs. Storage and job execution are included as internal layers. Several routes and integrations are unsampled, so links to them are omitted rather than inferred.

Main entry points: [`apps/web/src/components/app/studio/Studio.tsx`](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/studio/Studio.tsx) (Editing studio), [`apps/web/src/app/api/export/route.ts`](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/export/route.ts) (MP4 export API), [`apps/web/src/app/api/analyze/route.ts`](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/analyze/route.ts) (Media analysis API), [`packages/agent/src/agent.ts`](https://github.com/somewherelostt/unfold/blob/main/packages/agent/src/agent.ts) (Editorial agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Creator experience"]
  node_studio["Editing studio<br/>[Studio.tsx]"]
  node_upload["Footage upload<br/>[SourceUpload.tsx]"]
  node_supporting["Supporting assets"]
end

subgraph group_workflow["Editing workflow"]
  node_analysis_api["Media analysis API<br/>[route.ts]"]
  node_media["Media analysis pipeline"]
  node_agent["Editorial agent<br/>[agent.ts]"]
  node_agent_client["Gateway client<br/>[client.ts]"]
  node_remix_api["Remix API<br/>[route.ts]"]
  node_variants_api["Alternate takes API<br/>[route.ts]"]
  node_plan_schema["Edit plan schema<br/>[schema.ts]"]
  node_plan_compile["Plan compiler<br/>[compile.ts]"]
end

subgraph group_rendering["Preview and export"]
  node_preview["Browser preview<br/>[PlanPlayer.tsx]"]
  node_composition["Video composition<br/>[Root.tsx]"]
  node_video_quality["Render review<br/>[review.ts]"]
  node_export_api["MP4 export API<br/>[route.ts]"]
end

subgraph group_platform["App services"]
  node_private_storage[("Private storage<br/>[private-storage.ts]")]
  node_cloud_storage[("Cloud storage")]
  node_publishing["Publishing workspace"]
end

subgraph group_operations["Background operations"]
  node_jobs_api["Job API<br/>[route.ts]"]
  node_job_worker["Job worker<br/>[cloud-worker.ts]"]
  node_job_store[("Job persistence<br/>[postgres-store.ts]")]
  node_publisher_worker["Publishing worker<br/>[worker.ts]"]
  node_publisher_dispatch["Publishing dispatch<br/>[dispatch.ts]"]
  node_publisher_store[("Publishing persistence<br/>[repository.ts]")]
end

node_creator(("Creator"))

node_creator -->|"uploads footage"| node_upload
node_creator -->|"reviews and edits"| node_studio
node_upload -.->|"submits media"| node_analysis_api
node_analysis_api -.->|"requests analysis"| node_media
node_creator -->|"adds cutaways"| node_supporting
node_analysis_api -.->|"provides analysis"| node_agent
node_agent -.->|"uses gateway"| node_agent_client
node_agent -->|"produces plan"| node_plan_schema
node_studio -->|"requests revision"| node_remix_api
node_studio -->|"requests alternates"| node_variants_api
node_studio -->|"previews edit"| node_preview
node_plan_schema -->|"validates plan"| node_plan_compile
node_plan_compile -->|"feeds composition"| node_composition
node_composition -->|"renders preview"| node_preview
node_studio -->|"exports edit"| node_export_api
node_export_api -->|"prepares export plan"| node_plan_compile
node_export_api -->|"renders MP4"| node_composition
node_export_api -->|"reviews render"| node_video_quality
node_export_api -->|"reads project data"| node_private_storage
node_private_storage -.->|"cloud implementation"| node_cloud_storage
node_creator -.->|"opens publishing"| node_publishing
node_jobs_api -.->|"queues work"| node_job_worker
node_job_worker -->|"claims and finishes"| node_job_store
node_publisher_worker -->|"claims work"| node_publisher_store
node_publisher_worker -->|"dispatches task"| node_publisher_dispatch

click node_studio "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/studio/Studio.tsx"
click node_upload "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/home/SourceUpload.tsx"
click node_supporting "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/SupportingAssets.tsx"
click node_analysis_api "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/analyze/route.ts"
click node_media "https://github.com/somewherelostt/unfold/tree/main/services/media/src"
click node_agent "https://github.com/somewherelostt/unfold/blob/main/packages/agent/src/agent.ts"
click node_agent_client "https://github.com/somewherelostt/unfold/blob/main/packages/agent/src/client.ts"
click node_remix_api "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/remix/route.ts"
click node_variants_api "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/variants/route.ts"
click node_plan_schema "https://github.com/somewherelostt/unfold/blob/main/packages/core/src/schema.ts"
click node_plan_compile "https://github.com/somewherelostt/unfold/blob/main/packages/core/src/compile.ts"
click node_preview "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/preview/PlanPlayer.tsx"
click node_composition "https://github.com/somewherelostt/unfold/blob/main/packages/video/src/Root.tsx"
click node_video_quality "https://github.com/somewherelostt/unfold/blob/main/packages/video/src/review.ts"
click node_export_api "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/export/route.ts"
click node_private_storage "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/server/private-storage.ts"
click node_cloud_storage "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/server/supabase-storage.ts"
click node_publishing "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/publishing/PublishingWorkspace.tsx"
click node_jobs_api "https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/jobs/route.ts"
click node_job_worker "https://github.com/somewherelostt/unfold/blob/main/services/jobs/src/cloud-worker.ts"
click node_job_store "https://github.com/somewherelostt/unfold/blob/main/services/jobs/src/postgres-store.ts"
click node_publisher_worker "https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/worker.ts"
click node_publisher_dispatch "https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/dispatch.ts"
click node_publisher_store "https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/repository.ts"

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_studio,node_upload,node_supporting toneBlue
class node_analysis_api,node_media,node_agent,node_agent_client,node_remix_api,node_variants_api,node_plan_schema,node_plan_compile toneAmber
class node_preview,node_composition,node_video_quality,node_export_api toneMint
class node_private_storage,node_cloud_storage,node_publishing toneRose
class node_jobs_api,node_job_worker,node_job_store,node_publisher_worker,node_publisher_dispatch,node_publisher_store,node_creator toneIndigo
```

## Components

### Creator experience

- [Editing studio](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/studio/Studio.tsx): `apps/web/src/components/app/studio/Studio.tsx`
- [Footage upload](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/home/SourceUpload.tsx): `apps/web/src/components/app/home/SourceUpload.tsx`
- [Supporting assets](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/SupportingAssets.tsx): `apps/web/src/components/app/SupportingAssets.tsx`

### Editing workflow

- [Media analysis API](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/analyze/route.ts): `apps/web/src/app/api/analyze/route.ts`
- [Media analysis pipeline](https://github.com/somewherelostt/unfold/tree/main/services/media/src): `services/media/src`
- [Editorial agent](https://github.com/somewherelostt/unfold/blob/main/packages/agent/src/agent.ts): `packages/agent/src/agent.ts`
- [Gateway client](https://github.com/somewherelostt/unfold/blob/main/packages/agent/src/client.ts): `packages/agent/src/client.ts`
- [Remix API](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/remix/route.ts): `apps/web/src/app/api/remix/route.ts`
- [Alternate takes API](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/variants/route.ts): `apps/web/src/app/api/variants/route.ts`
- [Edit plan schema](https://github.com/somewherelostt/unfold/blob/main/packages/core/src/schema.ts): `packages/core/src/schema.ts`
- [Plan compiler](https://github.com/somewherelostt/unfold/blob/main/packages/core/src/compile.ts): `packages/core/src/compile.ts`

### Preview and export

- [Browser preview](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/app/preview/PlanPlayer.tsx): `apps/web/src/components/app/preview/PlanPlayer.tsx`
- [Video composition](https://github.com/somewherelostt/unfold/blob/main/packages/video/src/Root.tsx): `packages/video/src/Root.tsx`
- [Render review](https://github.com/somewherelostt/unfold/blob/main/packages/video/src/review.ts): `packages/video/src/review.ts`
- [MP4 export API](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/export/route.ts): `apps/web/src/app/api/export/route.ts`

### App services

- [Private storage](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/server/private-storage.ts): `apps/web/src/server/private-storage.ts`
- [Cloud storage](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/server/supabase-storage.ts): `apps/web/src/server/supabase-storage.ts`
- [Publishing workspace](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/components/publishing/PublishingWorkspace.tsx): `apps/web/src/components/publishing/PublishingWorkspace.tsx`

### Background operations

- [Job API](https://github.com/somewherelostt/unfold/blob/main/apps/web/src/app/api/jobs/route.ts): `apps/web/src/app/api/jobs/route.ts`
- [Job worker](https://github.com/somewherelostt/unfold/blob/main/services/jobs/src/cloud-worker.ts): `services/jobs/src/cloud-worker.ts`
- [Job persistence](https://github.com/somewherelostt/unfold/blob/main/services/jobs/src/postgres-store.ts): `services/jobs/src/postgres-store.ts`
- [Publishing worker](https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/worker.ts): `services/publishing/src/worker.ts`
- [Publishing dispatch](https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/dispatch.ts): `services/publishing/src/dispatch.ts`
- [Publishing persistence](https://github.com/somewherelostt/unfold/blob/main/services/publishing/src/repository.ts): `services/publishing/src/repository.ts`

### Other components

- **Creator**

## Connections

- Creator → Footage upload: uploads footage
- Creator → Editing studio: reviews and edits
- Footage upload → Media analysis API: submits media
- Media analysis API → Media analysis pipeline: requests analysis
- Creator → Supporting assets: adds cutaways
- Media analysis API → Editorial agent: provides analysis
- Editorial agent → Gateway client: uses gateway
- Editorial agent → Edit plan schema: produces plan
- Editing studio → Remix API: requests revision
- Editing studio → Alternate takes API: requests alternates
- Editing studio → Browser preview: previews edit
- Edit plan schema → Plan compiler: validates plan (evidence: `packages/core/src/compile.ts`)
- Plan compiler → Video composition: feeds composition
- Video composition → Browser preview: renders preview
- Editing studio → MP4 export API: exports edit
- MP4 export API → Plan compiler: prepares export plan (evidence: `apps/web/src/app/api/export/route.ts`)
- MP4 export API → Video composition: renders MP4 (evidence: `apps/web/src/app/api/export/route.ts`)
- MP4 export API → Render review: reviews render (evidence: `apps/web/src/app/api/export/route.ts`)
- MP4 export API → Private storage: reads project data (evidence: `apps/web/src/app/api/export/route.ts`)
- Private storage → Cloud storage: cloud implementation (evidence: `apps/web/src/server/supabase-storage.ts`)
- Creator → Publishing workspace: opens publishing
- Job API → Job worker: queues work
- Job worker → Job persistence: claims and finishes (evidence: `services/jobs/src/cloud-worker.ts`)
- Publishing worker → Publishing persistence: claims work (evidence: `services/publishing/src/worker.ts`)
- Publishing worker → Publishing dispatch: dispatches task (evidence: `services/publishing/src/worker.ts`)
