How timothyhay256/mikumikuloader works
Project type and purpose
• MikuMikuLoader is a network-based game-mod proxy and web UI platform for Project Sekai, written in Rust, with a Python helper for AssetBundle creation.
• It functions as a local DNS/HTTP proxy, a REST API server, and a static web UI, orchestrating binary AssetBundle injections and story conversions via UnityPy.
File structure
• Top-level:
• Cargo.toml / Cargo.lock / build.rs → Rust project, build configuration.
• .github/workflows/rust.yml → CI pipeline for build/test.
• *.toml files → runtime configuration (mods, injections, certs).
• python/story_to_assetbundle.py → Python helper script integrated during build or on-demand.
• src/ (Rust backend):
• main.rs → entrypoint, HTTP/DNS server initialization.
• routes.rs → REST endpoints (mod management, status, cert gen).
• mods.rs, assetbundle.rs, scenario.rs → core injection logic (manage mod index, build/serve AssetBundles, scenario/story conversion).
• utils.rs → shared helpers.
• static/ (Frontend/UI assets):
• HTML pages: mod-manager.html, server-status.html, certificate-gen.html, custom-story.html, index.html.
• JS/CSS subfolders: interactive UI, API calls to backend.
• Images, styling, client logic.
• python/:
• UnityPy integration to build .unity3d AssetBundles from JSON stories.
• Configuration TOMLs for injection pipelines and the main loader (MikuMiku.toml, sekai-injector.toml).
README for additional insights
• Purpose: purely network-based modding, no client modifications.
• Features: DNS server, certificate generation, auto resource download, cache invalidation, AssetBundle injection, story conversion.
• Dependencies: Rust toolchain, Python 3 + UnityPy library for final packaging.
• Roadmap indicates ongoing work on custom stories and deeper UI integration.
Main components and their relationships
a. Game Client
• Configured to use custom DNS/HTTPS proxy.
• Requests game assets & data.
b. DNS & HTTPS Proxy (Rust server)
• Resolves Sekai domains to local server IP.
• Presents CA certificate (self-signed via cert-gen module).
c. REST API Server (Rust backend)
• Exposes /mods, /inject, /status, /cert endpoints.
• Serves static UI and responds to AJAX calls.
d. AssetBundle Injection Engine (Rust + Python)
• Rust routes invoke Python script via child process (build.rs integration or runtime spawn).
• Python uses UnityPy to bundle JSON → .unity3d.
• Rust streams generated bundles back to the client/game.
e. Static Web UI
• HTML/JS pages for mod manager, story editor, cert gen, server status.
• Communicates with REST API.
f. Configuration Store
• TOML files define injection mappings, mod indexes, cert parameters.
g. External Dependencies
• UnityPy (Python library) for asset packaging.
• Project Sekai master DB (auto-downloaded assets).
Relationships:
• Browser UI ↔ REST API over HTTP.
• Game Client ↔ DNS/HTTPS Proxy (game traffic hijacked to inject mods).
• REST API ↔ Python script (for heavy build tasks).
• Rust backend ↔ file system (reads/writes bundles, configs).
• Rust backend ↔ external Sekai CDN (to auto-download resources).
Architectural patterns and design principles
• Separation of concerns: DNS proxy, HTTP API, and build logic modularized.
• Polyglot orchestration: Rust core with Python helper for specialized tasks.
• Configuration-driven injection pipelines (TOML).
• Static asset serving alongside dynamic endpoints (Full-stack single-binaries).
• Minimal statefulness: mostly stateless REST calls; file-based cache/injection.
Detail
• Rust module (routes, mods, assetbundle, scenario) as separate sub-components or group them in a “Injection Engine”.
• Python script as an external subprocess/service.
• TOML files as config entities feeding into both the Rust server and the Python builder.
• How the CI (.github/workflows/rust.yml) fits in for build/deploy, if relevant.