How open-din/din-studio works
1. What this repo owns
- din-studio is the studio layer above @open-din/react: it owns the editor UI, the desktop/browser shells, the MCP server, and code-generation/agent workflows.
- It deliberately does not own the public patch schema or runtime semantics; those belong to react-din / din-core.
2. Top-level architecture
- The repository is organized around a few runtime targets: a browser editor, an Electron desktop app, and an MCP server.
- Most user-facing behavior lives in ui/, while targets/ contains thin platform entrypoints that host the same product surface in different runtimes.
3. Product contract and generated manifests
- The project/ directory is the repository’s specification layer: route cards, editor node slices, MCP tool slices, surface manifests, coverage manifests, feature specs, and skills.
- These files act as the source of truth for what the editor exposes, what MCP tools exist, and what scenarios tests should cover.
- Validation and generation scripts in scripts/ and tests in tests/ enforce consistency between these manifests and the implementation.
4. Editor shell and workspace UI
- The main UI entry points are ui/App.tsx, ui/ProjectLauncher.tsx, and ui/Editor.tsx.
- The shell layer in ui/shell/ composes the workspace into panels and drawers: activity rail, inspector, catalog explorer, source control, agent panel, command palette, and status/footer areas.
- This is the main coordination layer for navigation, panel state, and editor-level actions.
5. Graph editor subsystem
- The actual graph-building experience is centered in ui/editor/.
- store.ts, graphStorage.ts, graphBuilders.ts, graphUtils.ts, and defaultGraph.ts manage graph state and persistence.
- nodeCatalog/, nodeUiRegistry.ts, nodes/, and templateLibrary.ts define the available node types, their UI affordances, and reusable graph templates.
6. Audio and MIDI runtime-facing features
- Audio and MIDI concerns are isolated inside the editor subsystem but represent a distinct data flow from graph state into interactive runtime behavior.
- Files such as AudioEngine.ts, audioImport.ts, audioExport.ts, audioLibrary.ts, midiRuntime.ts, midiDetectionStore.ts, and the MIDI-related node components implement import/export, device detection, playback, recording, and control surfaces.
- The editor UI is therefore both a graph authoring tool and a live audio/MIDI control surface.
7. Node rendering and inspector/code generation
- Each node type has a dedicated React component under ui/editor/nodes/, with shared UI primitives in ui/editor/components/.
- Inspector.tsx and CodeGenerator.tsx bridge the visual graph to generated outputs and editable node metadata.
- This is where user edits on the canvas become structured changes to node parameters, connections, and generated code or patch artifacts.
8. AI agent and operation pipeline
- ui/ai/ contains the agent-facing layer: prompt construction, tool definitions, settings, chat storage, and operation application.
- bridge/ adds a lightweight protocol/status layer for connecting the editor UI to the agent/MCP world.
- The important architectural boundary here is that the agent does not directly mutate UI state; it proposes or applies operations that are funneled through shared editing logic.
9. Shared operation/session abstractions
- core/ contains reusable abstractions such as sessions, operations, and offline behavior.
- This is the shared backbone for cross-cutting workflows like persistence, agent actions, and any logic that needs to work consistently in browser, desktop, or bridge contexts.
10. RAG/search support
- src/rag/ and src/rag-ui.ts implement retrieval and augmentation support: chunking, embeddings, vector storage, search, and retrieval.
- This subsystem is likely used to enrich agent workflows with repository context, docs, or generated knowledge rather than to power the editor core itself.
- It sits adjacent to the AI tooling boundary, feeding context into assistant-driven actions.
11. MCP server target
- targets/mcp/ is a standalone runtime exposing the studio’s capabilities through MCP.
- It includes both stdio and TLS/bridge server paths, runtime definitions/handlers/resources, session registry, logging, and config.
- This target is the main integration boundary for external agents/tools and mirrors the same underlying manifest/tooling contracts defined in project/.
12. Desktop and web hosts
- targets/app/ is the Electron host, split into main, preload, and renderer entrypoints.
- targets/web/ is the browser host, built with Vite and used for the editor in a pure web runtime.
- These targets are intentionally thin: they host the same UI/product surface while changing packaging and process boundaries.
13. Documentation, feature specs, and tests as architecture enforcement
- docs/ and project/features/ describe the intended behaviors of the editor, nodes, panels, and agent/MCP flows.
- tests/unit/ and tests/e2e/ map closely to those specs, giving the repo a strong contract-testing shape.
- For an architecture diagram, these are not just documentation; they are the governance layer that keeps the UI, manifests, and MCP surfaces aligned.
14. External dependencies and trust boundaries
- The repo assumes @open-din/react provides the public patch/MIDI/data surfaces and treats that package as the runtime authority boundary.
- din-core owns runtime/registry semantics, while din-agents owns routing and quality gates.
- din-studio therefore sits in the middle: it authoring tools, shell UI, and integration surfaces that orchestrate those external authorities without redefining them.
Main entry points: EditorShell.tsx Editor shell · index.ts MCP server · store-and-codegen.spec.ts Tests · App.tsx App shell
Components 18
UI layer
Browser and desktop-facing studio UI, including shell, editor, and AI surfaces.
- App shell · Top-level app composition and routing between launcher and editor.
ui/App.tsx - Project launcher · Entry flow for choosing or opening a studio project.
ui/ProjectLauncher.tsx - Editor surface · Main editing experience that hosts the graph editor and shared studio actions.
ui/Editor.tsx - Editor shell · Panel and drawer orchestration for navigation, inspector, catalog, source control, and agent tools.
ui/shell/EditorShell.tsx - Graph editor · Graph state, persistence, builders, defaults, and template-driven canvas behavior.
ui/editor/store.ts - Node library · Node catalog, registry, node components, and reusable node templates.
ui/editor/nodes/index.ts - Inspector/codegen · Inspector and code generation bridge from canvas edits to structured outputs.
ui/editor/Inspector.tsx - Audio/MIDI runtime · Live audio, MIDI import/export, device detection, playback, and control surfaces.
ui/editor/AudioEngine.ts - AI tools · Agent prompts, tools, settings, chat storage, and operation application.
ui/ai/agent.ts - Bridge protocol · Lightweight status and client bridge between the editor UI and agent/MCP world.
bridge/protocol.ts
Runtime targets
Thin host entrypoints for web, Electron, and MCP runtimes.
- Web host · Browser runtime entrypoint for the studio UI.
targets/web/main.tsx - Electron host · Electron main, preload, and renderer entrypoints for the desktop app.
targets/app/main.ts - MCP server · Standalone MCP runtime with stdio, TLS/bridge, session registry, and handlers.
targets/mcp/src/index.ts
Specs and tests
Manifests, feature specs, docs, and tests that lock the studio contract.
- Studio specs · Repository manifests, route cards, surface definitions, coverage, and skills that define the product contract.
project/REPO_MANIFEST.json - Docs · Behavioral and architectural documentation for shells, panels, runtimes, and workflows.
docs/README.md - Tests · Unit and end-to-end suites that enforce UI, manifest, audio/MIDI, RAG, and MCP behavior.
tests/unit/store-and-codegen.spec.ts
Connections 24
- App shell → Project launcher: opens · App routes users into project selection or the editor.
- App shell → Editor surface: hosts · App composes the main studio editor experience.
- Project launcher → Studio specs: reads · Launcher behavior follows repository manifest and flow specs.
- Editor surface → Editor shell: uses · Editor delegates workspace composition and panel state to the shell.
- Editor shell → Graph editor: controls · Shell actions mutate graph workspace state.
- Editor shell → Inspector/codegen: opens · Shell exposes inspector and generation panels.
- Editor shell → Audio/MIDI runtime: surfaces · Shell hosts audio and MIDI status/controls.
- Graph editor → Node library: instantiates · Graph state is rendered through node catalog and components.
- Graph editor → Inspector/codegen: feeds · Selected nodes and connections drive inspector/code generation.
- Node library → Audio/MIDI runtime: includes · Several nodes expose audio and MIDI runtime controls.
- AI tools → Bridge protocol: connects · Agent tooling exchanges status and protocol data through the bridge.
- AI tools → Core ops: applies · Agent actions flow through shared operations and session abstractions.
- AI tools → RAG stack: retrieves · Agent workflows can pull contextual retrieval results.
- Bridge protocol → MCP server: adapts · Bridge aligns UI status and protocol expectations with MCP runtime.
- Web host → App shell: boots · Web host mounts the studio app.
- Electron host → App shell: boots · Electron renderer hosts the same app surface.
- MCP server → Studio specs: implements · MCP runtime mirrors the manifest-defined tool and surface contract.
- MCP server → Core ops: shares · Server runtime reuses session and operation abstractions.
- Studio specs → Tests: governs · Specs and manifests are enforced by unit and e2e coverage.
- Docs → Editor shell: describes · Documentation explains shell panels, drawers, and navigation.
- Docs → MCP server: describes · Docs cover MCP runtime behavior and integration boundaries.
- Tests → Graph editor: verifies · Tests cover graph state, codegen, and editor behaviors.
- Tests → MCP server: verifies · Tests cover MCP server runtime and bridge paths.
- Tests → RAG stack: verifies · Tests cover retrieval and search behavior.