# yell0wsuit/cuttherope-dx architecture

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

- Interactive diagram: https://gitdiagram.com/yell0wsuit/cuttherope-dx
- Repository: https://github.com/yell0wsuit/cuttherope-dx

## Overview

#### Purpose and entry points
Cut the Rope: DX is a .NET 10 fan-maintained enhancement of the original PC puzzle game. The solution separates reusable game logic from desktop and WebAssembly hosts. Main executables are `src/CutTheRopeDX.Desktop/Program.cs`, `src/CutTheRopeDX.Browser/Program.cs`, and the graphics-backend launcher `src/CutTheRopeDX.Launcher/Program.cs`. Content acquisition/building is a separate CLI at `content/Builder/Program.cs`.

#### Core bootstrap and application control
The core project owns startup, global application state, navigation, save/progress behavior, and resource initialization. `src/CutTheRopeDX.Core/CtrBootstrap.cs` wires host-provided services into the game; `src/CutTheRopeDX.Core/Commons/CTRApp.cs` and `src/CutTheRopeDX.Core/GameMain/CTRRootController.cs` coordinate high-level screens. Startup generally transitions through loading/menu controllers into a gameplay scene, while command-line custom-level mode bypasses normal menu/progress flow.
- `src/CutTheRopeDX.Core/GameMain/StartupController.cs`
- `src/CutTheRopeDX.Core/GameMain/LoadingController.cs`
- `src/CutTheRopeDX.Core/GameMain/CommandLine.cs`

#### Framework boundary: platform-neutral game engine
`CutTheRopeDX.Core` defines its own UI, rendering, input, resource, media, and platform abstractions rather than directly depending on a desktop or browser runtime. Host implementations are injected through `PlatformServices`; interfaces isolate content storage, graphics, preferences, windows, updates, cursors, rich presence, and assets. Core owns view/controller hierarchy, responsive viewport calculations, animation, and lightweight constraint-based physics.
- `src/CutTheRopeDX.Core/Framework/Platform/PlatformServices.cs`
- `src/CutTheRopeDX.Core/Framework/Core/Application.cs`
- `src/CutTheRopeDX.Core/Framework/Physics/ConstraintSystem.cs`

#### Level ingestion and gameplay simulation
Pack metadata and XML map files are data inputs; `GameScene` loads map metadata and object definitions into the active simulation. Its partial files divide initialization, input, object loading, updates, collisions, drawing, and end-of-level behavior. Object loaders map level XML entities to gameplay systems such as ropes, candy, targets, bubbles, hazards, and transport devices. Input gestures alter scene objects, physics advances state, collisions/outcomes determine stars and level result, then controller flow presents replay/progression.
- `src/CutTheRopeDX.Core/GameMain/GameScene.cs`
- `src/CutTheRopeDX.Core/GameMain/GameScene.LoadObjects.cs`
- `content/maps/1_1.xml`

#### Rendering, assets, and authored content
The resource manager reads content via an abstract store and parses TexturePacker-style JSON atlases, Flash XML animations, fonts, localized strings, and maps. Visual elements emit renderer operations through the platform render backend. The repository’s `content/` directory is the authored game-data boundary: maps are XML; image/animation descriptors are JSON/XML; translations are JSON. Content pack selection is governed by pack manifests.
- `src/CutTheRopeDX.Core/Framework/Core/ResourceMgr.cs`
- `src/CutTheRopeDX.Core/Framework/Core/TexturePackerAtlasParser.cs`
- `content/packlist.json`

#### Desktop runtime and distribution
The desktop host uses MonoGame for the window, rendering, texture/audio integration, and game loop. It supplies file-backed content, save preferences, file watching for custom-level reloads, update checks, and optional Discord Rich Presence. Video backend selection supports FFmpeg generally and AVFoundation on applicable macOS builds. Release scripts package Windows, macOS, Linux AppImage, and Debian artifacts.
- `src/CutTheRopeDX.Desktop/Game1.cs`
- `src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs`
- `src/CutTheRopeDX.Desktop/Framework/Media/VideoPlayerBackendSelector.cs`

#### Browser runtime and offline delivery
The browser project is a WebAssembly host using Skia rendering, Web Audio, JavaScript interop, fetch-backed content, browser input, and `localStorage` preferences. It is a static PWA with service-worker caching, so its external runtime boundary is the browser platform rather than a server. Browser-specific content is preconverted from source assets by Python plus NuGet-provisioned FFmpeg; GitHub Pages deployment publishes `wwwroot`.
- `src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs`
- `src/CutTheRopeDX.Browser/Browser/SkiaRenderBackend.cs`
- `src/CutTheRopeDX.Browser/wwwroot/service-worker.js`

#### Content pipeline and external dependencies
The content builder manages archived/downloaded assets and manifests, while the browser conversion pipeline transcodes images, audio, videos, and fonts to web formats. Material infrastructure includes .NET SDK/WebAssembly tooling, Python 3.11+, FFmpeg, MonoGame, Skia, browser APIs, GitHub Actions/Pages, and optional Discord IPC.
- `content/Builder/Builder.cs`
- `content/Builder/Assets/AssetDownloader.cs`
- `scripts/build_web_content.py`

Main entry points: [`src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs`](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs) (MonoGame desktop host), [`src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs`](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs) (Browser host), [`src/CutTheRopeDX.Core/CtrBootstrap.cs`](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/CtrBootstrap.cs) (Core bootstrap), [`content/packlist.json`](https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/packlist.json) (Game content packs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hosts["Runtime Hosts"]
  node_desktop_program["Desktop entry point<br/>executable<br/>[Program.cs]"]
  node_desktop_host["MonoGame desktop host<br/>host adapter<br/>[DesktopHostApp.cs]"]
  node_desktop_game["Desktop game runtime<br/>MonoGame runtime<br/>[Game1.cs]"]
  node_video_backend["Video backend selection<br/>media adapter"]
  node_browser_program["Browser entry point<br/>WASM executable<br/>[Program.cs]"]
  node_browser_host["Browser host<br/>WASM host adapter<br/>[BrowserHostApp.cs]"]
  node_skia_renderer["Skia renderer<br/>render backend"]
  node_launcher["Graphics launcher<br/>executable<br/>[Program.cs]"]
end

subgraph group_core["Core Game"]
  node_bootstrap["Core bootstrap<br/>composition root<br/>[CtrBootstrap.cs]"]
  node_platform_services{{"Platform services<br/>abstraction boundary"}}
  node_application["Application framework<br/>app lifecycle<br/>[Application.cs]"]
  node_app_control["App and root control<br/>navigation state<br/>[CTRApp.cs]"]
  node_root_controller["Root controller<br/>screen coordinator"]
  node_startup_flow["Startup and loading<br/>controller flow"]
  node_game_scene["Gameplay scene<br/>simulation scene<br/>[GameScene.cs]"]
  node_physics["Constraint physics<br/>physics engine"]
  node_resources["Resource manager<br/>asset loader<br/>[ResourceMgr.cs]"]
end

subgraph group_content["Content Pipeline"]
  node_authored_content["Game content packs<br/>authored data<br/>[packlist.json]"]
  node_content_builder["Content builder CLI<br/>asset acquisition CLI<br/>[Program.cs]"]
  node_asset_downloader["Asset downloader<br/>content acquisition<br/>[AssetDownloader.cs]"]
  node_web_conversion["Web content conversion<br/>asset transcode pipeline"]
end

subgraph group_delivery["Web Delivery"]
  node_service_worker["PWA service worker<br/>offline cache<br/>[service-worker.js]"]
end

node_desktop_program -->|"starts"| node_desktop_host
node_desktop_host -->|"runs"| node_desktop_game
node_desktop_host -->|"injects services"| node_bootstrap
node_desktop_host -->|"uses"| node_video_backend
node_browser_program -->|"starts"| node_browser_host
node_browser_host -->|"injects services"| node_bootstrap
node_browser_host -->|"renders through"| node_skia_renderer
node_launcher -->|"launches"| node_desktop_program
node_bootstrap -->|"binds"| node_platform_services
node_bootstrap -->|"initializes"| node_application
node_application -->|"hosts"| node_app_control
node_app_control -->|"coordinates"| node_root_controller
node_root_controller -->|"begins with"| node_startup_flow
node_startup_flow -->|"opens gameplay"| node_game_scene
node_game_scene -->|"advances constraints"| node_physics
node_game_scene -->|"loads maps and objects"| node_resources
node_resources -->|"reads"| node_authored_content
node_content_builder -->|"acquires assets"| node_asset_downloader
node_content_builder -->|"builds packs"| node_authored_content
node_web_conversion -->|"converts assets for web"| node_authored_content
node_browser_host -->|"delivered offline by"| node_service_worker
node_service_worker -.->|"caches web content"| node_authored_content

click node_desktop_program "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Program.cs"
click node_desktop_host "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs"
click node_desktop_game "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Game1.cs"
click node_video_backend "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Framework/Media/VideoPlayerBackendSelector.cs"
click node_browser_program "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Program.cs"
click node_browser_host "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs"
click node_skia_renderer "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Browser/SkiaRenderBackend.cs"
click node_launcher "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Launcher/Program.cs"
click node_bootstrap "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/CtrBootstrap.cs"
click node_platform_services "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Platform/PlatformServices.cs"
click node_application "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Core/Application.cs"
click node_app_control "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Commons/CTRApp.cs"
click node_root_controller "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/CTRRootController.cs"
click node_startup_flow "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/StartupController.cs"
click node_game_scene "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/GameScene.cs"
click node_physics "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Physics/ConstraintSystem.cs"
click node_resources "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Core/ResourceMgr.cs"
click node_authored_content "https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/packlist.json"
click node_content_builder "https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/Builder/Program.cs"
click node_asset_downloader "https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/Builder/Assets/AssetDownloader.cs"
click node_web_conversion "https://github.com/yell0wsuit/cuttherope-dx/blob/main/scripts/build_web_content.py"
click node_service_worker "https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/wwwroot/service-worker.js"

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_desktop_program,node_desktop_host,node_desktop_game,node_video_backend,node_browser_program,node_browser_host,node_skia_renderer,node_launcher toneBlue
class node_bootstrap,node_platform_services,node_application,node_app_control,node_root_controller,node_startup_flow,node_game_scene,node_physics,node_resources toneAmber
class node_authored_content,node_content_builder,node_asset_downloader,node_web_conversion toneMint
class node_service_worker toneRose
```

## Components

### Runtime Hosts

- [Desktop entry point](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Program.cs): executable · `src/CutTheRopeDX.Desktop/Program.cs`
- [MonoGame desktop host](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs): host adapter · Provides windowing, game loop, local storage, and desktop integrations. · `src/CutTheRopeDX.Desktop/Desktop/DesktopHostApp.cs`
- [Desktop game runtime](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Game1.cs): MonoGame runtime · `src/CutTheRopeDX.Desktop/Game1.cs`
- [Video backend selection](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Desktop/Framework/Media/VideoPlayerBackendSelector.cs): media adapter · Selects FFmpeg or macOS AVFoundation playback. · `src/CutTheRopeDX.Desktop/Framework/Media/VideoPlayerBackendSelector.cs`
- [Browser entry point](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Program.cs): WASM executable · `src/CutTheRopeDX.Browser/Program.cs`
- [Browser host](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs): WASM host adapter · Bridges browser APIs, fetch content, input, audio, and localStorage. · `src/CutTheRopeDX.Browser/Browser/BrowserHostApp.cs`
- [Skia renderer](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/Browser/SkiaRenderBackend.cs): render backend · `src/CutTheRopeDX.Browser/Browser/SkiaRenderBackend.cs`
- [Graphics launcher](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Launcher/Program.cs): executable · `src/CutTheRopeDX.Launcher/Program.cs`

### Core Game

- [Core bootstrap](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/CtrBootstrap.cs): composition root · Wires injected host services into the game. · `src/CutTheRopeDX.Core/CtrBootstrap.cs`
- [Platform services](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Platform/PlatformServices.cs): abstraction boundary · Interfaces for storage, rendering, preferences, windows, media, and platform features. · `src/CutTheRopeDX.Core/Framework/Platform/PlatformServices.cs`
- [Application framework](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Core/Application.cs): app lifecycle · `src/CutTheRopeDX.Core/Framework/Core/Application.cs`
- [App and root control](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Commons/CTRApp.cs): navigation state · Coordinates global state, screens, saves, and progression. · `src/CutTheRopeDX.Core/Commons/CTRApp.cs`
- [Root controller](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/CTRRootController.cs): screen coordinator · `src/CutTheRopeDX.Core/GameMain/CTRRootController.cs`
- [Startup and loading](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/StartupController.cs): controller flow · Transitions to menu or command-line custom-level gameplay. · `src/CutTheRopeDX.Core/GameMain/StartupController.cs`
- [Gameplay scene](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/GameMain/GameScene.cs): simulation scene · Loads level objects, handles gestures, updates gameplay, collisions, drawing, and results. · `src/CutTheRopeDX.Core/GameMain/GameScene.cs`
- [Constraint physics](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Physics/ConstraintSystem.cs): physics engine · `src/CutTheRopeDX.Core/Framework/Physics/ConstraintSystem.cs`
- [Resource manager](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Core/Framework/Core/ResourceMgr.cs): asset loader · Loads atlases, animations, fonts, strings, and maps through abstract content storage. · `src/CutTheRopeDX.Core/Framework/Core/ResourceMgr.cs`

### Content Pipeline

- [Game content packs](https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/packlist.json): authored data · Pack manifests select XML maps, visual assets, and localized data. · `content/packlist.json`
- [Content builder CLI](https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/Builder/Program.cs): asset acquisition CLI · Builds manifests and manages archived or downloaded source assets. · `content/Builder/Program.cs`
- [Asset downloader](https://github.com/yell0wsuit/cuttherope-dx/blob/main/content/Builder/Assets/AssetDownloader.cs): content acquisition · `content/Builder/Assets/AssetDownloader.cs`
- [Web content conversion](https://github.com/yell0wsuit/cuttherope-dx/blob/main/scripts/build_web_content.py): asset transcode pipeline · Python and FFmpeg convert source media into browser-ready formats. · `scripts/build_web_content.py`

### Web Delivery

- [PWA service worker](https://github.com/yell0wsuit/cuttherope-dx/blob/main/src/CutTheRopeDX.Browser/wwwroot/service-worker.js): offline cache · `src/CutTheRopeDX.Browser/wwwroot/service-worker.js`

## Connections

- Desktop entry point → MonoGame desktop host: starts
- MonoGame desktop host → Desktop game runtime: runs
- MonoGame desktop host → Core bootstrap: injects services
- MonoGame desktop host → Video backend selection: uses
- Browser entry point → Browser host: starts
- Browser host → Core bootstrap: injects services
- Browser host → Skia renderer: renders through
- Graphics launcher → Desktop entry point: launches
- Core bootstrap → Platform services: binds
- Core bootstrap → Application framework: initializes
- Application framework → App and root control: hosts
- App and root control → Root controller: coordinates
- Root controller → Startup and loading: begins with
- Startup and loading → Gameplay scene: opens gameplay
- Gameplay scene → Constraint physics: advances constraints
- Gameplay scene → Resource manager: loads maps and objects
- Resource manager → Game content packs: reads
- Content builder CLI → Asset downloader: acquires assets
- Content builder CLI → Game content packs: builds packs
- Web content conversion → Game content packs: converts assets for web
- Browser host → PWA service worker: delivered offline by
- PWA service worker → Game content packs: caches web content
