# ttktjmt/muwanx architecture

> Architecture diagram of the GitHub repository ttktjmt/muwanx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ttktjmt/muwanx
- Repository: https://github.com/ttktjmt/muwanx

## Overview

##### Project type and purpose
- Muwanx is a client-only, full-stack-in-the-browser application: a static Vue.js SPA that runs MuJoCo physics simulations and ONNX policy inference entirely in the browser.

##### File structure
- Top-level:
- public/ – static assets (config.json, scene XMLs, ONNX checkpoints, meshes) served over HTTP
- src/ – application source
– App.vue + main.js – Vue.js entrypoint registering plugins (router, Vuetify)
– plugins/ – Vue router & UI framework setup
– views/demo/ – component tree for the interactive demo
– composables/ – custom Vue Composition API hooks for config, runtime, scene/policy management
– mujoco_wasm/ – embedded MuJoCo WebAssembly module, JS bindings, managers (actions, commands, environment, observations), utils (Debug, onnxHelper, mujocoScene)
- docs/ – documentation for extending/custom content
- tests/ – simple asset-collector and YAML mapping tests
- CI (deploy.yml) – GitHub Actions for building & deploying to GitHub Pages

##### README for additional insights
- Confirms tech stack: Vue 3 SPA, MuJoCo WASM (DeepMind’s wasm port), ONNX Runtime in-browser
- Highlights features: real-time simulation, interactive controls, policy loading, no server dependency
- Use cases: embed demos, rapid RL prototyping, shareable static site

##### Main components and their interactions
a. Frontend UI Layer
- Vue.js SPA (App.vue, router, Vuetify)
- Demo view & subcomponents for scene/policy selection, control panels, force/trajectory editors
- Composables orchestrating state: useConfig, useRuntime, useScenePolicy, etc.
b. Asset & Configuration Layer
- HTTP static server (serving public/)
- Config JSONs (public/config_*.json) and scene XMLs + meshes + ONNX checkpoints
c. Simulation Engine Layer
- MuJoCo WASM binary + JS binding (src/mujoco_wasm/dist/*.wasm + MujocoRuntime.js)
- Managers: command, action, environment, observation
- mujocoScene utility to translate simulation state to WebGL scene graph
d. Inference Layer
- ONNX Runtime Web (via onnxHelper.js) loaded at runtime, consuming ONNX policy files to output action vectors
e. Rendering Layer
- Three.js (implicitly via mujocoScene utils) for drawing meshes and joints, updated each simulation frame
f. Interaction Layer
- DragStateManager, Debug, Reflector utilities for user input & debugging overlays
g. Routing & Plugin Layer
- Vue Router for URL-based scene selection (e.g., #/myosuite)
- Vuetify plugin for UI styling

##### Architectural patterns & design principles
- Component-based UI (Vue single-file components, composables)
- Layered separation: UI ↔ Simulation Engine ↔ Physics WASM ↔ Inference Engine ↔ Assets
- Plugin/module pattern for extending new scenes or policies (docs/ADDING_CUSTOM_CONTENT.md)
- Composition API hooks encapsulate side effects (loading, physics loop, URL sync)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interaction
    User["User"]:::external
    User -->|"interacts"| Entr

    subgraph "Browser UI Layer"
        direction TB
        Entr["Entrypoint (App.vue + main.js)"]:::frontend
        Router["Vue Router Plugin"]:::frontend
        Vuetify["Vuetify Plugin"]:::frontend
        subgraph "Demo View & Components"
            direction TB
            Demo["Demo.vue"]:::frontend
            CommandControls["CommandControls.vue"]:::frontend
            ControlPanel["ControlPanel.vue"]:::frontend
            ForceControls["ForceControls.vue"]:::frontend
            HelpDialog["HelpDialog.vue"]:::frontend
            Notice["Notice.vue"]:::frontend
            PolicySelector["PolicySelector.vue"]:::frontend
            ProjectSelector["ProjectSelector.vue"]:::frontend
            SceneSelector["SceneSelector.vue"]:::frontend
            StatusDialogs["StatusDialogs.vue"]:::frontend
            StatusOverlay["StatusOverlay.vue"]:::frontend
            StiffnessControls["StiffnessControls.vue"]:::frontend
            TrajectoryControls["TrajectoryControls.vue"]:::frontend
        end
    end

    subgraph "Composables & State Orchestration"
        direction TB
        useConfig["useConfig.ts"]:::frontend
        useResponsive["useResponsive.ts"]:::frontend
        useRuntime["useRuntime.ts"]:::frontend
        useScenePolicy["useScenePolicy.ts"]:::frontend
        useTransition["useTransition.ts"]:::frontend
        useUrlSync["useUrlSync.ts"]:::frontend
    end

    subgraph "Simulation & Inference Engines"
        direction TB
        Runtime["MujocoRuntime.js"]:::engine
        WASM["MuJoCo WASM Module"]:::engine
        ONNXHelper["onnxHelper.js"]:::engine
        ONNXRuntime["ONNX Runtime Web"]:::external
        subgraph "Managers"
            direction TB
            BaseManager["BaseManager.js"]:::engine
            IsaacActionManager["IsaacActionManager.js"]:::engine
            PassiveActionManager["PassiveActionManager.js"]:::engine
            TrajectoryActionManager["TrajectoryActionManager.js"]:::engine
            GoCommandManager["GoCommandManager.js"]:::engine
            LocomotionEnvManager["LocomotionEnvManager.js"]:::engine
            ConfigObservationManager["ConfigObservationManager.js"]:::engine
        end
    end

    subgraph "Rendering Pipeline"
        direction TB
        mujocoScene["mujocoScene.js (Three.js)"]:::engine
        WebGL["WebGL Renderer"]:::external
        mujocoScene -->|renders scene| WebGL
    end

    subgraph "Static Asset Store"
        direction TB
        Configs["Config JSONs"]:::assets
        Scenes["Scene Assets"]:::assets
        Checkpoints["Policy Checkpoints"]:::assets
    end

    %% Data Flows
    Entr --> Router
    Entr --> Vuetify
    Entr --> Demo
    Demo -->|loads state| useConfig
    Demo -->|interacts| useRuntime
    Demo -->|selects scene/policy| useScenePolicy

    useConfig -->|fetch config| Configs
    useScenePolicy -->|fetch scene| Scenes
    useScenePolicy -->|fetch ONNX model| Checkpoints

    useRuntime -->|initialize| Runtime
    useScenePolicy -->|policy data| ONNXHelper
    ONNXHelper -->|invoke| ONNXRuntime
    ONNXRuntime -->|action vector| useRuntime
    useRuntime -->|step physics| Runtime
    Runtime -->|call| WASM
    Runtime -->|state| mujocoScene

    %% Click Events
    click Entr "https://github.com/ttktjmt/muwanx/blob/main/src/App.vue"
    click Entr "https://github.com/ttktjmt/muwanx/blob/main/src/main.js"
    click Router "https://github.com/ttktjmt/muwanx/blob/main/src/plugins/router.js"
    click Vuetify "https://github.com/ttktjmt/muwanx/blob/main/src/plugins/vuetify.js"
    click Demo "https://github.com/ttktjmt/muwanx/blob/main/src/views/Demo.vue"
    click CommandControls "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/CommandControls.vue"
    click ControlPanel "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/ControlPanel.vue"
    click ForceControls "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/ForceControls.vue"
    click HelpDialog "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/HelpDialog.vue"
    click Notice "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/Notice.vue"
    click PolicySelector "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/PolicySelector.vue"
    click ProjectSelector "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/ProjectSelector.vue"
    click SceneSelector "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/SceneSelector.vue"
    click StatusDialogs "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/StatusDialogs.vue"
    click StatusOverlay "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/StatusOverlay.vue"
    click StiffnessControls "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/StiffnessControls.vue"
    click TrajectoryControls "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/components/TrajectoryControls.vue"
    click useConfig "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useConfig.ts"
    click useResponsive "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useResponsive.ts"
    click useRuntime "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useRuntime.ts"
    click useScenePolicy "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useScenePolicy.ts"
    click useTransition "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useTransition.ts"
    click useUrlSync "https://github.com/ttktjmt/muwanx/blob/main/src/views/demo/composables/useUrlSync.ts"
    click WASM "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/dist/mujoco_wasm.wasm"
    click Runtime "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/MujocoRuntime.js"
    click BaseManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/BaseManager.js"
    click IsaacActionManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/actions/IsaacActionManager.js"
    click PassiveActionManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/actions/PassiveActionManager.js"
    click TrajectoryActionManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/actions/TrajectoryActionManager.js"
    click GoCommandManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/commands/GoCommandManager.js"
    click LocomotionEnvManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/environment/LocomotionEnvManager.js"
    click ConfigObservationManager "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/managers/observations/ConfigObservationManager.js"
    click ONNXHelper "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/utils/onnxHelper.js"
    click mujocoScene "https://github.com/ttktjmt/muwanx/blob/main/src/mujoco_wasm/runtime/utils/mujocoScene.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef engine fill:#d4edda,stroke:#333,stroke-width:1px
    classDef assets fill:#f0f0f0,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
```
