caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

936 lines
67 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ReelForge Vision 2026 — `apps/web` Architecture (Additive)
> **Scope of this document.** This is an *additive* file+directory manifest for the Next.js
> **App Router** web client (`apps/web`). It designs the NEW web surfaces required to turn the
> current single-reel creation + jobs library + editor + publishing/analytics dashboard into a
> full **shot-by-shot Studio → storyboard → AI-movie timeline → genre-template gallery + one-click
> series → character-consistency manager → clipfarm control room (batch/schedule/calendar) →
> multi-platform publishing + cross-post scheduler → trends explorer → creator analytics +
> retention curves → template marketplace (browse/publish/monetize) → agency/white-label
> workspace → onboarding + growth loops → native-publish connection UI** product.
>
> It assumes everything already shipped exists and does **not** restate it: the `app/` route tree
> (`dashboard`, `new`, `editor`, `jobs`, `analytics`, `insights`, `calendar`, `scheduled`,
> `connections`, `marketplace`, `creators`, `wallet`, `billing`, `developer`, `settings/*`,
> `admin/*`, `voices`, `avatars`, `presets`, `broll`, `batch`, `team`, `referral`, `usage`,
> `(marketing)`…), the `src/features/{reel-create,jobs-library,editor,broll-studio}` modules,
> the newer `src/shared/{api/client.ts,media}` transport, and the legacy `components/<domain>/` +
> `lib/api.ts` + `lib/types.ts` + `lib/use-*.ts` surfaces.
>
> **The one-backend rule holds.** Web is a thin client of the same `/api/v1` contract mobile and
> desktop consume. It owns *no* job, credit, provider, routing, watermark, template, or media
> business rules — it renders state, captures input, and orchestrates polling. Every new server
> subsystem referenced here (`templates/`, `captions/`, `film/`, `publishing/`, `gateway/`,
> `marketplace/`) lives in `apps/api/reelforge/*` and is consumed over HTTP. See
> [apps-api.md](./apps-api.md) for the backend manifest and [packages.md](./packages.md) for the
> shared `api-contract` types this client imports.
---
## 1. Overview & Design Principles
### 1.1 What we are adding (surface map)
| Surface | Web module | One-line responsibility |
| --- | --- | --- |
| Shot-by-shot **Studio** | `src/features/studio/` | Per-shot canvas: script→shotlist→first-frame→motion, per-shot regenerate + burn preview |
| **Storyboard** editor | `src/features/storyboard/` | Grid/board of first-frame stills with reorder, beat labels, animatic preview |
| AI-movie **timeline** | `src/features/film-timeline/` | Multi-track NLE for stitched shots + voice + score + SFX, OTIO/FCPXML export |
| Genre **template gallery** | `src/features/template-gallery/` | Browse 7 seeded genres, preview segment slots, one-click apply |
| **One-click series** | `src/features/series/` | Episodic recurring-character series manager + genre-tuned cadence |
| **Character** consistency | `src/features/characters/` | Character/Style lock entities: refs, LoRA training, cross-model identity |
| **Clipfarm** dashboard | `src/features/clipfarm/` | Batch/schedule/calendar control room, automation runs, cadence guardrails |
| Multi-platform **publishing** | `src/features/publishing/` | Per-platform composer, watermark-safe export, cross-post scheduler |
| Native-publish **connections** | `src/features/connections/` (extends legacy) | OAuth connect wizard per platform, health, token status |
| **Trends** explorer | `src/features/trends/` | Trending audio/hashtag feed + saturation score + create-from-trend |
| Creator **analytics** | `src/features/creator-analytics/` | Retention curves, hook-score, A/B experiments, best-time optimizer |
| Template **marketplace** | `src/features/marketplace-studio/` (extends legacy) | Browse/publish/monetize shot-templates + ComfyUI presets |
| **Agency** / white-label | `src/features/agency/` | Workspace roster, per-client caps, margin dashboard, branding, provisioning keys |
| **Onboarding** + growth | `src/features/onboarding/` | Empty-screen killer, sample-reel remix, Sora-migration, growth loops |
| Free **micro-tools** | `src/features/micro-tools/` | Standalone captioner / hook-score / thumbnail top-of-funnel tools |
### 1.2 Conventions we follow (matching the existing codebase)
- **Route files are thin.** `app/<route>/page.tsx` only sets `metadata`, reads params, renders a
feature `*Page`/`*Workspace` component and the shared app chrome (header + `UserButton`).
All logic lives in `src/features/<domain>/`.
- **Feature module shape:** `src/features/<domain>/<Name>Page.tsx` (or `Workspace`/`Board`) +
`index.ts` barrel + `components/` (200–400 line focused files) + colocated `use-*.ts` hooks +
`model.ts` / `*-model.ts` pure state + local `*.ts` helpers. Mirrors `editor/` and
`reel-create/`.
- **Transport** goes through the newer `src/shared/api/client.ts` (`apiRequest`, `ApiError`,
envelope unwrap, `Idempotency-Key`, `x-api-key`, `POLL_INTERVAL_MS`). New typed resource
clients wrap it under `src/shared/api/resources/`. The legacy monolithic `lib/api.ts` is *not*
extended for new domains — new domains get focused resource modules (keeps files <800 lines).
- **Types** come from the shared `@reelforge/api-contract` package where a contract exists; local
view-model types live beside the feature in `model.ts`. We stop growing `lib/types.ts`.
- **Auth token** via `useAuth().getToken()` (Clerk) passed as `{ token }` to `apiRequest`; the
public `NEXT_PUBLIC_APP_API_KEY` remains the fallback.
- **Data fetching / mutations** use TanStack Query hooks (already a dep) wrapping resource
clients; polling reuses `POLL_INTERVAL_MS` and stops on terminal `completed`/`failed` state.
- **UI primitives** come from `@/components/ui/*` (shadcn: button, card, badge, input, select,
textarea, label, progress, skeleton). We add the missing primitives (tabs, dialog, tooltip,
dropdown-menu, slider, switch, table, sheet, toast, popover, command) under `components/ui/`.
- **Path alias** `@/*` → repo `apps/web/*`; feature imports use `@/src/features/...`, primitives
`@/components/ui/...`, shared transport `@/src/shared/api/...`.
- **Immutability, small focused files (<800 lines, 200–400 typical), explicit prop types,
`unknown`-narrowed errors, Zod at boundaries** per repo rules.
- **No secrets in the client.** Signed media URLs are never persisted; provider/BYOK keys never
touch the browser; OAuth uses server-initiated redirect + PKCE.
### 1.3 New shared dependencies (added to `package.json`)
| Package | Purpose |
| --- | --- |
| `@tanstack/react-query` | Server-state cache for all new resource hooks (if not already present) |
| `@dnd-kit/core` + `@dnd-kit/sortable` | Drag-reorder for storyboard board + timeline clips + shot list |
| `zod` | Boundary validation of API envelopes + form schemas |
| `react-hook-form` + `@hookform/resolvers` | Studio/publishing/agency forms |
| `recharts` (already used in analytics) | Retention curves + A/B + margin charts |
| `wavesurfer.js` | Waveform + beat markers in timeline audio tracks |
| `@radix-ui/react-*` (tabs, dialog, tooltip, dropdown, slider, switch, popover) | UI primitives |
| `cmdk` | Command palette (Studio quick-actions, template search) |
| `sonner` | Toast notifications for async job/publish events |
| `date-fns-tz` | Timezone-correct scheduler + calendar (matches server cron) |
| `use-debounce` | Debounced prompt fields + trend search |
| `nuqs` | URL-synced filter/tab state for gallery/marketplace/trends |
---
## 2. New App Router surface (directory tree)
```
apps/web/
├── app/
│ ├── studio/ # shot-by-shot Studio (project workspace)
│ │ ├── page.tsx # projects list (create/continue)
│ │ ├── new/page.tsx # new-project intake (idea/script/genre)
│ │ └── [projectId]/
│ │ ├── page.tsx # Studio workspace shell (tab router)
│ │ ├── script/page.tsx # script + beat-sheet stage
│ │ ├── shots/page.tsx # shot-list stage
│ │ ├── shots/[shotId]/page.tsx # single-shot deep view (regenerate)
│ │ ├── storyboard/page.tsx # storyboard board stage
│ │ ├── timeline/page.tsx # AI-movie timeline stage
│ │ ├── voice/page.tsx # per-character voice stage
│ │ ├── score/page.tsx # score + SFX stage
│ │ └── export/page.tsx # finish + per-aspect + OTIO/FCPXML
│ ├── characters/ # character-consistency manager
│ │ ├── page.tsx # character library
│ │ ├── new/page.tsx # create from references
│ │ └── [characterId]/
│ │ ├── page.tsx # character detail (sheet + identity)
│ │ └── train/page.tsx # LoRA training run monitor
│ ├── templates/ # genre template gallery
│ │ ├── page.tsx # gallery grid + filters
│ │ └── [templateId]/page.tsx # template preview + apply
│ ├── series/ # one-click episodic series
│ │ ├── page.tsx # series list
│ │ ├── new/page.tsx # new series wizard
│ │ └── [seriesId]/
│ │ ├── page.tsx # series dashboard (episodes + cadence)
│ │ └── episodes/[episodeId]/page.tsx
│ ├── clipfarm/ # clipfarm control room
│ │ ├── page.tsx # overview (queue + runs + guardrails)
│ │ ├── batches/page.tsx # batch runs list
│ │ ├── batches/new/page.tsx # 1-body/N-hooks + bulk generate
│ │ ├── batches/[batchId]/page.tsx # batch detail
│ │ ├── automations/page.tsx # scheduled automations
│ │ ├── automations/[automationId]/page.tsx
│ │ └── calendar/page.tsx # content calendar (extends legacy calendar)
│ ├── publishing/ # multi-platform publishing hub
│ │ ├── page.tsx # publishing hub (accounts + queue)
│ │ ├── compose/page.tsx # cross-post composer
│ │ ├── compose/[jobId]/page.tsx # compose from a finished render
│ │ ├── queue/page.tsx # scheduled queue (extends /scheduled)
│ │ └── history/page.tsx # publish history + watermark audit
│ ├── connections/ # native-publish connections (extends legacy)
│ │ ├── page.tsx # connected accounts grid
│ │ └── [platform]/page.tsx # per-platform connect/health detail
│ ├── trends/ # trends explorer
│ │ ├── page.tsx # trend feed (audio/hashtag/format)
│ │ ├── audio/page.tsx # trending sounds
│ │ ├── hashtags/page.tsx # trending hashtags
│ │ └── [trendId]/page.tsx # trend detail + create-from-trend
│ ├── analytics/ # creator analytics (extends legacy /analytics)
│ │ ├── retention/page.tsx # retention-curve explorer
│ │ ├── experiments/page.tsx # A/B experiments list
│ │ ├── experiments/[experimentId]/page.tsx
│ │ └── hooks/page.tsx # hook-score leaderboard
│ ├── marketplace/ # template marketplace (extends legacy /marketplace)
│ │ ├── publish/page.tsx # publish a template/preset
│ │ ├── mine/page.tsx # my listings + earnings
│ │ └── [listingId]/page.tsx # listing detail (extends legacy)
│ ├── agency/ # agency / white-label workspace
│ │ ├── page.tsx # agency overview
│ │ ├── clients/page.tsx # client roster + caps
│ │ ├── clients/[clientId]/page.tsx # per-client workspace
│ │ ├── margin/page.tsx # margin dashboard (wholesale vs retail)
│ │ ├── keys/page.tsx # provisioning/management keys
│ │ └── branding/page.tsx # white-label branding + custom domain
│ ├── onboarding/ # empty-screen killer + growth loops
│ │ ├── page.tsx # first-run wizard
│ │ ├── remix/[sampleId]/page.tsx # one-tap sample remix
│ │ └── migrate/page.tsx # Sora-shutdown migration flow
│ ├── tools/ # standalone free micro-tools (top-of-funnel)
│ │ ├── caption/page.tsx # AI captioner
│ │ ├── hook-score/page.tsx # hook-strength analyzer
│ │ └── thumbnail/page.tsx # thumbnail generator
│ └── affiliate/ # lifetime-recurring affiliate (extends /referral)
│ └── page.tsx # affiliate dashboard + deep links + payouts
│
├── src/features/ # NEW feature modules (see §3)
│ ├── studio/
│ ├── storyboard/
│ ├── film-timeline/
│ ├── template-gallery/
│ ├── series/
│ ├── characters/
│ ├── clipfarm/
│ ├── publishing/
│ ├── connections/
│ ├── trends/
│ ├── creator-analytics/
│ ├── marketplace-studio/
│ ├── agency/
│ ├── onboarding/
│ └── micro-tools/
│
├── src/shared/ # EXTENDED shared layer (see §5)
│ ├── api/
│ │ ├── client.ts # (exists)
│ │ └── resources/ # NEW typed resource clients
│ ├── ui/ # NEW cross-feature design-system pieces
│ ├── state/ # NEW query-client + global stores
│ ├── format/ # NEW formatting utilities
│ ├── polling/ # NEW job-polling hooks
│ └── media/ # (exists) EXTENDED
│
└── components/ui/ # EXTENDED shadcn primitives (see §4.0)
```
---
## 3. Routes (`app/*/page.tsx`) — thin route files
> Every file below is a thin App Router page: sets `metadata`, reads `params`/`searchParams`,
> renders the app chrome + a feature component. No business logic. Server components where the
> route is static shell; `"use client"` delegated to the feature component.
### 3.1 Studio routes
| Path | Responsibility |
| --- | --- |
| `app/studio/page.tsx` | Studio project list; renders `<StudioProjectsPage/>` |
| `app/studio/new/page.tsx` | New-project intake (idea/script/genre); renders `<StudioIntake/>` |
| `app/studio/[projectId]/page.tsx` | Studio workspace shell + stage tab router; renders `<StudioWorkspace/>` |
| `app/studio/[projectId]/script/page.tsx` | Script + beat-sheet stage; renders `<ScriptStage/>` |
| `app/studio/[projectId]/shots/page.tsx` | Shot-list stage; renders `<ShotListStage/>` |
| `app/studio/[projectId]/shots/[shotId]/page.tsx` | Single-shot deep view; renders `<ShotDetail/>` |
| `app/studio/[projectId]/storyboard/page.tsx` | Storyboard board; renders `<StoryboardBoard/>` |
| `app/studio/[projectId]/timeline/page.tsx` | AI-movie timeline; renders `<FilmTimeline/>` |
| `app/studio/[projectId]/voice/page.tsx` | Per-character voice stage; renders `<VoiceStage/>` |
| `app/studio/[projectId]/score/page.tsx` | Score + SFX stage; renders `<ScoreStage/>` |
| `app/studio/[projectId]/export/page.tsx` | Finish + per-aspect + interop export; renders `<ExportStage/>` |
### 3.2 Characters routes
| Path | Responsibility |
| --- | --- |
| `app/characters/page.tsx` | Character library grid; renders `<CharacterLibrary/>` |
| `app/characters/new/page.tsx` | Create-from-references wizard; renders `<CharacterCreate/>` |
| `app/characters/[characterId]/page.tsx` | Character detail (sheet + identity); renders `<CharacterDetail/>` |
| `app/characters/[characterId]/train/page.tsx` | LoRA training run monitor; renders `<CharacterTraining/>` |
### 3.3 Templates + Series routes
| Path | Responsibility |
| --- | --- |
| `app/templates/page.tsx` | Genre template gallery grid + filters; renders `<TemplateGalleryPage/>` |
| `app/templates/[templateId]/page.tsx` | Template preview + segment slots + apply; renders `<TemplateDetail/>` |
| `app/series/page.tsx` | Series list; renders `<SeriesListPage/>` |
| `app/series/new/page.tsx` | New-series wizard (one-click series); renders `<SeriesWizard/>` |
| `app/series/[seriesId]/page.tsx` | Series dashboard (episodes + cadence); renders `<SeriesDashboard/>` |
| `app/series/[seriesId]/episodes/[episodeId]/page.tsx` | Episode detail; renders `<EpisodeDetail/>` |
### 3.4 Clipfarm routes
| Path | Responsibility |
| --- | --- |
| `app/clipfarm/page.tsx` | Control-room overview; renders `<ClipfarmOverview/>` |
| `app/clipfarm/batches/page.tsx` | Batch runs list; renders `<BatchList/>` |
| `app/clipfarm/batches/new/page.tsx` | 1-body/N-hooks + bulk generate; renders `<BatchCreate/>` |
| `app/clipfarm/batches/[batchId]/page.tsx` | Batch detail + per-item status; renders `<BatchDetail/>` |
| `app/clipfarm/automations/page.tsx` | Scheduled automations list; renders `<AutomationList/>` |
| `app/clipfarm/automations/[automationId]/page.tsx` | Automation config + run history; renders `<AutomationDetail/>` |
| `app/clipfarm/calendar/page.tsx` | Content calendar; renders `<ContentCalendar/>` |
### 3.5 Publishing + Connections routes
| Path | Responsibility |
| --- | --- |
| `app/publishing/page.tsx` | Publishing hub (accounts + queue snapshot); renders `<PublishingHub/>` |
| `app/publishing/compose/page.tsx` | Cross-post composer (pick a render); renders `<ComposerPage/>` |
| `app/publishing/compose/[jobId]/page.tsx` | Compose from a finished render; renders `<ComposerPage/>` |
| `app/publishing/queue/page.tsx` | Scheduled publish queue; renders `<PublishQueue/>` |
| `app/publishing/history/page.tsx` | Publish history + watermark audit; renders `<PublishHistory/>` |
| `app/connections/page.tsx` | Connected-accounts grid; renders `<ConnectionsGrid/>` (extends legacy) |
| `app/connections/[platform]/page.tsx` | Per-platform connect/health detail; renders `<PlatformConnectDetail/>` |
### 3.6 Trends + Analytics routes
| Path | Responsibility |
| --- | --- |
| `app/trends/page.tsx` | Unified trend feed; renders `<TrendsExplorer/>` |
| `app/trends/audio/page.tsx` | Trending sounds; renders `<TrendAudioList/>` |
| `app/trends/hashtags/page.tsx` | Trending hashtags; renders `<TrendHashtagList/>` |
| `app/trends/[trendId]/page.tsx` | Trend detail + create-from-trend; renders `<TrendDetail/>` |
| `app/analytics/retention/page.tsx` | Retention-curve explorer; renders `<RetentionExplorer/>` |
| `app/analytics/experiments/page.tsx` | A/B experiments list; renders `<ExperimentsList/>` |
| `app/analytics/experiments/[experimentId]/page.tsx` | Experiment detail + winner; renders `<ExperimentDetail/>` |
| `app/analytics/hooks/page.tsx` | Hook-score leaderboard; renders `<HookScoreBoard/>` |
### 3.7 Marketplace + Agency routes
| Path | Responsibility |
| --- | --- |
| `app/marketplace/publish/page.tsx` | Publish a template/preset; renders `<ListingPublish/>` |
| `app/marketplace/mine/page.tsx` | My listings + earnings; renders `<MyListings/>` |
| `app/marketplace/[listingId]/page.tsx` | Listing detail (extends legacy); renders `<ListingDetail/>` |
| `app/agency/page.tsx` | Agency overview; renders `<AgencyOverview/>` |
| `app/agency/clients/page.tsx` | Client roster + caps; renders `<ClientRoster/>` |
| `app/agency/clients/[clientId]/page.tsx` | Per-client workspace; renders `<ClientWorkspace/>` |
| `app/agency/margin/page.tsx` | Margin dashboard; renders `<MarginDashboard/>` |
| `app/agency/keys/page.tsx` | Provisioning/management keys; renders `<ProvisioningKeys/>` |
| `app/agency/branding/page.tsx` | White-label branding + custom domain; renders `<BrandingSettings/>` |
### 3.8 Onboarding + Tools + Affiliate routes
| Path | Responsibility |
| --- | --- |
| `app/onboarding/page.tsx` | First-run empty-screen-killer wizard; renders `<OnboardingWizard/>` |
| `app/onboarding/remix/[sampleId]/page.tsx` | One-tap sample-reel remix; renders `<SampleRemix/>` |
| `app/onboarding/migrate/page.tsx` | Sora-shutdown migration flow; renders `<SoraMigration/>` |
| `app/tools/caption/page.tsx` | Standalone AI captioner; renders `<CaptionTool/>` |
| `app/tools/hook-score/page.tsx` | Standalone hook-score analyzer; renders `<HookScoreTool/>` |
| `app/tools/thumbnail/page.tsx` | Standalone thumbnail generator; renders `<ThumbnailTool/>` |
| `app/affiliate/page.tsx` | Affiliate dashboard + deep links + payouts; renders `<AffiliateDashboard/>` |
---
## 4. Feature modules (`src/features/*`) & shared UI
> Each module follows the established shape: a top-level entry component + `index.ts` barrel +
> `components/` + colocated `use-*.ts` hooks + `model.ts`. Every module consumes a resource client
> from `src/shared/api/resources/` (§5.1) and never talks to `fetch` directly.
### 4.0 `components/ui/` — added shadcn primitives
| Path | Responsibility |
| --- | --- |
| `components/ui/tabs.tsx` | Radix tabs (Studio stage tabs, analytics tabs) |
| `components/ui/dialog.tsx` | Radix modal dialog (apply-template, regenerate, confirm) |
| `components/ui/sheet.tsx` | Slide-over panel (shot inspector, connection detail) |
| `components/ui/tooltip.tsx` | Hover tooltips (burn preview, watermark note) |
| `components/ui/dropdown-menu.tsx` | Row/action menus (batch item, listing, client) |
| `components/ui/popover.tsx` | Anchored popovers (color pick, date pick) |
| `components/ui/slider.tsx` | Range sliders (emotion dial, duration, cost-cap) |
| `components/ui/switch.tsx` | Toggles (watermark, BYOK-in-limit, auto-cadence) |
| `components/ui/table.tsx` | Data tables (clients, keys, deliveries, listings) |
| `components/ui/toast.tsx` + `toaster.tsx` | `sonner`-backed async event toasts |
| `components/ui/command.tsx` | `cmdk` palette (Studio quick-actions, template search) |
| `components/ui/tag-input.tsx` | Multi-tag input (hashtags, keywords, genre tags) |
| `components/ui/color-swatch.tsx` | Caption highlight color swatch (`#FFD93D`) |
| `components/ui/empty-state.tsx` | Reusable empty-state (icon + copy + CTA) |
| `components/ui/stat-tile.tsx` | KPI tile (reused across analytics/agency/wallet) |
| `components/ui/segmented-control.tsx` | Aspect-ratio / mode segmented picker |
| `components/ui/copy-button.tsx` | Copy-to-clipboard button (keys, deep links) |
| `components/ui/avatar.tsx` | Avatar primitive (characters, creators, clients) |
### 4.1 `src/features/studio/` — shot-by-shot Studio (crown jewel)
| Path | Responsibility |
| --- | --- |
| `src/features/studio/index.ts` | Barrel export for Studio entry components |
| `src/features/studio/StudioProjectsPage.tsx` | Project list (create/continue/duplicate) |
| `src/features/studio/StudioIntake.tsx` | New-project intake: idea/script paste/genre select |
| `src/features/studio/StudioWorkspace.tsx` | Stage-tab shell orchestrating the 8 pipeline stages |
| `src/features/studio/model.ts` | Studio project view-model + stage enum + shot types |
| `src/features/studio/pipeline-stages.ts` | Ordered stage definitions + gating rules |
| `src/features/studio/use-studio-project.ts` | Load/poll a project (script→shots→render state) |
| `src/features/studio/use-studio-projects.ts` | List/create/duplicate projects |
| `src/features/studio/use-burn-preview.ts` | Per-shot + whole-project burn preview (credits/$) |
| `src/features/studio/use-regenerate-shot.ts` | Regenerate a single shot's frame or motion |
| `src/features/studio/components/StudioHeader.tsx` | Project title + stage breadcrumb + burn badge |
| `src/features/studio/components/StageTabBar.tsx` | Tab navigation across script→export stages |
| `src/features/studio/components/StageGate.tsx` | Blocks a stage until prerequisites satisfied |
| `src/features/studio/components/BurnPreviewBadge.tsx` | "~X credits / ~$Y, Z keepers left" preview |
| `src/features/studio/components/ModelRoutePicker.tsx` | Per-shot model route (order/cost-cap/:nitro) |
| `src/features/studio/components/StudioCommandPalette.tsx` | `cmdk` quick-actions (jump stage, regenerate) |
| `src/features/studio/components/ProjectCard.tsx` | Project card in list (poster + progress) |
| `src/features/studio/components/EmptyStudioState.tsx` | Empty-state → start from template/sample |
| `src/features/studio/script/ScriptStage.tsx` | Script editor + beat-sheet generator |
| `src/features/studio/script/BeatSheetEditor.tsx` | Editable beat list (add/reorder/label) |
| `src/features/studio/script/ScriptImportPanel.tsx` | Paste / URL ingest / upload screenplay |
| `src/features/studio/script/use-script.ts` | Script + beat-sheet load/save/generate |
| `src/features/studio/script/use-beat-sheet.ts` | Beat-sheet generation + edit state |
| `src/features/studio/shots/ShotListStage.tsx` | Auto shot-list grid (scenes → shots) |
| `src/features/studio/shots/ShotRow.tsx` | One shot: camera/framing/action/dialogue |
| `src/features/studio/shots/ShotDetail.tsx` | Deep single-shot view (frame + motion + regen) |
| `src/features/studio/shots/ShotFramePreview.tsx` | First-frame still preview + regenerate |
| `src/features/studio/shots/ShotMotionPreview.tsx` | I2V motion clip preview + regenerate-motion |
| `src/features/studio/shots/ShotPromptEditor.tsx` | Per-shot prompt + locked-ref injection view |
| `src/features/studio/shots/ShotCharacterBinder.tsx` | Bind character/style locks to a shot |
| `src/features/studio/shots/ShotStatusChip.tsx` | Per-shot generation status (queued→done) |
| `src/features/studio/shots/use-shot-list.ts` | Shot-list generation + reorder + edit |
| `src/features/studio/shots/use-shot.ts` | Single-shot load/poll/regenerate |
| `src/features/studio/voice/VoiceStage.tsx` | Per-character voice assignment + generation |
| `src/features/studio/voice/CharacterVoiceRow.tsx` | Character → voice model + emotion tags |
| `src/features/studio/voice/use-voice-stage.ts` | Voice generation + per-shot dialogue timing |
| `src/features/studio/score/ScoreStage.tsx` | Score + SFX generation + auto-duck controls |
| `src/features/studio/score/ScoreTrackRow.tsx` | Music/SFX track selection + duck curve |
| `src/features/studio/score/use-score-stage.ts` | Score/SFX generation + duck config |
| `src/features/studio/export/ExportStage.tsx` | Finish: per-aspect masters + interop export |
| `src/features/studio/export/AspectExportGrid.tsx` | 9:16 / 1:1 / 16:9 export toggles |
| `src/features/studio/export/InteropExportPanel.tsx` | OTIO / FCPXML / DaVinci Resolve handoff |
| `src/features/studio/export/use-export.ts` | Export job trigger + poll + download links |
### 4.2 `src/features/storyboard/` — storyboard board editor
| Path | Responsibility |
| --- | --- |
| `src/features/storyboard/index.ts` | Barrel export |
| `src/features/storyboard/StoryboardBoard.tsx` | Board of first-frame stills (dnd-kit reorder) |
| `src/features/storyboard/model.ts` | Board card view-model + beat-label types |
| `src/features/storyboard/use-storyboard.ts` | Load/reorder/regenerate storyboard frames |
| `src/features/storyboard/use-animatic.ts` | Frames-to-Video animatic preview trigger + poll |
| `src/features/storyboard/components/FrameCard.tsx` | Single frame card (still + beat label + regen) |
| `src/features/storyboard/components/FrameGrid.tsx` | Responsive sortable grid of frame cards |
| `src/features/storyboard/components/BeatLabelChip.tsx` | Editable beat-slot label (Hook/Proof/Payoff/Loop) |
| `src/features/storyboard/components/AnimaticPlayer.tsx` | Animatic playback for pacing review |
| `src/features/storyboard/components/RegenerateFrameDialog.tsx` | Prompt-tweak + regenerate a single frame |
| `src/features/storyboard/components/AddFramePanel.tsx` | Insert frame between beats |
| `src/features/storyboard/components/StoryboardToolbar.tsx` | Approve→commit, animatic, aspect toggle |
### 4.3 `src/features/film-timeline/` — AI-movie timeline (multi-track NLE)
| Path | Responsibility |
| --- | --- |
| `src/features/film-timeline/index.ts` | Barrel export |
| `src/features/film-timeline/FilmTimeline.tsx` | Multi-track timeline workspace shell |
| `src/features/film-timeline/timeline-model.ts` | Track/clip/keyframe pure view-model (immutable ops) |
| `src/features/film-timeline/time-scale.ts` | Pixels↔seconds mapping + zoom math |
| `src/features/film-timeline/beat-snap.ts` | Beat-detection snap + -2/-3 frame nudge helper |
| `src/features/film-timeline/use-timeline.ts` | Load stitched shots into tracks + edit ops |
| `src/features/film-timeline/use-timeline-playback.ts` | Playhead + preview player sync |
| `src/features/film-timeline/use-timeline-export.ts` | Commit timeline → render/export job |
| `src/features/film-timeline/components/TrackList.tsx` | Left rail of track headers (video/voice/score/sfx) |
| `src/features/film-timeline/components/TrackLane.tsx` | One track lane holding clips |
| `src/features/film-timeline/components/ClipBlock.tsx` | Draggable/trimmable clip block |
| `src/features/film-timeline/components/Playhead.tsx` | Scrubber + current-time indicator |
| `src/features/film-timeline/components/TimeRuler.tsx` | Time ruler with beat markers |
| `src/features/film-timeline/components/WaveformLane.tsx` | `wavesurfer` waveform for audio tracks |
| `src/features/film-timeline/components/DuckCurveOverlay.tsx` | Auto-duck curve overlay on music track |
| `src/features/film-timeline/components/PreviewPlayer.tsx` | Live composite preview (Revideo/Remotion player) |
| `src/features/film-timeline/components/TimelineToolbar.tsx` | Zoom, snap-to-beat, split, export controls |
| `src/features/film-timeline/components/ClipInspector.tsx` | Selected-clip properties (trim, transition, regen) |
| `src/features/film-timeline/components/TransitionPicker.tsx` | Transition between clips (cut/zoom-in) |
### 4.4 `src/features/template-gallery/` — genre template gallery
| Path | Responsibility |
| --- | --- |
| `src/features/template-gallery/index.ts` | Barrel export |
| `src/features/template-gallery/TemplateGalleryPage.tsx` | Genre grid + filters + search |
| `src/features/template-gallery/TemplateDetail.tsx` | Template preview + segment slots + apply CTA |
| `src/features/template-gallery/model.ts` | Template + segment-slot view-model |
| `src/features/template-gallery/genres.ts` | 7 seeded genre metadata (icon/blurb/aspect/duration) |
| `src/features/template-gallery/use-templates.ts` | List/filter templates (genre/aspect/duration) |
| `src/features/template-gallery/use-template.ts` | Load single template + apply-to-new-reel |
| `src/features/template-gallery/use-apply-template.ts` | Apply template → prefill `/new` or Studio |
| `src/features/template-gallery/components/TemplateCard.tsx` | Card (poster loop + genre tag + duration) |
| `src/features/template-gallery/components/GenreFilterBar.tsx` | Genre + aspect + duration filter chips |
| `src/features/template-gallery/components/SegmentSlotList.tsx` | Named slots (Hook/Proof/Payoff/Loop) w/ timing |
| `src/features/template-gallery/components/SegmentSlotCard.tsx` | One slot: duration, audio layer, caption preset |
| `src/features/template-gallery/components/CaptionPresetPreview.tsx` | Hormozi karaoke style preview swatch |
| `src/features/template-gallery/components/TemplatePreviewPlayer.tsx` | Looping sample preview |
| `src/features/template-gallery/components/ApplyTemplateDialog.tsx` | Choose target (new reel / series / Studio) |
| `src/features/template-gallery/components/GalleryEmptyState.tsx` | Empty/loading skeleton grid |
### 4.5 `src/features/series/` — one-click episodic series
| Path | Responsibility |
| --- | --- |
| `src/features/series/index.ts` | Barrel export |
| `src/features/series/SeriesListPage.tsx` | List of series (channel-mode cards) |
| `src/features/series/SeriesWizard.tsx` | New-series wizard: genre + character + cadence |
| `src/features/series/SeriesDashboard.tsx` | Episodes list + cadence + recurring identity |
| `src/features/series/EpisodeDetail.tsx` | Single episode (variation on fixed lock) |
| `src/features/series/model.ts` | Series + episode + cadence view-model |
| `src/features/series/cadence.ts` | Genre-tuned daily/weekly cadence presets |
| `src/features/series/use-series-list.ts` | List/create/archive series |
| `src/features/series/use-series.ts` | Load one series + episodes + cadence |
| `src/features/series/use-episode.ts` | Load/generate a single episode |
| `src/features/series/use-generate-episode.ts` | One-click "generate next episode" |
| `src/features/series/components/SeriesCard.tsx` | Series card (recurring char + next-post) |
| `src/features/series/components/EpisodeRow.tsx` | Episode row (number + status + schedule) |
| `src/features/series/components/RecurringCharacterBanner.tsx` | Locked voice+avatar identity summary |
| `src/features/series/components/CadencePlanner.tsx` | Per-platform cadence editor (warmed vs new) |
| `src/features/series/components/SingleFormatToggle.tsx` | Single-format channel-mode switch |
| `src/features/series/components/NextEpisodeButton.tsx` | Generate-next-episode CTA + burn preview |
| `src/features/series/components/SeriesEmptyState.tsx` | Empty → start from template |
### 4.6 `src/features/characters/` — character-consistency manager
| Path | Responsibility |
| --- | --- |
| `src/features/characters/index.ts` | Barrel export |
| `src/features/characters/CharacterLibrary.tsx` | Grid of Character/Style lock entities |
| `src/features/characters/CharacterCreate.tsx` | Create from reference images wizard |
| `src/features/characters/CharacterDetail.tsx` | Character sheet + identity + usage across projects |
| `src/features/characters/CharacterTraining.tsx` | Wan 2.2 LoRA training run monitor |
| `src/features/characters/model.ts` | Character/Style entity + identity view-model |
| `src/features/characters/identity.ts` | Cross-model identity injection descriptor helper |
| `src/features/characters/use-characters.ts` | List/create/delete characters |
| `src/features/characters/use-character.ts` | Load one character + reused-in projects |
| `src/features/characters/use-character-training.ts` | Start/poll LoRA training job |
| `src/features/characters/use-reference-upload.ts` | Upload + validate 50+ reference images |
| `src/features/characters/components/CharacterCard.tsx` | Card (portrait + identity source badge) |
| `src/features/characters/components/CharacterSheet.tsx` | Static+dynamic feature sheet view |
| `src/features/characters/components/ReferenceUploader.tsx` | Drag-drop reference set + count meter |
| `src/features/characters/components/ReferenceGrid.tsx` | Thumbnail grid of reference images |
| `src/features/characters/components/IdentitySourcePicker.tsx` | Refs-only / LoRA / cross-model identity |
| `src/features/characters/components/TrainingProgress.tsx` | LoRA training progress + logs |
| `src/features/characters/components/ConsistencyPreview.tsx` | Generate test frames to verify consistency |
| `src/features/characters/components/UsedInProjects.tsx` | Where this character/style is reused |
| `src/features/characters/components/ConsentGate.tsx` | Consent capture for likeness/AutoCameo |
### 4.7 `src/features/clipfarm/` — clipfarm control room
| Path | Responsibility |
| --- | --- |
| `src/features/clipfarm/index.ts` | Barrel export |
| `src/features/clipfarm/ClipfarmOverview.tsx` | Control-room dashboard (queue+runs+guardrails) |
| `src/features/clipfarm/BatchList.tsx` | Batch runs list |
| `src/features/clipfarm/BatchCreate.tsx` | 1-body/N-hooks + bulk generate wizard |
| `src/features/clipfarm/BatchDetail.tsx` | Batch detail + per-item status grid |
| `src/features/clipfarm/AutomationList.tsx` | Scheduled automations list |
| `src/features/clipfarm/AutomationDetail.tsx` | Automation config + run history |
| `src/features/clipfarm/ContentCalendar.tsx` | Month calendar of scheduled posts |
| `src/features/clipfarm/model.ts` | Batch/automation/run view-model |
| `src/features/clipfarm/guardrails.ts` | Self-cannibalization + daily-cap guardrail rules |
| `src/features/clipfarm/use-batches.ts` | List/create batches |
| `src/features/clipfarm/use-batch.ts` | Load/poll a batch + per-item status |
| `src/features/clipfarm/use-automations.ts` | List/create/toggle automations |
| `src/features/clipfarm/use-automation.ts` | Load one automation + run history |
| `src/features/clipfarm/use-clipfarm-calendar.ts` | Calendar entries + reschedule |
| `src/features/clipfarm/components/QueueSnapshot.tsx` | Live queue depth + throughput tiles |
| `src/features/clipfarm/components/RunTimeline.tsx` | Recent automation runs strip |
| `src/features/clipfarm/components/GuardrailBanner.tsx` | Cadence/cannibalization warnings |
| `src/features/clipfarm/components/BatchRow.tsx` | Batch row (template + N + progress) |
| `src/features/clipfarm/components/BatchItemGrid.tsx` | Per-variant status grid |
| `src/features/clipfarm/components/HookVariantEditor.tsx` | Edit N hook variants for 1 body |
| `src/features/clipfarm/components/BulkSourceInput.tsx` | Bulk source (URLs/CSV/trend picks) |
| `src/features/clipfarm/components/AutomationScheduleForm.tsx` | Cron/timezone + cadence config |
| `src/features/clipfarm/components/AutomationTargetPicker.tsx` | Channel/account + template binding |
| `src/features/clipfarm/components/PauseResumeControl.tsx` | Pause/resume a batch or automation |
| `src/features/clipfarm/components/CalendarMiniGrid.tsx` | Compact month grid (reuses `lib/calendar.ts`) |
| `src/features/clipfarm/components/CadenceGuardrailChip.tsx` | Per-account cadence status chip |
### 4.8 `src/features/publishing/` — multi-platform publishing + cross-post
| Path | Responsibility |
| --- | --- |
| `src/features/publishing/index.ts` | Barrel export |
| `src/features/publishing/PublishingHub.tsx` | Hub: connected accounts + queue snapshot |
| `src/features/publishing/ComposerPage.tsx` | Cross-post composer (per-platform tabs) |
| `src/features/publishing/PublishQueue.tsx` | Scheduled publish queue (extends `/scheduled`) |
| `src/features/publishing/PublishHistory.tsx` | Publish history + watermark audit log |
| `src/features/publishing/model.ts` | Publish target + variant + schedule view-model |
| `src/features/publishing/platforms.ts` | Per-platform limits (caps, aspect, watermark rules) |
| `src/features/publishing/use-publish-targets.ts` | Connected accounts as publish targets |
| `src/features/publishing/use-composer.ts` | Compose state (caption/hashtags per platform) |
| `src/features/publishing/use-cross-post.ts` | Submit cross-post + poll container status |
| `src/features/publishing/use-publish-history.ts` | History list + retry failed |
| `src/features/publishing/components/PlatformComposeTab.tsx` | Per-platform caption/hashtag/thumbnail editor |
| `src/features/publishing/components/CaptionSeoField.tsx` | Keyword-SEO caption + on-screen-text helper |
| `src/features/publishing/components/HashtagSuggest.tsx` | Trend-aware hashtag suggestions |
| `src/features/publishing/components/WatermarkSafeNotice.tsx` | Watermark-clean master confirmation |
| `src/features/publishing/components/TrendingAudioAttach.tsx` | Export-muted + relink native trending sound |
| `src/features/publishing/components/AspectVariantSelector.tsx` | Per-platform aspect master picker |
| `src/features/publishing/components/PublishTargetToggle.tsx` | Enable/disable a platform in this post |
| `src/features/publishing/components/StaggerScheduler.tsx` | ≥24h stagger + best-time suggestion |
| `src/features/publishing/components/ContainerPollStatus.tsx` | IG container+poll / TikTok audit status |
| `src/features/publishing/components/PublishPreview.tsx` | Per-platform mock preview card |
| `src/features/publishing/components/PublishHistoryRow.tsx` | History row (platform + status + link) |
| `src/features/publishing/components/WatermarkAuditBadge.tsx` | Foreign-watermark scan result badge |
| `src/features/publishing/components/PayPerUseNotice.tsx` | X pay-per-use cost confirmation |
### 4.9 `src/features/connections/` — native-publish connection UI
| Path | Responsibility |
| --- | --- |
| `src/features/connections/index.ts` | Barrel export |
| `src/features/connections/ConnectionsGrid.tsx` | Grid of platform connections + health |
| `src/features/connections/PlatformConnectDetail.tsx` | Per-platform connect/reauth/health detail |
| `src/features/connections/model.ts` | Connection + token-health view-model |
| `src/features/connections/platform-registry.ts` | Platform metadata (scopes, OAuth kind, caps) |
| `src/features/connections/use-connections.ts` | List connections + disconnect |
| `src/features/connections/use-connect-flow.ts` | Start OAuth redirect + handle callback |
| `src/features/connections/use-token-health.ts` | Token-expiry + re-auth status polling |
| `src/features/connections/components/ConnectionCard.tsx` | Account card (avatar + platform + health) |
| `src/features/connections/components/ConnectButton.tsx` | Start OAuth for a platform |
| `src/features/connections/components/ReauthBanner.tsx` | Expiring/expired token re-auth prompt |
| `src/features/connections/components/ScopeChecklist.tsx` | Requested-scope explanation list |
| `src/features/connections/components/AggregatorFallbackCard.tsx` | Ayrshare/Blotato managed-queue fallback |
| `src/features/connections/components/DailyCapMeter.tsx` | Per-platform daily-cap usage meter |
| `src/features/connections/components/ConnectionHealthPill.tsx` | Connected/expiring/error status pill |
### 4.10 `src/features/trends/` — trends explorer
| Path | Responsibility |
| --- | --- |
| `src/features/trends/index.ts` | Barrel export |
| `src/features/trends/TrendsExplorer.tsx` | Unified trend feed (audio/hashtag/format) |
| `src/features/trends/TrendAudioList.tsx` | Trending sounds list |
| `src/features/trends/TrendHashtagList.tsx` | Trending hashtags list |
| `src/features/trends/TrendDetail.tsx` | Trend detail + create-from-trend CTA |
| `src/features/trends/model.ts` | Trend + saturation-score view-model |
| `src/features/trends/saturation.ts` | Saturation/decay score → rising/peaked bucketing |
| `src/features/trends/use-trends.ts` | List/filter trends (platform/type/rising) |
| `src/features/trends/use-trend.ts` | Load one trend + related content |
| `src/features/trends/use-create-from-trend.ts` | Prefill Studio/`/new` from a trend |
| `src/features/trends/components/TrendCard.tsx` | Trend card (waveform/hashtag + saturation) |
| `src/features/trends/components/SaturationGauge.tsx` | Rising-vs-peaked saturation gauge |
| `src/features/trends/components/TrendFilterBar.tsx` | Platform/type/rising filters |
| `src/features/trends/components/AudioTrendRow.tsx` | Sound row (mini-player + usage count) |
| `src/features/trends/components/HashtagTrendRow.tsx` | Hashtag row (volume + co-occurrence) |
| `src/features/trends/components/CreateFromTrendButton.tsx` | Kick off trend-audio-remix template |
| `src/features/trends/components/AdSafeBadge.tsx` | Cross-platform-safe (Meta-compatible) audio badge |
| `src/features/trends/components/TrendSparkline.tsx` | 7-day trend-volume sparkline |
### 4.11 `src/features/creator-analytics/` — retention + hooks + A/B
| Path | Responsibility |
| --- | --- |
| `src/features/creator-analytics/index.ts` | Barrel export |
| `src/features/creator-analytics/RetentionExplorer.tsx` | Per-second retention-curve explorer |
| `src/features/creator-analytics/ExperimentsList.tsx` | A/B experiments list |
| `src/features/creator-analytics/ExperimentDetail.tsx` | Experiment detail + winner promotion |
| `src/features/creator-analytics/HookScoreBoard.tsx` | Hook-score leaderboard |
| `src/features/creator-analytics/model.ts` | Retention/experiment/hook view-model |
| `src/features/creator-analytics/retention-math.ts` | Drop-off + threshold (70/85%) computation |
| `src/features/creator-analytics/use-retention.ts` | Load per-second retention for a video |
| `src/features/creator-analytics/use-experiments.ts` | List/create experiments |
| `src/features/creator-analytics/use-experiment.ts` | Load one experiment + variant metrics |
| `src/features/creator-analytics/use-hook-scores.ts` | Hook-score list + pre-publish predictor |
| `src/features/creator-analytics/use-best-time.ts` | Best-time-to-post optimizer read |
| `src/features/creator-analytics/components/RetentionCurve.tsx` | Recharts per-second retention line |
| `src/features/creator-analytics/components/DropOffMarkers.tsx` | Annotate hook/loop drop-off points |
| `src/features/creator-analytics/components/ThresholdBands.tsx` | 70%/85% viral-gate reference bands |
| `src/features/creator-analytics/components/CompletionTile.tsx` | Completion / Viewed-vs-Swiped tile |
| `src/features/creator-analytics/components/HookScoreGauge.tsx` | First-3s hook-strength gauge |
| `src/features/creator-analytics/components/HookScoreRow.tsx` | Leaderboard row (video + score + reach) |
| `src/features/creator-analytics/components/ColdOpenSuggestions.tsx` | Suggested stronger cold-opens |
| `src/features/creator-analytics/components/ExperimentCard.tsx` | 1-body/N-hooks experiment card |
| `src/features/creator-analytics/components/VariantComparison.tsx` | Side-by-side variant retention compare |
| `src/features/creator-analytics/components/WinnerPromoteButton.tsx` | Feed winning hook back into generation |
| `src/features/creator-analytics/components/BestTimeHeatmap.tsx` | Best-time-to-post heatmap |
| `src/features/creator-analytics/components/TitleThumbTestPanel.tsx` | YouTube Test-and-Compare title/thumb A/B |
### 4.12 `src/features/marketplace-studio/` — template marketplace (extends legacy)
| Path | Responsibility |
| --- | --- |
| `src/features/marketplace-studio/index.ts` | Barrel export |
| `src/features/marketplace-studio/ListingPublish.tsx` | Publish a shot-template/ComfyUI preset |
| `src/features/marketplace-studio/MyListings.tsx` | My listings + earnings + payouts |
| `src/features/marketplace-studio/ListingDetail.tsx` | Listing detail (install/buy/rate) |
| `src/features/marketplace-studio/model.ts` | Listing + earnings + license view-model |
| `src/features/marketplace-studio/pricing.ts` | Price/markup + license-class helper |
| `src/features/marketplace-studio/use-my-listings.ts` | List/create/unpublish my listings |
| `src/features/marketplace-studio/use-listing-publish.ts` | Publish flow (template/preset → listing) |
| `src/features/marketplace-studio/use-listing-earnings.ts` | Earnings + payout status |
| `src/features/marketplace-studio/use-install-listing.ts` | Install/buy a listing into workspace |
| `src/features/marketplace-studio/components/PublishTypePicker.tsx` | Shot-template vs ComfyUI-graph vs preset |
| `src/features/marketplace-studio/components/ListingForm.tsx` | Title/desc/price/license form |
| `src/features/marketplace-studio/components/LicenseClassPicker.tsx` | Commercial-safe / non-commercial select |
| `src/features/marketplace-studio/components/PriceMarkupField.tsx` | Set price + preview creator take |
| `src/features/marketplace-studio/components/PreviewUploader.tsx` | Upload sample-output preview clip |
| `src/features/marketplace-studio/components/EarningsPanel.tsx` | Earnings summary + payout button |
| `src/features/marketplace-studio/components/PayoutHistory.tsx` | Payout history table |
| `src/features/marketplace-studio/components/LineageBadge.tsx` | Fork/remix lineage (extends legacy) |
| `src/features/marketplace-studio/components/InstallButton.tsx` | Install/buy CTA + burn confirm |
### 4.13 `src/features/agency/` — agency / white-label workspace
| Path | Responsibility |
| --- | --- |
| `src/features/agency/index.ts` | Barrel export |
| `src/features/agency/AgencyOverview.tsx` | Agency dashboard (clients + spend + margin tiles) |
| `src/features/agency/ClientRoster.tsx` | Client roster + per-client spend caps |
| `src/features/agency/ClientWorkspace.tsx` | Per-client workspace (usage + members + keys) |
| `src/features/agency/MarginDashboard.tsx` | Wholesale-cost vs retail-set margin dashboard |
| `src/features/agency/ProvisioningKeys.tsx` | Provisioning/management keys manager |
| `src/features/agency/BrandingSettings.tsx` | White-label branding + custom domain |
| `src/features/agency/model.ts` | Client + key + margin + branding view-model |
| `src/features/agency/margin-math.ts` | Markup-policy → margin computation helper |
| `src/features/agency/use-clients.ts` | List/invite/suspend clients |
| `src/features/agency/use-client.ts` | Load one client + usage + caps |
| `src/features/agency/use-provisioning-keys.ts` | List/create/rotate spend-capped sub-keys |
| `src/features/agency/use-margin.ts` | Margin dashboard read (wholesale vs retail) |
| `src/features/agency/use-branding.ts` | Branding + custom-domain config CRUD |
| `src/features/agency/components/ClientRow.tsx` | Client row (spend + cap + reset date) |
| `src/features/agency/components/SpendCapEditor.tsx` | Per-client spend-cap + reset cadence |
| `src/features/agency/components/ClientCapMeter.tsx` | Cap-usage meter (10/50 workspace caps) |
| `src/features/agency/components/ProvisioningKeyForm.tsx` | Create sub-key (cap/reset/label/BYOK toggle) |
| `src/features/agency/components/ProvisioningKeyRow.tsx` | Key row (label + cap + reset + revoke) |
| `src/features/agency/components/KeyResetCadencePicker.tsx` | Daily/weekly/monthly midnight-UTC reset |
| `src/features/agency/components/MarkupPolicyEditor.tsx` | Per-workspace/per-model markup multiplier |
| `src/features/agency/components/MarginBreakdownTable.tsx` | Model → wholesale/markup/margin table |
| `src/features/agency/components/MarginTrendChart.tsx` | Margin-over-time chart |
| `src/features/agency/components/BrandingForm.tsx` | Logo/colors/remove-ReelForge-badge form |
| `src/features/agency/components/CustomDomainField.tsx` | Custom domain + DNS verify status |
| `src/features/agency/components/WhiteLabelPreview.tsx` | Live preview of rebranded shell |
| `src/features/agency/components/UsageExportButton.tsx` | Itemized per-key usage-metering CSV export |
### 4.14 `src/features/onboarding/` — empty-screen killer + growth loops
| Path | Responsibility |
| --- | --- |
| `src/features/onboarding/index.ts` | Barrel export |
| `src/features/onboarding/OnboardingWizard.tsx` | First-run wizard (goal → genre → sample) |
| `src/features/onboarding/SampleRemix.tsx` | One-tap sample-reel remix → first render |
| `src/features/onboarding/SoraMigration.tsx` | Sora-shutdown migration onboarding flow |
| `src/features/onboarding/model.ts` | Onboarding step + activation view-model |
| `src/features/onboarding/steps.ts` | Ordered step definitions + skip rules |
| `src/features/onboarding/use-onboarding.ts` | Step progression + persistence |
| `src/features/onboarding/use-sample-reels.ts` | Preloaded sample reels + one-tap remix |
| `src/features/onboarding/use-sora-migration.ts` | Map displaced Sora usage → routed stack |
| `src/features/onboarding/use-activation-tracking.ts` | 3–5min-to-first-clip funnel events (PostHog) |
| `src/features/onboarding/components/GoalPicker.tsx` | Pick creator goal (faceless/film/clipfarm) |
| `src/features/onboarding/components/SampleReelGrid.tsx` | Preloaded finished-sample grid |
| `src/features/onboarding/components/RemixCta.tsx` | One-tap remix CTA on a sample |
| `src/features/onboarding/components/ActivationChecklist.tsx` | Steps to first published clip |
| `src/features/onboarding/components/ProgressMeter.tsx` | Onboarding progress + reward hints |
| `src/features/onboarding/components/SoraMigrationForm.tsx` | Import prompts → Veo/Kling/Seedance routing |
| `src/features/onboarding/components/UpgradeTriggerCard.tsx` | Named upgrade-trigger nudges (watermark/hook) |
| `src/features/onboarding/components/WatermarkBadgeNotice.tsx` | Free-export watermark + remove-on-upgrade |
| `src/features/onboarding/components/ReferralInvitePanel.tsx` | Growth-loop invite/referral prompt |
### 4.15 `src/features/micro-tools/` — standalone free top-of-funnel tools
| Path | Responsibility |
| --- | --- |
| `src/features/micro-tools/index.ts` | Barrel export |
| `src/features/micro-tools/CaptionTool.tsx` | Standalone AI captioner (upload → ASS/SRT) |
| `src/features/micro-tools/HookScoreTool.tsx` | Standalone hook-strength analyzer |
| `src/features/micro-tools/ThumbnailTool.tsx` | Standalone thumbnail generator |
| `src/features/micro-tools/model.ts` | Tool input/result view-model |
| `src/features/micro-tools/use-caption-tool.ts` | Upload → caption job + download |
| `src/features/micro-tools/use-hook-score-tool.ts` | Upload → hook-score result |
| `src/features/micro-tools/use-thumbnail-tool.ts` | Prompt/frame → thumbnail render |
| `src/features/micro-tools/components/ToolUploadDropzone.tsx` | Shared upload dropzone for tools |
| `src/features/micro-tools/components/CaptionResultPanel.tsx` | Caption preview + download + upsell |
| `src/features/micro-tools/components/HookScoreResultCard.tsx` | Score + cold-open suggestion + upsell |
| `src/features/micro-tools/components/ThumbnailResultGrid.tsx` | Generated thumbnail options |
| `src/features/micro-tools/components/ToolUpsellBanner.tsx` | Funnel CTA into wallet product |
### 4.16 `src/features/affiliate/` — lifetime-recurring affiliate (extends `/referral`)
| Path | Responsibility |
| --- | --- |
| `src/features/affiliate/index.ts` | Barrel export |
| `src/features/affiliate/AffiliateDashboard.tsx` | Affiliate dashboard (links + earnings + payouts) |
| `src/features/affiliate/model.ts` | Affiliate link + commission view-model |
| `src/features/affiliate/use-affiliate.ts` | Affiliate stats + referrals + payouts |
| `src/features/affiliate/use-deep-links.ts` | Create/track deep links |
| `src/features/affiliate/components/DeepLinkBuilder.tsx` | Build + copy trackable deep links |
| `src/features/affiliate/components/CommissionTable.tsx` | Lifetime-recurring commission table |
| `src/features/affiliate/components/ReferralFunnel.tsx` | Clicks → signups → paid funnel |
| `src/features/affiliate/components/PayoutSetupCard.tsx` | Creem/Stripe payout setup |
---
## 5. Shared layer (`src/shared/*`) — hooks, transport, utilities
### 5.1 `src/shared/api/resources/` — typed resource clients
> Thin wrappers over `apiRequest` from `src/shared/api/client.ts`. One module per backend domain;
> each exports typed functions returning contract types. Feature `use-*` hooks call these — no raw
> `fetch`. Replaces growing the 117KB `lib/api.ts` monolith for new domains.
| Path | Responsibility |
| --- | --- |
| `src/shared/api/resources/index.ts` | Barrel export of all resource clients |
| `src/shared/api/resources/studio.ts` | Projects, script, beat-sheet, shots CRUD + render |
| `src/shared/api/resources/shots.ts` | Per-shot first-frame/motion generate + regenerate |
| `src/shared/api/resources/storyboard.ts` | Storyboard frames + animatic endpoints |
| `src/shared/api/resources/timeline.ts` | Timeline load/commit + interop export |
| `src/shared/api/resources/templates.ts` | Genre templates list/get/apply |
| `src/shared/api/resources/series.ts` | Series + episodes + cadence |
| `src/shared/api/resources/characters.ts` | Character/style locks + LoRA training |
| `src/shared/api/resources/clipfarm.ts` | Batches + automations + runs |
| `src/shared/api/resources/publishing.ts` | Compose + cross-post + container-poll + history |
| `src/shared/api/resources/connections.ts` | OAuth connect/list/health/disconnect |
| `src/shared/api/resources/trends.ts` | Trend feed + saturation + create-from-trend |
| `src/shared/api/resources/analytics.ts` | Retention + experiments + hook-score + best-time |
| `src/shared/api/resources/marketplace.ts` | Listings publish/install/earnings/payouts |
| `src/shared/api/resources/agency.ts` | Clients + provisioning keys + margin + branding |
| `src/shared/api/resources/onboarding.ts` | Sample reels + activation + Sora migration |
| `src/shared/api/resources/tools.ts` | Caption / hook-score / thumbnail micro-tools |
| `src/shared/api/resources/affiliate.ts` | Affiliate links + commissions + payouts |
| `src/shared/api/resources/burn.ts` | Per-model burn preview (credits/$ before render) |
| `src/shared/api/resources/media.ts` | Signed-URL fetch (never persisted) + upload init |
### 5.2 `src/shared/ui/` — cross-feature composite UI
| Path | Responsibility |
| --- | --- |
| `src/shared/ui/index.ts` | Barrel export |
| `src/shared/ui/AppShell.tsx` | Standard header + `UserButton` + nav chrome |
| `src/shared/ui/AppNav.tsx` | Primary nav (Studio/Clipfarm/Publish/Trends/Analytics) |
| `src/shared/ui/PageHeader.tsx` | Reusable page title + actions row |
| `src/shared/ui/DataTable.tsx` | Generic sortable/paginated table wrapper |
| `src/shared/ui/StatTileRow.tsx` | KPI tile row (analytics/agency/wallet) |
| `src/shared/ui/AsyncBoundary.tsx` | Loading/error/empty boundary wrapper |
| `src/shared/ui/ErrorState.tsx` | Standard error panel (correlation id + retry) |
| `src/shared/ui/PollingBadge.tsx` | Live-polling indicator |
| `src/shared/ui/MediaPlayer.tsx` | Shared video/loop player (signed-URL safe) |
| `src/shared/ui/AspectFrame.tsx` | Aspect-locked media frame (9:16/1:1/16:9) |
| `src/shared/ui/BurnPreviewInline.tsx` | Inline credits/$ burn chip (reused everywhere) |
| `src/shared/ui/ConfirmDialog.tsx` | Generic confirm dialog (destructive actions) |
| `src/shared/ui/UpgradeGate.tsx` | Locked-feature gate → upgrade trigger |
### 5.3 `src/shared/state/` — query client + global stores
| Path | Responsibility |
| --- | --- |
| `src/shared/state/query-client.ts` | TanStack QueryClient config (retry/stale) |
| `src/shared/state/QueryProvider.tsx` | Client provider mounted in root layout |
| `src/shared/state/workspace-store.ts` | Active workspace/agency-client context store |
| `src/shared/state/burn-store.ts` | Cross-stage burn-preview cache |
| `src/shared/state/toast-bus.ts` | `sonner` toast dispatch for job/publish events |
| `src/shared/state/keys.ts` | Central query-key factory per resource |
### 5.4 `src/shared/polling/` — job polling
| Path | Responsibility |
| --- | --- |
| `src/shared/polling/use-job-poll.ts` | Poll a job to terminal state (`POLL_INTERVAL_MS`) |
| `src/shared/polling/use-batch-poll.ts` | Poll a batch's per-item statuses |
| `src/shared/polling/use-container-poll.ts` | Poll IG container / TikTok audit status |
| `src/shared/polling/terminal-states.ts` | Terminal-state predicates (`completed`/`failed`) |
### 5.5 `src/shared/format/` — formatting utilities
| Path | Responsibility |
| --- | --- |
| `src/shared/format/credits.ts` | Microdollar→credits/$ display formatting |
| `src/shared/format/duration.ts` | Seconds↔`mm:ss` + frame formatting |
| `src/shared/format/datetime.ts` | Timezone-correct date/time (matches server cron) |
| `src/shared/format/numbers.ts` | Compact counts (12.3K views, retention %) |
| `src/shared/format/platform.ts` | Platform names/icons/aspect helpers |
### 5.6 `src/shared/media/` — EXTENDED
| Path | Responsibility |
| --- | --- |
| `src/shared/media/upload.ts` | Chunked reference/source upload (characters, tools) |
| `src/shared/media/loop-preview.ts` | Seamless-loop preview player helper (ASMR) |
| `src/shared/media/thumbnail.ts` | Client-side poster/frame extraction |
### 5.7 `lib/` additions (kept minimal — legacy compatibility only)
| Path | Responsibility |
| --- | --- |
| `lib/use-feature-flags.ts` | PostHog feature flags (gate new surfaces per plan) |
| `lib/nav-registry.ts` | Central nav item registry consumed by `AppNav` |
| `lib/plan-gates.ts` | Plan → allowed-surface map (free/pro/agency/enterprise) |
---
## 6. State & data-flow conventions
- **Server state** lives entirely in TanStack Query keyed via `src/shared/state/keys.ts`. No
duplicate client caches; feature `use-*` hooks are the only readers/writers.
- **Local UI state** (open panels, selected shot, timeline zoom) is `useState`/`useReducer` inside
the feature component; complex editors (`film-timeline`, `storyboard`) keep an immutable
`*-model.ts` reducer producing new objects on every edit (per repo immutability rule).
- **URL as state** via `nuqs` for gallery/marketplace/trends filters, analytics tabs, and Studio
stage — makes every view shareable and back-button-correct.
- **Cross-cutting context** (active workspace / agency client, burn cache, toasts) uses the small
Zustand-style stores in `src/shared/state/` — never prop-drilled.
- **Optimistic mutations** for reorder (storyboard/shots/timeline) and toggle actions (pause batch,
enable platform), rolled back on `ApiError`.
- **Polling** is opt-in per hook via `src/shared/polling/*`; it stops at terminal states and pauses
when the tab is hidden.
## 7. API bindings — `/api/v1` endpoints consumed (all envelope-wrapped)
> The client owns none of these; it calls the backend manifest in [apps-api.md](./apps-api.md).
> Grouped by resource client (§5.1). `GET` unless noted.
| Resource client | Endpoints (representative) |
| --- | --- |
| `studio.ts` | `POST /studio/projects`, `/studio/projects`, `/studio/projects/{id}`, `POST /studio/projects/{id}/script`, `POST /studio/projects/{id}/beats`, `POST /studio/projects/{id}/shotlist` |
| `shots.ts` | `/studio/projects/{id}/shots`, `POST /shots/{id}/frame`, `POST /shots/{id}/motion`, `POST /shots/{id}/regenerate` |
| `storyboard.ts` | `/studio/projects/{id}/storyboard`, `POST /studio/projects/{id}/storyboard/reorder`, `POST /studio/projects/{id}/animatic` |
| `timeline.ts` | `/studio/projects/{id}/timeline`, `POST /studio/projects/{id}/timeline/commit`, `POST /studio/projects/{id}/export` (otio/fcpxml/aspect) |
| `templates.ts` | `/templates`, `/templates/{id}`, `POST /templates/{id}/apply` |
| `series.ts` | `/series`, `POST /series`, `/series/{id}`, `POST /series/{id}/episodes`, `/series/{id}/episodes/{eid}` |
| `characters.ts` | `/characters`, `POST /characters`, `/characters/{id}`, `POST /characters/{id}/train`, `/characters/{id}/train/status` |
| `clipfarm.ts` | `/clipfarm/batches`, `POST /clipfarm/batches`, `/clipfarm/batches/{id}`, `/clipfarm/automations`, `POST /clipfarm/automations`, `POST /clipfarm/automations/{id}/toggle` |
| `publishing.ts` | `/publish/targets`, `POST /publish/compose`, `POST /publish/cross-post`, `/publish/containers/{id}`, `/publish/history` |
| `connections.ts` | `/connections`, `POST /connections/{platform}/authorize`, `POST /connections/{platform}/callback`, `DELETE /connections/{id}`, `/connections/{id}/health` |
| `trends.ts` | `/trends`, `/trends/audio`, `/trends/hashtags`, `/trends/{id}`, `POST /trends/{id}/create` |
| `analytics.ts` | `/analytics/retention/{videoId}`, `/analytics/experiments`, `POST /analytics/experiments`, `/analytics/hooks`, `/analytics/best-time` |
| `marketplace.ts` | `/marketplace/listings`, `POST /marketplace/listings`, `/marketplace/mine`, `POST /marketplace/listings/{id}/install`, `/marketplace/earnings` |
| `agency.ts` | `/agency/clients`, `POST /agency/clients`, `/agency/keys`, `POST /agency/keys`, `/agency/margin`, `PUT /agency/branding`, `/agency/usage/export` |
| `onboarding.ts` | `/onboarding/samples`, `POST /onboarding/samples/{id}/remix`, `/onboarding/state`, `POST /onboarding/migrate` |
| `tools.ts` | `POST /tools/caption`, `POST /tools/hook-score`, `POST /tools/thumbnail` |
| `affiliate.ts` | `/affiliate`, `POST /affiliate/links`, `/affiliate/payouts` |
| `burn.ts` | `POST /burn/preview` (per-shot/per-project credits+$ estimate) |
**Auth & safety on every call:** `x-api-key` (Clerk JWT via `getToken()` or `NEXT_PUBLIC_APP_API_KEY`
fallback), `Idempotency-Key` on all create/generate `POST`s, Zod-validated envelopes, correlation-id
surfaced in `ErrorState`. Success-only billing is enforced server-side — the client never assumes a
debit on error/queue/failure and reflects that in burn UI.
## 8. Build sequencing (phasing) — maps to `RESEARCH_DIGEST` §7
| Phase | Web deliverables | Depends on (backend) |
| --- | --- | --- |
| **P1 — Template + capture ROI** | `template-gallery`, `series` (one-click), `micro-tools`, onboarding empty-screen killer + sample remix; `components/ui/*` primitives; `src/shared/{api/resources,ui,state,polling,format}` foundation | `apps/api/reelforge/templates/`, `captions/` |
| **P2 — Close the loop (the wedge)** | `publishing` hub + cross-post composer, `connections` OAuth UI, `clipfarm` (batch/schedule/calendar), `creator-analytics` (retention/hooks/A/B), `trends` explorer | `apps/api/reelforge/publishing/` |
| **P3 — Resellable platform** | `agency` (clients/caps/keys/margin/branding), plan gates, usage export, provisioning keys, affiliate dashboard | `apps/api/reelforge/gateway/` |
| **P4 — Film moat** | `studio` (script→shot→frame→motion→export), `storyboard` board, `film-timeline` NLE, `characters` consistency manager + LoRA training | `apps/api/reelforge/film/` |
| **P5 — Marketplace + growth compounding** | `marketplace-studio` (publish/monetize), Sora-migration flow, growth-loop mechanics, native pay-per-view surfaces | `apps/api/reelforge/marketplace/` |
Each phase ships behind `lib/use-feature-flags.ts` + `lib/plan-gates.ts` so surfaces roll out per
plan tier without route churn.
## 9. Integration seams (how new surfaces bolt onto existing code)
| Seam | Existing anchor | New wiring |
| --- | --- | --- |
| **Nav** | `app/layout.tsx` header + `/dashboard` | `src/shared/ui/AppNav.tsx` reads `lib/nav-registry.ts`; adds Studio/Clipfarm/Publish/Trends/Analytics/Agency entries gated by `plan-gates.ts` |
| **Query provider** | root `app/layout.tsx` | Mount `src/shared/state/QueryProvider.tsx` once (wraps existing tree; legacy `lib/use-*` hooks keep working) |
| **New reel form** | `src/features/reel-create/Wizard.tsx` + `TemplateGallery.tsx` | `template-gallery` + `trends` prefill via `lib/spark-prefill.ts` pattern (`use-apply-template`, `use-create-from-trend`) |
| **Editor** | `src/features/editor/*` (EDL/timeline) | `film-timeline` reuses `timeline-model.ts` patterns; Studio `export` hands off to existing editor for manual finishing |
| **Jobs library** | `src/features/jobs-library/*` | Studio projects + batches + episodes surface as job sources; `publishing/compose/[jobId]` deep-links from `JobDetailsPage` |
| **B-roll studio** | `src/features/broll-studio/*` | Studio shots can pull B-roll via existing `src/shared/media/broll-attachment.ts` |
| **Scheduling** | `components/schedule/*`, `components/calendar/*`, `lib/calendar.ts` | `clipfarm/ContentCalendar` + `publishing/PublishQueue` reuse `use-calendar`, `platforms.ts`, `SchedulePublishDialog` |
| **Analytics** | `components/analytics/*`, `app/analytics/page.tsx` | `creator-analytics` adds `/analytics/{retention,experiments,hooks}` subroutes reusing `chart-theme.ts`, `ChartTooltip`, `format.ts` |
| **Connections** | `components/social/*`, `components/connections/*` | `src/features/connections` supersedes ad-hoc cards with OAuth-flow + health module (legacy components wrapped, not deleted) |
| **Marketplace** | `components/marketplace/*`, `lib/marketplace.ts`, `app/marketplace/*` | `marketplace-studio` adds publish/mine/earnings; reuses `TemplateCard`, `StarRating`, `LineageDialog`, `PublishDialog` |
| **Agency / keys** | `components/apikeys/*`, `lib/use-my-workspaces.ts`, `components/settings/*` | `agency` extends workspace + API-key surfaces with provisioning sub-keys, caps, margin, branding |
| **Wallet / burn** | `app/wallet/*`, `app/spend/*`, `lib/use-workspace-billing.ts` | `src/shared/ui/BurnPreviewInline` + `burn.ts` inject per-model burn preview into Studio/series/marketplace/tools |
| **Onboarding** | `app/(marketing)/*`, `lib/use-current-user.ts` | `onboarding` gates first-run via `use-activation-tracking` (PostHog); watermark + upgrade-trigger loops |
| **Types** | `packages/api-contract`, `lib/types.ts` | New domains import from `@reelforge/api-contract`; `lib/types.ts` frozen (legacy only) |
> **Net-new file count (approx):** ~40 route files (§3) + ~230 feature files (§4) + ~50 shared/ui
> files (§5) ≈ **320 additive files**, all matching existing `apps/web` conventions and consuming a
> single unchanged `/api/v1` contract.