# wisdom-km/mira_new architecture

> Architecture diagram of the GitHub repository wisdom-km/mira_new, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wisdom-km/mira_new
- Repository: https://github.com/wisdom-km/mira_new

## Overview

#### Purpose and Entry Points
DirectorDesk is a native C++17 desktop application for creating controllable AI-video storyboards from Markdown scripts, 3D assets, camera presets, and shot links. The executable starts in `src/App/main.cpp`, constructs the application loop in `src/App/Application.cpp`, and optionally opens a `.ddproj` project such as `examples/cafe.ddproj`.

#### Application Composition
`Application` coordinates platform startup, window/render loop, project loading, document state, panels, and asynchronous work. Project-level persistence and cross-document binding are centered in `src/App/ProjectFile.cpp` and `src/App/ProjectBinding.cpp`; public application contracts live under `include/DirectorDesk/App/`.

#### Script-to-Shot Domain Flow
Markdown is parsed into a structured script document by `src/Script/Parser.cpp` and maintained by `src/Script/Document.cpp`. Stable script IDs from `src/Script/Ids.cpp` provide the boundary for linking visual shots back to source text. This script domain feeds shot association rather than directly driving rendering.

#### Asset Acquisition and Scene Construction
The asset subsystem imports local OBJ/GLB models through registered loaders (`src/Asset/LoaderRegistry.cpp`, `src/Asset/ObjLoader.cpp`, `src/Asset/GlbLoader.cpp`) into the asset library (`src/Asset/Library.cpp`). It also manages an official catalog and downloads through the HTTP abstraction: `src/Asset/OfficialCatalog.cpp`, `include/DirectorDesk/Platform/IHttpClient.h`, and the curl implementation `backends/curl/CurlHttpClient.cpp`. Scene state is represented separately by `src/Scene/Document.cpp` and transforms in `src/Scene/Transform.cpp`.

#### Camera, Links, and Storyboard Assembly
Camera authoring is managed through orbit controls and reusable presets in `src/Camera/CameraManager.cpp`, `src/Camera/OrbitCamera.cpp`, and `src/Camera/Presets.cpp`. `src/Link/ShotLink.cpp` binds script-shot IDs to scene/camera information. The storyboard domain then composes linked shots into board documents and layouts via `src/Storyboard/Document.cpp`, `src/Storyboard/BoardComposer.cpp`, and `src/Storyboard/Layout.cpp`.

#### UI and Rendering Boundary
ImGui panels expose the workflow: library, script, workspace, and storyboard panels in `src/UI/LibraryPanel.cpp`, `src/UI/ScriptPanel.cpp`, and `src/UI/WorkspacePanel.cpp`. UI and domain code depend on renderer interfaces (`include/DirectorDesk/Renderer/IRenderer.h`), while concrete graphics/window backends are isolated in `backends/bgfx/BgfxRenderer.cpp`, `backends/glfw/GlfwWindow.cpp`, and `backends/imgui/ImGuiGlfwBackend.cpp`. Mesh and ImGui shaders originate in `shaders/mesh/` and `shaders/imgui/`, compiled by CMake.

#### Export and Service Extension Points
Storyboard/shot output is exported as PNG through `src/Export/ShotExport.cpp` and `src/Renderer/PngWriter.cpp`. AI image/video generation is intentionally interface-driven rather than coupled to a provider: `include/DirectorDesk/AI/IImageGenService.h`, `include/DirectorDesk/AI/IVideoGenService.h`, with current mock/null implementations in `src/AI/`. Background work and UI-safe result handoff use platform workers plus core command/result queues (`src/Platform/Worker.cpp`, `include/DirectorDesk/Core/CommandQueue.h`).

#### Runtime and Delivery
Supported desktop targets are Windows 10/11 and macOS. The build is CMake/vcpkg based (`CMakeLists.txt`, `CMakePresets.json`, `vcpkg.json`), using GLFW, bgfx, ImGui, curl, and shaderc-related shader compilation. Windows packaging is an Inno Setup installer under `packaging/windows/DirectorDesk.iss`.

Main entry points: [`src/App/Application.cpp`](https://github.com/wisdom-km/mira_new/blob/main/src/App/Application.cpp) (Application loop), [`src/UI/WorkspacePanel.cpp`](https://github.com/wisdom-km/mira_new/blob/main/src/UI/WorkspacePanel.cpp) (ImGui workflow panels), [`src/App/ProjectFile.cpp`](https://github.com/wisdom-km/mira_new/blob/main/src/App/ProjectFile.cpp) (Project persistence), [`src/Script/Document.cpp`](https://github.com/wisdom-km/mira_new/blob/main/src/Script/Document.cpp) (Script document)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Desktop entry point<br/>C++ executable<br/>[main.cpp]"]
  node_application["Application loop<br/>application coordinator<br/>[Application.cpp]"]
  node_project["Project persistence<br/>project binding<br/>[ProjectFile.cpp]"]
  node_ui_panels["ImGui workflow panels<br/>desktop UI<br/>[WorkspacePanel.cpp]"]
end

subgraph group_domain["Authoring Domains"]
  node_script["Script document<br/>Markdown script domain<br/>[Document.cpp]"]
  node_script_parser["Markdown parser<br/>script parser<br/>[Parser.cpp]"]
  node_shot_link["Shot links<br/>script-to-shot binding<br/>[ShotLink.cpp]"]
  node_storyboard["Storyboard composer<br/>board assembly<br/>[BoardComposer.cpp]"]
  node_camera["Camera authoring<br/>camera presets and controls<br/>[CameraManager.cpp]"]
end

subgraph group_assets["Assets and Scene"]
  node_asset_library[("Asset library<br/>asset catalog<br/>[Library.cpp]")]
  node_asset_loaders["Model importers<br/>OBJ/GLB loader registry<br/>[LoaderRegistry.cpp]"]
  node_official_catalog["Official asset catalog<br/>remote asset acquisition"]
  node_scene["Scene document<br/>scene state<br/>[Document.cpp]"]
end

subgraph group_platform["Platform and Rendering"]
  node_renderer_api{{"Renderer interface<br/>rendering contract<br/>[IRenderer.h]"}}
  node_graphics_backend["bgfx renderer<br/>graphics backend<br/>[BgfxRenderer.cpp]"]
  node_window_backend["GLFW window backend<br/>window platform backend<br/>[GlfwWindow.cpp]"]
  node_async_work["Background work queues<br/>worker and UI handoff<br/>[Worker.cpp]"]
  node_http_client{{"HTTP client contract<br/>network abstraction<br/>[IHttpClient.h]"}}
  node_curl_http["curl HTTP backend<br/>HTTP implementation<br/>[CurlHttpClient.cpp]"]
end

subgraph group_extension["Export and Services"]
  node_export["PNG shot export<br/>storyboard export<br/>[ShotExport.cpp]"]
  node_ai_services{{"AI generation services<br/>image/video service contracts<br/>[IImageGenService.h]"}}
end

node_main -->|"starts"| node_application
node_application -->|"loads"| node_project
node_project -->|"persists"| node_script
node_project -->|"persists"| node_scene
node_project -->|"persists"| node_storyboard
node_script_parser -->|"parses into"| node_script
node_script -->|"stable IDs"| node_shot_link
node_scene -->|"scene binding"| node_shot_link
node_camera -->|"camera binding"| node_shot_link
node_shot_link -->|"linked shots"| node_storyboard
node_asset_loaders -->|"imports models"| node_asset_library
node_asset_library -->|"supplies assets"| node_scene
node_official_catalog -->|"acquires assets"| node_asset_library
node_official_catalog -->|"downloads via"| node_http_client
node_curl_http -->|"implements"| node_http_client
node_application -->|"hosts"| node_ui_panels
node_ui_panels -->|"edits"| node_script
node_ui_panels -->|"edits"| node_scene
node_ui_panels -->|"edits"| node_storyboard
node_ui_panels -->|"renders through"| node_renderer_api
node_graphics_backend -->|"implements"| node_renderer_api
node_application -->|"creates window"| node_window_backend
node_application -->|"dispatches"| node_async_work
node_storyboard -->|"exports shots"| node_export
node_application -.->|"invokes"| node_ai_services

click node_main "https://github.com/wisdom-km/mira_new/blob/main/src/App/main.cpp"
click node_application "https://github.com/wisdom-km/mira_new/blob/main/src/App/Application.cpp"
click node_project "https://github.com/wisdom-km/mira_new/blob/main/src/App/ProjectFile.cpp"
click node_script "https://github.com/wisdom-km/mira_new/blob/main/src/Script/Document.cpp"
click node_script_parser "https://github.com/wisdom-km/mira_new/blob/main/src/Script/Parser.cpp"
click node_shot_link "https://github.com/wisdom-km/mira_new/blob/main/src/Link/ShotLink.cpp"
click node_storyboard "https://github.com/wisdom-km/mira_new/blob/main/src/Storyboard/BoardComposer.cpp"
click node_camera "https://github.com/wisdom-km/mira_new/blob/main/src/Camera/CameraManager.cpp"
click node_asset_library "https://github.com/wisdom-km/mira_new/blob/main/src/Asset/Library.cpp"
click node_asset_loaders "https://github.com/wisdom-km/mira_new/blob/main/src/Asset/LoaderRegistry.cpp"
click node_official_catalog "https://github.com/wisdom-km/mira_new/blob/main/src/Asset/OfficialCatalog.cpp"
click node_scene "https://github.com/wisdom-km/mira_new/blob/main/src/Scene/Document.cpp"
click node_ui_panels "https://github.com/wisdom-km/mira_new/blob/main/src/UI/WorkspacePanel.cpp"
click node_renderer_api "https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/Renderer/IRenderer.h"
click node_graphics_backend "https://github.com/wisdom-km/mira_new/blob/main/backends/bgfx/BgfxRenderer.cpp"
click node_window_backend "https://github.com/wisdom-km/mira_new/blob/main/backends/glfw/GlfwWindow.cpp"
click node_async_work "https://github.com/wisdom-km/mira_new/blob/main/src/Platform/Worker.cpp"
click node_export "https://github.com/wisdom-km/mira_new/blob/main/src/Export/ShotExport.cpp"
click node_ai_services "https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/AI/IImageGenService.h"
click node_http_client "https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/Platform/IHttpClient.h"
click node_curl_http "https://github.com/wisdom-km/mira_new/blob/main/backends/curl/CurlHttpClient.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_application,node_project,node_ui_panels toneBlue
class node_script,node_script_parser,node_shot_link,node_storyboard,node_camera toneAmber
class node_asset_library,node_asset_loaders,node_official_catalog,node_scene toneMint
class node_renderer_api,node_graphics_backend,node_window_backend,node_async_work,node_http_client,node_curl_http toneRose
class node_export,node_ai_services toneIndigo
```

## Components

### Application

- [Desktop entry point](https://github.com/wisdom-km/mira_new/blob/main/src/App/main.cpp): C++ executable · `src/App/main.cpp`
- [Application loop](https://github.com/wisdom-km/mira_new/blob/main/src/App/Application.cpp): application coordinator · Coordinates projects, panels, rendering, and async work. · `src/App/Application.cpp`
- [Project persistence](https://github.com/wisdom-km/mira_new/blob/main/src/App/ProjectFile.cpp): project binding · Loads .ddproj state and binds documents. · `src/App/ProjectFile.cpp`
- [ImGui workflow panels](https://github.com/wisdom-km/mira_new/blob/main/src/UI/WorkspacePanel.cpp): desktop UI · Library, script, workspace, and storyboard editing surfaces. · `src/UI/WorkspacePanel.cpp`

### Authoring Domains

- [Script document](https://github.com/wisdom-km/mira_new/blob/main/src/Script/Document.cpp): Markdown script domain · Parses Markdown and maintains stable source IDs. · `src/Script/Document.cpp`
- [Markdown parser](https://github.com/wisdom-km/mira_new/blob/main/src/Script/Parser.cpp): script parser · `src/Script/Parser.cpp`
- [Shot links](https://github.com/wisdom-km/mira_new/blob/main/src/Link/ShotLink.cpp): script-to-shot binding · Associates script IDs with scene and camera state. · `src/Link/ShotLink.cpp`
- [Storyboard composer](https://github.com/wisdom-km/mira_new/blob/main/src/Storyboard/BoardComposer.cpp): board assembly · Composes linked shots into board documents and layouts. · `src/Storyboard/BoardComposer.cpp`
- [Camera authoring](https://github.com/wisdom-km/mira_new/blob/main/src/Camera/CameraManager.cpp): camera presets and controls · `src/Camera/CameraManager.cpp`

### Assets and Scene

- [Asset library](https://github.com/wisdom-km/mira_new/blob/main/src/Asset/Library.cpp): asset catalog · `src/Asset/Library.cpp`
- [Model importers](https://github.com/wisdom-km/mira_new/blob/main/src/Asset/LoaderRegistry.cpp): OBJ/GLB loader registry · `src/Asset/LoaderRegistry.cpp`
- [Official asset catalog](https://github.com/wisdom-km/mira_new/blob/main/src/Asset/OfficialCatalog.cpp): remote asset acquisition · `src/Asset/OfficialCatalog.cpp`
- [Scene document](https://github.com/wisdom-km/mira_new/blob/main/src/Scene/Document.cpp): scene state · Maintains scene objects and transforms. · `src/Scene/Document.cpp`

### Platform and Rendering

- [Renderer interface](https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/Renderer/IRenderer.h): rendering contract · `include/DirectorDesk/Renderer/IRenderer.h`
- [bgfx renderer](https://github.com/wisdom-km/mira_new/blob/main/backends/bgfx/BgfxRenderer.cpp): graphics backend · `backends/bgfx/BgfxRenderer.cpp`
- [GLFW window backend](https://github.com/wisdom-km/mira_new/blob/main/backends/glfw/GlfwWindow.cpp): window platform backend · `backends/glfw/GlfwWindow.cpp`
- [Background work queues](https://github.com/wisdom-km/mira_new/blob/main/src/Platform/Worker.cpp): worker and UI handoff · Runs work off-thread and returns UI-safe results. · `src/Platform/Worker.cpp`
- [HTTP client contract](https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/Platform/IHttpClient.h): network abstraction · `include/DirectorDesk/Platform/IHttpClient.h`
- [curl HTTP backend](https://github.com/wisdom-km/mira_new/blob/main/backends/curl/CurlHttpClient.cpp): HTTP implementation · `backends/curl/CurlHttpClient.cpp`

### Export and Services

- [PNG shot export](https://github.com/wisdom-km/mira_new/blob/main/src/Export/ShotExport.cpp): storyboard export · `src/Export/ShotExport.cpp`
- [AI generation services](https://github.com/wisdom-km/mira_new/blob/main/include/DirectorDesk/AI/IImageGenService.h): image/video service contracts · Provider-independent image and video generation extension points. · `include/DirectorDesk/AI/IImageGenService.h`

## Connections

- Desktop entry point → Application loop: starts
- Application loop → Project persistence: loads
- Project persistence → Script document: persists
- Project persistence → Scene document: persists
- Project persistence → Storyboard composer: persists
- Markdown parser → Script document: parses into
- Script document → Shot links: stable IDs
- Scene document → Shot links: scene binding
- Camera authoring → Shot links: camera binding
- Shot links → Storyboard composer: linked shots
- Model importers → Asset library: imports models
- Asset library → Scene document: supplies assets
- Official asset catalog → Asset library: acquires assets
- Official asset catalog → HTTP client contract: downloads via
- curl HTTP backend → HTTP client contract: implements
- Application loop → ImGui workflow panels: hosts
- ImGui workflow panels → Script document: edits
- ImGui workflow panels → Scene document: edits
- ImGui workflow panels → Storyboard composer: edits
- ImGui workflow panels → Renderer interface: renders through
- bgfx renderer → Renderer interface: implements
- Application loop → GLFW window backend: creates window
- Application loop → Background work queues: dispatches
- Storyboard composer → PNG shot export: exports shots
- Application loop → AI generation services: invokes
