# Embed Studio - Architecture Document ## Overview The Embed Studio is a dedicated UI mode within the editor for creating, editing, and previewing HTML embed visualizations (D3.js charts). It isolates the dataviz workflow from the article editing flow, providing a focused chat + preview experience similar to the standalone [dataviz-agent-space](https://huggingface.co/spaces/tfrere/dataviz-agent-space). ## Context Embeds are self-contained HTML fragments (root div + scoped style + script) that call the shared `Embed.mount` runtime. The runtime and the authoring guides live in `backend/embed-kit/` (`embed-runtime.js`, `contract.md`, `banners.md`, `dataviz.md`); `npm run gen:embed-kit` in `backend/` compiles them into the TypeScript modules used by `buildEmbedSrcdoc` and the Embed Studio prompt. In the editor, users need to create and iterate on these charts without leaving the editor. The Embed Studio solves this by providing a dedicated panel with an AI assistant specialized in D3 chart generation. ## Storage ### Y.Map("embeds") Embed HTML content is stored in a collaborative Yjs Map, keyed by filename: ``` Y.Map("embeds") = { "d3-scaling-chart.html": "