# modinmobilests/slaytheamethystmodded architecture

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

- Interactive diagram: https://gitdiagram.com/modinmobilests/slaytheamethystmodded
- Repository: https://github.com/modinmobilests/slaytheamethystmodded

## Overview

1. **Repository shape**
   - This is a multi-module Android launcher ecosystem for modded Slay the Spire.
   - The central product is `app/`, surrounded by a Java bridge jar (`boot-bridge/`), runtime compatibility patches (`patches/gdx-patch/`), native/JNI code, several auxiliary backend services, and a few standalone tooling modules.

2. **Primary runtime boundary: Android launcher vs game runtime**
   - `app/` is the Android UI and orchestration layer.
   - It does not run the game logic itself; instead it prepares a JavaSE runtime, native libraries, patched game jars, and then launches the Slay the Spire desktop runtime inside an Android process model.
   - The key architectural boundary is between Android-managed launcher state and the embedded Java/LibGDX game runtime.

3. **Launch pipeline**
   - The launcher flow starts in `LauncherActivity` / `StsGameActivity`, then moves through launch-preparation coordinators under `backend/launch/`.
   - These classes install components, resolve native library paths, warm up caches, validate the game jar, apply patch caches, and decide how the game should return to the launcher after exit.
   - `boot-bridge/` participates here as the Java-side bootstrap layer loaded into the game runtime.

4. **Game session and surface management**
   - `GameSessionCoordinator`, `RenderSurfaceHost`, `RenderSurfaceManager`, `GameSessionConfig`, and the render-related backend classes coordinate the actual game window/surface lifecycle.
   - Rendering policy is abstracted from the UI: the app chooses a renderer backend, display refresh strategy, virtual resolution policy, and surface backend before game start.
   - This is the boundary where Android display constraints, GPU behavior, and the game’s desktop rendering expectations are reconciled.

5. **Native and JVM compatibility layer**
   - The repo includes extensive JNI/C code under `app/src/main/jni/`, plus Java compatibility stubs under `app/src/main/java/com/oracle`, `dalvik`, and `net/kdt/pojavlaunch`.
   - These pieces emulate or bridge desktop behaviors needed by the JavaSE runtime on Android: AWT, GLFW/input, EGL/OSMesa, native hooks, process exit handling, and workshop Zstd support.
   - `patches/gdx-patch/` adds bytecode/source-level compatibility fixes for LibGDX and game classes, while `boot-bridge/` adds runtime probes and patch-cache/bootstrap logic.

6. **Mod ecosystem handling**
   - `backend/mods/` is a major subsystem for validating, patching, importing, and managing mod jars.
   - It handles mod manifest parsing, classpath jar building, compatibility patching, duplicate ZIP normalization, optional mod storage, jar integrity checks, and runtime patch generation.
   - There is a separate import pipeline under `backend/mods/importing/` with modular patch modules for specific mod families, indicating that mod ingestion is intentionally data-driven and extensible.

7. **Workshop and Steam content flow**
   - `backend/workshop/` is the launcher-side workshop domain: browsing, metadata storage, download orchestration, preview caching, interrupted-download recovery, and auto-import into the mod system.
   - `steam-protocol/` and `workshop-core/` are lower-level network/client libraries used to talk to Steam content services and process workshop downloads.
   - This creates a clean separation: app-level UX and policies in `app/`, transport/protocol logic in shared libraries, and file installation/patching back in the launcher.

8. **Steam Cloud synchronization**
   - `backend/steamcloud/` is a full sync engine for save-state mirroring, diff planning, path mapping, auth, local snapshots, manifest handling, and process services.
   - It is designed as a long-running subsystem with explicit mutex/operation coordination and user warnings for conflict/risk cases.
   - The launcher also exposes settings screens for cloud behavior, blacklist configuration, and login, so cloud sync is both a backend service and a user-visible feature.

9. **Feedback, diagnostics, and crash recovery**
   - `backend/feedback/` and `backend/diag/` form the observability and support path.
   - Diagnostics collect logcat, memory snapshots, process exit data, crash dumps, and archive them for submission or local inspection.
   - Feedback submission is integrated with issue models, inbox coordination, and conversation handling, so the launcher can gather structured reports after failures or user reports.

10. **Update and resource distribution**
    - `backend/update/` manages launcher updates and component updates, including mirror selection and versioning policy.
    - `backend/resources/` and `backend/runtime/` manage runtime resource packs and external resource packs, which are required to assemble the launcher’s embedded game environment.
    - The repo explicitly relies on external artifacts such as the Steam desktop jar, runtime pack, and native library market assets.

11. **UI architecture**
    - The UI layer is Jetpack Compose-based and organized by domain: main launcher, workshop, feedback, settings, quickstart, compatibility, and mod import.
    - Screens are backed by view models and stores/coordinators rather than direct imperative logic, which keeps UI state separate from the game/runtime orchestration.
    - The UI also includes overlays and controls for in-game touch/mouse keyboard, boot overlays, performance overlays, and mobile-specific gestures.

12. **Configuration and persistence**
    - `config/` contains the launcher’s persistent policy and user preference model: render backend, touchscreen mode, Steam Cloud mode, theme/icon policies, runtime paths, and legacy migration.
    - Many subsystems keep their own local stores for search history, mod associations, favorites, highlights, workshop metadata, and diagnostics artifacts.
    - This implies a mostly local-first architecture with explicit per-domain storage rather than one centralized app database.

13. **Ancillary services in the repo**
    - `cloud-function/` is a Node.js backend for submission/feedback/cloud-control style APIs and notifications.
    - `presence-service/` and `cloudflare-presence-worker/` implement a separate presence-tracking service, with a server/API layer plus Cloudflare Worker deployment and SQL migrations.
    - These are not part of the Android launcher runtime, but they are architectural peers supporting community/telemetry/social features.

14. **Automation, testing, and release chain**
    - `scripts/tools/` and `scripts/build/` provide harnesses for repeatable device testing, smoke runs, autoplay runs, and crash/performance workflows.
    - `macrobenchmark/` and the Android instrumentation tests cover UI and launcher behavior, while `boot-bridge/`, `app/`, and `patches/gdx-patch/` each have focused unit tests.
    - GitHub Actions workflows and docs under `docs/release-automation/` and `docs/debug-automation/` show that release packaging and debugging are treated as part of the architecture, not as afterthoughts.

Main entry points: [`app`](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app) (Launcher app), [`app/src/main/java/io/stamethyst/backend/launch`](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/launch) (Launch core), [`app/src/main/java/io/stamethyst/backend/mods`](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/mods) (Mod manager), [`app/src/main/java/io/stamethyst/backend/workshop`](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/workshop) (Workshop domain)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_android_launcher["Android launcher"]
  node_app["Launcher app<br/>Android app"]
  node_app_launch["Launch core<br/>startup orchestration"]
  node_app_render["Render core<br/>display/surface policy"]
  node_app_game_session["Game session<br/>session/surface coordination"]
end

subgraph group_group_runtime_compat["Runtime compat"]
  node_boot_bridge["Boot bridge<br/>Java bootstrap"]
  node_gdx_patch["GDX patch"]
  node_runtime_mods["Compat mods<br/>runtime patch mods"]
  node_native_layer["Native layer<br/>JNI/bridge code"]
end

subgraph group_group_content_backend["Content backend"]
  node_app_mods["Mod manager<br/>mod lifecycle"]
  node_app_workshop["Workshop domain<br/>content sync"]
  node_app_steamcloud["Steam Cloud<br/>sync engine"]
  node_app_diag["Diagnostics<br/>observability"]
  node_app_feedback["Feedback<br/>issue/reporting"]
  node_app_update["Updates<br/>update policy"]
  node_app_resources["Resources<br/>runtime assets"]
end

subgraph group_group_services_tools["Services and tools"]
  node_steam_protocol["Steam protocol<br/>network client lib"]
  node_workshop_core["Workshop core<br/>download engine"]
  node_cloud_function["Cloud function<br/>Node backend"]
  node_presence_service["Presence service<br/>web service"]
  node_presence_worker["Presence worker<br/>edge worker"]
  node_tools["Automation tools<br/>test/release tooling"]
end

node_app -->|"launches"| node_app_launch
node_app -->|"configures"| node_app_render
node_app -->|"hosts"| node_app_game_session
node_app -->|"manages"| node_app_mods
node_app -->|"syncs"| node_app_workshop
node_app -->|"synchronizes"| node_app_steamcloud
node_app -->|"collects"| node_app_diag
node_app -->|"submits"| node_app_feedback
node_app -->|"updates"| node_app_update
node_app -->|"installs"| node_app_resources
node_app_launch -->|"boots"| node_boot_bridge
node_app_launch -->|"loads"| node_native_layer
node_app_launch -.->|"depends on"| node_gdx_patch
node_app_game_session -->|"uses"| node_app_render
node_app_mods -->|"targets"| node_gdx_patch
node_app_mods -->|"coordinates"| node_runtime_mods
node_app_workshop -->|"uses"| node_steam_protocol
node_app_workshop -->|"downloads"| node_workshop_core
node_app_steamcloud -.->|"syncs via"| node_cloud_function
node_app_feedback -.->|"reports to"| node_cloud_function
node_presence_service -.->|"deploys"| node_presence_worker
node_tools -.->|"drives"| node_app
node_tools -.->|"probes"| node_boot_bridge

click node_app "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app"
click node_app_launch "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/launch"
click node_app_render "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/render"
click node_app_game_session "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst"
click node_app_mods "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/mods"
click node_app_workshop "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/workshop"
click node_app_steamcloud "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/steamcloud"
click node_app_diag "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/diag"
click node_app_feedback "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/feedback"
click node_app_update "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/update"
click node_app_resources "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/resources"
click node_boot_bridge "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/boot-bridge"
click node_gdx_patch "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/patches/gdx-patch"
click node_runtime_mods "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/mods"
click node_native_layer "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/jni"
click node_steam_protocol "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/steam-protocol"
click node_workshop_core "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/workshop-core"
click node_cloud_function "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/cloud-function"
click node_presence_service "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/presence-service"
click node_presence_worker "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/cloudflare-presence-worker"
click node_tools "https://github.com/modinmobilests/slaytheamethystmodded/tree/main/scripts"

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_app,node_app_launch,node_app_render,node_app_game_session toneBlue
class node_boot_bridge,node_gdx_patch,node_runtime_mods,node_native_layer toneAmber
class node_app_mods,node_app_workshop,node_app_steamcloud,node_app_diag,node_app_feedback,node_app_update,node_app_resources toneMint
class node_steam_protocol,node_workshop_core,node_cloud_function,node_presence_service,node_presence_worker,node_tools toneRose
```

## Components

### Android launcher

Android app, UI, launch orchestration, and in-process runtime boundary.

- [Launcher app](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app): Android app · Compose-based launcher UI plus orchestration for game startup, settings, mod management, workshop, cloud sync, feedback, and diagnostics. · `app`
- [Launch core](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/launch): startup orchestration · Prepares runtime assets, native library paths, caches, patch state, and game return policy before starting the desktop game runtime. · `app/src/main/java/io/stamethyst/backend/launch`
- [Render core](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/render): display/surface policy · Chooses renderer backend, virtual resolution, refresh policy, and surface lifecycle for the embedded game window. · `app/src/main/java/io/stamethyst/backend/render`
- [Game session](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst): session/surface coordination · Coordinates activity entry, render surface hosting, session config, and in-game overlays around the running game process. · `app/src/main/java/io/stamethyst`

### Runtime compat

Java bridge, bytecode patches, native shims, and bundled compatibility mods.

- [Boot bridge](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/boot-bridge): Java bootstrap · Game-runtime-side bootstrap layer that probes game state, caches patch metadata, and forwards startup/runtime signals. · `boot-bridge`
- [GDX patch](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/patches/gdx-patch): LibGDX patch set · Bytecode/source compatibility fixes for LibGDX, Steam, and selected game classes used by the desktop runtime. · `patches/gdx-patch`
- [Compat mods](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/mods): runtime patch mods · Bundled ModTheSpire mods that adapt desktop/game behavior for Android, including touch, autoplay, rescue, and RAM-saving patches. · `mods`
- [Native layer](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/jni): JNI/bridge code · C/JNI and Java compatibility stubs for AWT, GLFW/input, EGL/OSMesa, process hooks, and workshop zstd support. · `app/src/main/jni`

### Content backend

Workshop, mods, resources, updates, feedback, diagnostics, and cloud sync subsystems.

- [Mod manager](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/mods): mod lifecycle · Validates, patches, imports, classpath-builds, and stores mods; also drives mod suggestions and compatibility handling. · `app/src/main/java/io/stamethyst/backend/mods`
- [Workshop domain](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/workshop): content sync · Browses Steam Workshop content, downloads packages, caches previews, recovers interrupted downloads, and auto-imports into mods. · `app/src/main/java/io/stamethyst/backend/workshop`
- [Steam Cloud](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/steamcloud): sync engine · Long-running save mirroring engine with auth, path mapping, diff planning, snapshots, blacklists, and conflict warnings. · `app/src/main/java/io/stamethyst/backend/steamcloud`
- [Diagnostics](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/diag): observability · Collects logcat, memory snapshots, process exit data, and crash artifacts into shareable diagnostics archives. · `app/src/main/java/io/stamethyst/backend/diag`
- [Feedback](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/feedback): issue/reporting · Manages feedback inbox, issue models, conversation flow, submission, and log-assisted triage. · `app/src/main/java/io/stamethyst/backend/feedback`
- [Updates](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/update): update policy · Handles launcher and component update checks, mirror selection, version policy, and update UI reduction. · `app/src/main/java/io/stamethyst/backend/update`
- [Resources](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/app/src/main/java/io/stamethyst/backend/resources): runtime assets · Installs external resource packs and runtime packs required to assemble the launcher’s embedded environment. · `app/src/main/java/io/stamethyst/backend/resources`

### Services and tools

External services, shared protocol libraries, and automation tooling.

- [Steam protocol](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/steam-protocol): network client lib · Low-level Steam authentication/content protocol client used by workshop download flows and related services. · `steam-protocol`
- [Workshop core](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/workshop-core): download engine · Shared downloader and integrity engine for Steam workshop and depot content. · `workshop-core`
- [Cloud function](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/cloud-function): Node backend · Serverless backend for submission, feedback, notifications, and cloud-control style APIs. · `cloud-function`
- [Presence service](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/presence-service): web service · Standalone presence tracking API and client UI with SQL-backed storage. · `presence-service`
- [Presence worker](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/cloudflare-presence-worker): edge worker · Cloudflare Worker deployment and migrations for presence snapshot handling. · `cloudflare-presence-worker`
- [Automation tools](https://github.com/modinmobilests/slaytheamethystmodded/tree/main/scripts): test/release tooling · Device harnesses, smoke/perf runners, release prep scripts, and support utilities for debugging and automation. · `scripts`

## Connections

- Launcher app → Launch core: launches · UI entry points hand off to launch preparation and startup coordination.
- Launcher app → Render core: configures · Launcher settings determine renderer, refresh, and resolution policy.
- Launcher app → Game session: hosts · Activities and overlays manage the active game session and surface lifecycle.
- Launcher app → Mod manager: manages · The launcher’s main content loop is mod validation, import, and patching.
- Launcher app → Workshop domain: syncs · Workshop browsing and downloads feed the local mod system.
- Launcher app → Steam Cloud: synchronizes · Save-state mirroring is controlled from launcher settings and services.
- Launcher app → Diagnostics: collects · Crash and support flows build diagnostics archives from launcher/runtime data.
- Launcher app → Feedback: submits · Feedback screens and stores route issue reports to backend services.
- Launcher app → Updates: updates · Launcher and component updates are checked and applied from the app.
- Launcher app → Resources: installs · Runtime packs and external assets are staged by the launcher.
- Launch core → Boot bridge: boots · Launch prep depends on the bridge layer loaded into the game runtime.
- Launch core → Native layer: loads · Native library resolution and preload are part of startup.
- Launch core → GDX patch: depends on · Startup assumes patched desktop/LibGDX classes are available.
- Game session → Render core: uses · Session setup selects and applies render surface policy.
- Mod manager → GDX patch: targets · Mod compatibility relies on patched runtime classes and behavior.
- Mod manager → Compat mods: coordinates · Imported and bundled mods become part of the runtime patch set.
- Workshop domain → Steam protocol: uses · Workshop browsing and metadata flows use the Steam protocol client.
- Workshop domain → Workshop core: downloads · Content retrieval and integrity checks delegate to the shared downloader engine.
- Steam Cloud → Cloud function: syncs via · Support/control APIs and notifications are backed by the cloud function service.
- Feedback → Cloud function: reports to · Submission and issue workflows connect to the server-side feedback API.
- Presence service → Presence worker: deploys · The worker is the edge deployment companion for the presence service.
- Automation tools → Launcher app: drives · Automation harnesses exercise launcher flows on real devices and test setups.
- Automation tools → Boot bridge: probes · Crash, autoplay, and observation tools connect through the bridge protocol.
