You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 03f0639
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+37-4Lines changed: 37 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,28 +9,59 @@ Projects
9
9
+ Home
10
10
+ Studio
11
11
+ Canvas
12
+
+ Editor
12
13
+ Assets
13
14
+ Generation history
14
15
+ Provider configuration
15
16
+ Storage configuration
16
17
```
17
18
18
-
Studio, Canvas, and Assets are three views over the same project, generation, and asset services. Switching modes never creates a second project or backend.
19
+
Studio, Canvas, Editor, and Assets are views over the same project, generation, asset, and history services. Switching modes never creates a second project or backend.
20
+
21
+
The shared product model is asset-first:
22
+
23
+
- A generation creates an `Asset`; it does not own a single UI placement.
24
+
- A Canvas node references an Asset, Generation, or Timeline.
25
+
- A Timeline clip pins a concrete Asset and never silently follows a Canvas generation's latest output.
26
+
- A Take is an alternate Asset for one clip; the original source remains recoverable.
27
+
- Canvas edges describe visual organization. Generation lineage describes real derivation and is stored separately.
19
28
20
29
## Runtime flow
21
30
22
-
The browser calls local `/api` routes. Server routes validate input and call the BeatAPI adapter. The adapter submits image/video generation tasks or the stable `/v1/video-analysis/tasks` workflow, then checks `/v1/tasks/:id`. Generation state and analysis text are stored locally, while provider result URLs are indexed as project assets.
31
+
The browser calls local `/api` routes. Server routes validate input and resolve a logical model through the active Generation Provider contract. BeatAPI is the built-in/default provider; forks can register another source-level provider without changing Canvas, Editor, MCP, or the asset-first request contract.
23
32
24
33
Provider credentials are read from environment variables or the local `config` table. Browser components never receive the raw API key.
25
34
26
35
Upload storage is a separate adapter boundary. File selection remains browser-local. A successful generation precheck creates a short-lived, one-time SQLite intent that binds the project, model, exact upload count, uploaded URLs, and final generation submission. Required references are promoted only after that point and immediately before task submission; they become project assets only after BeatAPI accepts the task. The built-in provider is fixed to the official `https://api.beatapi.io` endpoint. Official `BEATAPI_MANAGED_R2_*` secrets and self-hosted `R2_*` credentials are deliberately separate and never fall through to each other.
27
36
37
+
## Command boundary
38
+
39
+
UI actions, the local MCP server, and a future CLI call the same Command Kernel. The kernel owns validation and pure document operations for Canvas and Editor. Persistence boundaries remain responsible for revision checks, durable writes, and returning the authoritative document.
40
+
41
+
```text
42
+
UI / MCP / CLI
43
+
|
44
+
Command envelope + validation
45
+
|
46
+
Canvas / Editor / Generation commands
47
+
|
48
+
revision-checked project persistence
49
+
|
50
+
SQLite + project media files
51
+
```
52
+
53
+
MCP does not write SQLite directly or replace an entire Canvas or Timeline document. Its tools call `persistBeatDesignCommand` with a transport-controlled `origin=mcp`. The public UI route assigns `origin=ui` server-side and rejects an `origin` request field. UI-only timeline replacement exists for local autosave and undo/redo, remains revision-checked, and is rejected for MCP/CLI origins. Generation commands are asset-first and intentionally have no `placement` field; the server compiles provider media URLs from project-owned Asset IDs and the one-time generation intent before submission.
54
+
55
+
Canvas layout persistence is the deliberate exception on the UI side: drag, resize, viewport, and the complete visual arrangement are saved as a revision-checked snapshot. Semantic Canvas operations are also exposed through `canvas.apply`, and external agents must use those operations rather than snapshot replacement.
56
+
28
57
## Persistence
29
58
30
-
The SQLite/D1 schema contains ten tables:
59
+
The SQLite/D1 schema contains twelve tables:
31
60
32
61
-`project`
33
62
-`project_canvas_state`
63
+
-`project_timeline_state`
64
+
-`project_command_receipt`
34
65
-`project_workflow_state`
35
66
-`generation_history`
36
67
-`generation_upload_intent`
@@ -40,11 +71,13 @@ The SQLite/D1 schema contains ten tables:
40
71
-`project_asset_membership`
41
72
-`config`
42
73
74
+
`project_command_receipt` stores bounded, short-lived command results for retry idempotency and powers the current MCP history tool. It is not a permanent audit log; long-term Agent Activity still needs a separate durable event contract.
75
+
43
76
No user, session, role, order, subscription, payment, credit, API-key, ticket, or CMS table belongs in this repository.
44
77
45
78
## Model catalog
46
79
47
-
`src/core/effects/effect-registry.ts` is the canonical user-facing catalog. `src/core/adapters/beatapi-adapter.ts`maps that catalog to BeatAPI request bodies. Do not add a second database-backed model registry.
80
+
`src/core/effects/effect-registry.ts` is the canonical user-facing logical catalog. `src/core/generation-providers/` maps those logical IDs to provider bindings and adapters. `src/core/adapters/beatapi-adapter.ts`contains BeatAPI request mapping. Do not leak upstream effect IDs or field names into MCP tools, and do not add a second database-backed model registry.
- BeatAPI model capability discovery and asset-first generation contracts.
15
+
- Codex plugin packaging plus generic MCP configuration for Claude Code, Cursor, OpenCode, and other stdio hosts.
16
+
17
+
### Changed
18
+
19
+
- Canvas and Editor now check for Agent/MCP revisions every two seconds and whenever the page regains focus.
20
+
- Canvas rebases pending local layout edits onto newer Agent revisions instead of blocking visible MCP updates; snapshot restoration also removes stale shapes before rebuilding the current document.
21
+
- Editor autosave adopts the canonical saved document and ignores timestamp-only differences, preventing repeated save echoes from blocking MCP updates.
22
+
- Generated and imported media are persisted in project-owned local storage and indexed in SQLite.
23
+
- External Canvas media writes require project-owned Asset IDs, and local image/video/audio imports validate type and size before reading file contents.
24
+
- GitHub documentation now includes a product-first English/Chinese README and a BeatDesign release cover.
25
+
26
+
### Current boundaries
27
+
28
+
- Editor snapshots are semantic rather than pixel-rendered.
29
+
- MP4 export remains browser-driven and is not yet available as a headless MCP tool.
30
+
- Captions, transitions, speed controls, multiple named timelines, and native desktop packaging remain follow-up work.
Copy file name to clipboardExpand all lines: PROVIDERS.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Provider configuration
2
2
3
-
BeatAPI is the fixed built-in generation and analysis provider implemented by this repository. The upstream URL is intentionally fixed to `https://api.beatapi.io`; users only provide their own BeatAPI API key.
3
+
BeatAPI is the built-in and default generation/analysis provider. The official BeatAPI adapter keeps its upstream URL fixed to `https://api.beatapi.io`; users only provide their own BeatAPI API key.
4
4
5
5
Configure it in either place:
6
6
@@ -17,13 +17,15 @@ The adapter uses:
17
17
-`GET /v1/tasks/:id`
18
18
-`POST /v1/files` for supported reference files
19
19
20
-
Model support is defined in `src/core/effects/effect-registry.ts`, not discovered dynamically. This keeps Canvas and Studio behavior deterministic. When adding a model, update the registry, request mapping, media capability rules, and tests together.
20
+
User-facing model capabilities are defined in `src/core/effects/effect-registry.ts`. Provider bindings live in `src/core/generation-providers/`; MCP and UI use the logical model id and capability schema, not BeatAPI `effectId` or raw upstream fields.
21
21
22
22
Kling 2.6 and Kling 3.0 Motion Control are exposed as BeatAPI models. Each run requires exactly one character image and one MP4/MOV motion video uploaded through the connected BeatAPI account. The Workspace never asks users for a KIE key; BeatAPI owns the upstream provider route, billing, polling, and output persistence.
23
23
24
24
Video Analysis is exposed as a stable BeatAPI workflow with Standard and Deep depth controls. The Workspace uploads one MP4/MOV input, submits the analysis task, polls `GET /v1/tasks/:id`, and stores the returned report text and usage in the local project history. Provider-specific Gemini routing remains private to BeatAPI.
25
25
26
-
An API with a different request or polling contract still needs its own adapter. This repository does not ship placeholder KIE, Vidu, Evolink, Gemini, Fal, Replicate, or payment-provider integrations.
26
+
An API with a different request or polling contract needs its own adapter. Forks can register one in `src/config/generation-providers.ts`, bind only the logical models they support, and set server-side `GENERATION_PROVIDER=<id>`. BeatAPI is the default only when no custom provider is selected; an unknown configured id fails explicitly so it cannot accidentally submit a task to another provider. This repository does not ship placeholder KIE, Vidu, Evolink, Gemini, Fal, Replicate, or payment-provider integrations.
27
+
28
+
A custom provider definition owns adapter construction, readiness checks, parameter validation, model bindings, upstream model names, and upload paths. Provider credentials must stay server-side. Switching providers does not change Canvas nodes, Editor clips, Asset IDs, or MCP requests; each submitted task also records its provider/model identity so polling does not silently follow a later default-provider change.
0 commit comments