videogen/docs/reelforge/ALL_APPS_IMPLEMENTATION_PLAN.md
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
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

344 lines
16 KiB
Markdown

# ReelForge all-apps implementation plan
> **Scope:** the concrete next architecture for every deployable application:
> `apps/api`, `apps/web`, `apps/mobile`, `apps/desktop`, and the contract/SDK
> packages that connect them.
> **Product principle:** one account, wallet, catalog, media library, job graph,
> and capability document across every device. Each app specializes its UX; none
> reimplements backend transactions or provider protocols.
## 1. App responsibility matrix
| Capability | API | Web | Mobile | Rust/GPUI desktop |
| --- | --- | --- | --- | --- |
| Identity and authorization | canonical | Clerk sign-in/session | secure session/API key | OS keychain API key |
| Model catalog, wallet, quote | canonical | full browse/compare/purchase | compact picker/balance | picker/read-only balance |
| Reel creation | validate/create/dispatch | full wizard | fast creator | native production form |
| B-roll | provider routing/worker | studio/history/attach | studio/history/attach | studio/attach from library |
| Upload | presign/register/ownership | drag/drop/browser | device picker/camera/files | file/screen capture |
| Job library | canonical state | full filters/detail/editor | queue and review | persistent native library |
| Preview | signed URL | browser player/editor | native player/share | native player/open/download |
| Billing and invoices | ledger/payment webhooks | full purchase/invoices | hosted checkout handoff | browser handoff/read-only |
| Publishing/OAuth | token lifecycle/publish | full settings/calendar | status + web handoff | browser handoff only |
| Teams/admin/developer | canonical | full control plane | summary/read-only | no initial scope |
## 2. Shared client contract
### 2.1 API primitives every client implements
```text
authenticate() -> principal and allowed capabilities
getCapabilities() -> pilot, launch, engine/runtime conditions
getCatalog() / getQuote() -> reviewed model/profile and max-cost quote
getWallet() / getActivity() -> wallet display; no local money calculation
presignUpload() → PUT → registerUpload()
createReel() / createBroll() / createEditorExport() with Idempotency-Key
poll(resource) -> queued/running/completed/failed snapshots
getSignedPreview() -> use transiently, refresh on expiry
retryEligibleFailure()
```
All clients preserve the idempotency key until a terminal create response is
received. They display user-safe error text plus correlation ID; they do not
retry a failed payment, provider request, or job create with a new key.
### 2.2 State ownership
| State | Web | Mobile | Desktop | Server authority |
| --- | --- | --- | --- | --- |
| Session/API credential | Clerk session | secure store | OS credential store | yes |
| Form draft | browser session/local draft | durable secure/app storage | workspace cache | no |
| Upload progress | ephemeral | ephemeral/resumable if platform supports | worker state | no |
| Job snapshot | query/poll cache | offline cache | workspace library cache | yes |
| B-roll attachment | current draft | current draft | current draft | validated on reel create |
| Preview URL | memory only | memory only | memory only | yes |
| Wallet balance/usage | display cache | display cache | display cache | yes |
| Provider keys | never | never | never | encrypted API only, later BYOK |
## 3. `apps/api` detailed plan
### 3.1 Final API directory shape
```text
apps/api/
├── app/
│ ├── asgi.py
│ ├── router.py
│ ├── bootstrap.py
│ ├── core/
│ │ ├── auth/ Clerk, API key, principal, workspace context
│ │ ├── capabilities/ user/product/launch capability document
│ │ ├── launch/ public feature gates and kill switches
│ │ ├── observability/ correlation, logs, Sentry events
│ │ ├── product_inventory.py
│ │ ├── idempotency.py
│ │ └── errors.py
│ ├── platform/
│ │ ├── storage/ R2/S3 only
│ │ ├── queue/ Celery route/dispatch primitives
│ │ ├── providers/ base adapter, catalog/price/health clients
│ │ ├── media/ ffmpeg/ffprobe primitives
│ │ └── cache/ Redis locks, rate limits, shared state
│ ├── domains/
│ │ ├── reels/ create/status/retry/rerun/pipeline policies
│ │ ├── broll/ generation, presets, attachment validation
│ │ ├── media/ upload intents and owned assets
│ │ ├── editor/ timeline/export jobs
│ │ ├── catalog/ reviewed models and generation profiles
│ │ ├── wallet/ balance, quote, reserve, settle, refund
│ │ ├── routing/ model/provider selection and fallback
│ │ ├── billing/ payment-provider checkout/webhooks/invoices
│ │ ├── publishing/ OAuth connections, publish, calendar
│ │ ├── identity/ me, SSO, SCIM, security policy
│ │ ├── workspaces/ membership, RBAC, audit
│ │ ├── creator/ avatar, voice, brand, ideas, notifications
│ │ ├── content/ catalogs, cover, social copy
│ │ ├── community/ share, marketplace, profiles
│ │ ├── developer/ public API keys/webhooks
│ │ ├── insights/ analytics/performance
│ │ ├── compliance/ consent/export/erasure/retention
│ │ └── legacy/ contained old video/LLM adapters only
│ ├── workers/
│ │ ├── celery_app.py
│ │ ├── reel_pipeline.py
│ │ ├── generation_pipeline.py
│ │ ├── editor_pipeline.py
│ │ └── maintenance.py
│ └── telemetry/
├── engine/ GPU-only engine package
├── assets/ reviewed immutable product assets
├── runtime/storage/ mounted mutable worker data only
└── tools/ops/ preflight, deploy smoke, reconciliation CLI
```
### 3.2 API delivery order
1. Finish existing reel/B-roll/media/editor client contract parity.
2. Build catalog/profile/quote read APIs in shadow mode.
3. Build wallet ledger/reservation/settlement and payment-webhook bridge.
4. Add `model_id`, `generation_profile_id`, quote ID, and max-cost fields as
additive job inputs; preserve legacy inputs during migration.
5. Move individual compatibility controller bodies into their domain services.
6. Add provider routing/fallback/BYOK only after wallet reconciliation is live.
## 4. `apps/web` detailed plan
### 4.1 Route tree
```text
apps/web/app/
├── (marketing)/
│ ├── page.tsx landing
│ ├── pricing/page.tsx pay-as-you-go explanation, not plans
│ ├── models/page.tsx public catalog discovery
│ ├── terms/page.tsx
│ ├── privacy/page.tsx
│ └── acceptable-use/page.tsx
├── (product)/
│ ├── layout.tsx authenticated navigation/shell
│ ├── dashboard/page.tsx
│ ├── new/page.tsx
│ ├── broll/page.tsx
│ ├── jobs/page.tsx
│ ├── jobs/[id]/page.tsx
│ ├── editor/page.tsx
│ ├── models/page.tsx
│ ├── models/[modelId]/page.tsx
│ ├── profiles/page.tsx
│ ├── wallet/page.tsx
│ ├── wallet/activity/page.tsx
│ ├── usage/page.tsx
│ ├── connections/page.tsx
│ ├── scheduled/page.tsx
│ ├── calendar/page.tsx
│ ├── team/page.tsx
│ ├── settings/… account, key, privacy, billing, SSO
│ └── developer/page.tsx
├── admin/… staff routes only
├── r/[token]/page.tsx public shared reel
└── sign-in/, sign-up/
```
### 4.2 Feature folders
```text
apps/web/src/features/
├── app-shell/ navigation, capability-aware nav, global errors
├── reel-create/ wizard steps + form mapping + submission
├── broll-studio/ prompt, i2v upload, poll/history/attach
├── jobs-library/ filters, detail, retry/rerun, activity timeline
├── editor/ timeline/preview/export command
├── model-catalog/ browsing, comparison, model detail
├── generation-profiles/ profile picker/builder and quote confirmation
├── wallet/ balance, purchase quote, checkout, activity
├── publishing/ connections, schedule, calendar, publish result
├── workspace/ team, role, audit, SSO, usage
├── creator/ avatar, voice, brand, ideas, notification
├── community/ marketplace, profile, share, leaderboard
├── developer/ keys, quotas, webhook endpoint management
└── admin/ staff tables and actions
```
### 4.3 Web critical journeys
**Create reel:** Dashboard/New → choose profile → select recording → upload
and register → optional B-roll attachment → quote confirmation → create job →
detail/poll → preview → editor/publish when launch allows.
**Wallet:** Wallet → choose wallet credit amount → API purchase quote (shows
platform fee) → hosted checkout → webhook-confirmed activity/balance → return
to Create. Browser return never grants balance by itself.
**Model discovery:** Models → model detail → compatible capabilities/price/data
policy → add to profile → quote at create. A browser cannot set raw provider
model identifiers.
## 5. `apps/mobile` detailed plan
### 5.1 Expo route tree
```text
apps/mobile/app/
├── _layout.tsx
├── index.tsx bootstrap/auth redirect
├── (tabs)/
│ ├── create.tsx reel creation
│ ├── broll.tsx B-roll studio
│ ├── jobs.tsx active/completed library
│ └── me.tsx account hub
├── job/[id].tsx deep-linked detail/review
├── wallet.tsx
├── wallet/activity.tsx
├── models.tsx compact catalog/picker
├── notifications.tsx
├── avatars.tsx, voices.tsx, brand.tsx
├── team.tsx, usage.tsx, privacy.tsx
└── connections.tsx status + web OAuth handoff
```
### 5.2 Mobile feature modules
```text
apps/mobile/src/features/
├── reel-create/ draft, model/profile picker, upload, create
├── broll-studio/ prompt/i2v/history/player/attach
├── jobs-library/ list/detail/poll/retry/share
├── wallet/ balance/activity/checkout browser handoff
├── model-catalog/ compact filtered listing and selection
├── account/ account/plan/API key/privacy/team summary
├── notifications/ notification list and job deep links
└── publishing/ connection status only initially
```
### 5.3 Mobile lifecycle requirements
- Persist non-secret creation drafts and B-roll history.
- Stop active polling in background; refresh active resources on foreground,
focus, deep link, and push notification.
- Use Expo secure storage for credential/session material; never AsyncStorage.
- Use native player with signed-URL refresh on expiry and share/download only
through OS-provided handoff.
- Offer hosted web handoff for checkout, OAuth, invoices, model comparison, and
enterprise settings rather than embedding sensitive provider flows.
## 6. `apps/desktop` detailed plan
### 6.1 GPUI workspace navigation
```text
apps/desktop/src/ui/
├── shell.rs top-level workspace/navigation
├── create/
│ ├── reel_form.rs fields/profile/quote/create
│ ├── broll_form.rs prompt/mode/approved workflow/create
│ ├── model_picker.rs
│ └── upload_progress.rs
├── library/
│ ├── list.rs queue/completed/failed filters
│ ├── detail.rs stages, cost, errors, retry
│ └── cost_details.rs
├── preview/
│ ├── player.rs native playback
│ ├── broll_attach.rs choose result for current reel draft
│ └── result_actions.rs open/save/reveal
├── wallet/
│ ├── overview.rs read-only balance/low balance
│ └── activity.rs
├── settings/
│ ├── connection.rs endpoint/credential test
│ ├── secure_store.rs Keychain error and recovery
│ └── capabilities.rs launch/runtime/model availability
└── components/
```
### 6.2 Background architecture
```text
ui intent
→ workspace::WorkerCommand
→ workspace::worker (HTTP, OS credential, upload, poll, preview launch)
→ workspace::WorkerUpdate
→ workspace::reducer (pure DesktopState update)
→ GPUI render
```
The UI thread never blocks on HTTP, filesystem scanning, credential access, or
video playback setup. `workspace/persistence.rs` stores only non-secret draft,
library, selected item, and endpoint preference. `security/credentials.rs`
stores/retrieves the API key through platform secure storage only.
### 6.3 Desktop product requirements
- Large-file/screen capture upload with clear local validation/progress.
- Native preview and result handoff, not a browser-only player.
- Library persists across restart and reconciles with API when connected.
- B-roll result attaches to the existing reel draft through a typed key; no
copy/paste URL workflow.
- Wallet is display-only at first; clicking top-up opens trusted browser URL.
- Provider/model browsing is filtered by server capability and quote, never
a locally maintained provider list.
## 7. `packages` plan
```text
packages/api-contract/
├── openapi/reelforge-v1.json
├── src/generated/ generated TypeScript DTOs only
├── src/reels.ts, broll.ts, media.ts, wallet.ts, catalog.ts
└── scripts/check_breaking.py
packages/sdk-typescript/
├── src/resources/ jobs, broll, uploads, catalog, wallet
└── src/errors.ts
packages/sdk-python/
├── reelforge_sdk/resources/ matching resources
└── reelforge_sdk/errors.py
```
Contract sequence for each API change: change server schema → export OpenAPI →
review additive/breaking diff → regenerate contract → update web/mobile and
reviewed desktop mapping → update SDKs. No client owns independently hand-coded
financial or provider DTOs.
## 8. Cross-app release phases
| Release | API | Web | Mobile | Desktop |
| --- | --- | --- | --- | --- |
| R1: parity | reels/B-roll/media/editor canonical paths | wizard, studio, jobs, preview | create, studio, jobs, preview | create, library, preview, secure settings |
| R2: catalog | models/profiles/quotes | full compare/profile builder | compact picker | picker + quote display |
| R3: wallet pilot | ledger/reserve/settle/payment sandbox | wallet/activity/hosted checkout | balance/activity/handoff | read-only wallet/browser handoff |
| R4: marketplace | multi-provider routing/usage | provider/usage controls | model selection/usage summary | model/cost details |
| R5: public | abuse/risk/tax/refund controls | public paygo + support | public paygo handoff | no direct payment credentials |
| R6: enterprise | BYOK/workspace policy/invoicing | full policy/admin | summary/web handoff | settings status only |
## 9. Definition of app completeness
The product is not complete when screens merely exist. A release is complete
only when its relevant client can authenticate, obtain server capabilities,
upload owned media, submit with an idempotency key, survive lifecycle changes,
render terminal success/failure with correlation ID, preview signed output, and
reconcile its cache with API truth. For wallet-enabled routes it must also show
the API quote before work, never calculate or mutate money locally.