# lemonloaderx/lemonloader architecture

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

- Interactive diagram: https://gitdiagram.com/lemonloaderx/lemonloader
- Repository: https://github.com/lemonloaderx/lemonloader

## Overview

LemonLoader is an Android ARM64 payload that adapts MelonLoader to Unity IL2CPP games. The principal workflow is game startup through native bootstrap and managed hosting, followed by loader initialization, Unity/game discovery, IL2CPP support setup, and loading mods and plugins. Additional branches cover assembly resolution, Unity asset access, and compatibility APIs. The README documents runtime profiles and the external Patcher boundary; sampled source is partial, so internal startup wiring beyond explicit calls is represented conservatively.

Main entry points: [`MelonLoader/Core.cs`](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Core.cs) (Loader core), [`Dependencies/SupportModules/Il2Cpp/Main.cs`](https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/Il2Cpp/Main.cs) (IL2CPP support), [`MelonLoader/Melons/MelonFolderHandler.cs`](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Melons/MelonFolderHandler.cs) (Content discovery), [`MelonLoader.Bootstrap/Platforms/Android/Native/src/bootstrap.cpp`](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader.Bootstrap/Platforms/Android/Native/src/bootstrap.cpp) (Native bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Android startup"]
  node_bootstrap["Native bootstrap<br/>[bootstrap.cpp]"]
  node_nativeentry["Native entry point"]
  node_managedruntime["CoreCLR runtime"]
end

subgraph group_loader["Loader runtime"]
  node_loadercore["Loader core<br/>[Core.cs]"]
  node_gameinfo["Unity discovery"]
  node_resolver["Assembly resolver<br/>[AssemblyManager.cs]"]
  node_searchdirs["Search directories"]
end

subgraph group_interop["Unity IL2CPP"]
  node_supportil2cpp["IL2CPP support<br/>[Main.cs]"]
  node_supportmono["Mono support<br/>[Main.cs]"]
  node_supportinterface["Support interface"]
  node_assetbundles["Asset bundles"]
  node_imageconversion["Image conversion"]
end

subgraph group_extensions["Mods and compatibility"]
  node_folderhandler["Content discovery"]
  node_melons["Mods and plugins<br/>[MelonHandler.cs]"]
  node_compat["Compatibility APIs"]
end

subgraph group_assets["Game resources"]
  node_apkassets["APK asset access<br/>[APKAssetManager.cs]"]
end

node_game(("Unity game"))
node_patcher["LemonLoader Patcher"]

node_game -->|"starts payload"| node_bootstrap
node_bootstrap -->|"enters host"| node_nativeentry
node_nativeentry -->|"loads runtime"| node_managedruntime
node_managedruntime -->|"hosts loader"| node_loadercore
node_loadercore -->|"discovers game"| node_gameinfo
node_loadercore -->|"sets up resolution"| node_resolver
node_resolver -->|"scans directories"| node_searchdirs
node_folderhandler -->|"registers directories"| node_searchdirs
node_folderhandler -->|"loads extensions"| node_melons
node_loadercore -->|"discovers content"| node_folderhandler
node_loadercore -->|"initializes support"| node_supportil2cpp
node_supportil2cpp -->|"provides interface"| node_supportinterface
node_supportmono -->|"provides interface"| node_supportinterface
node_supportil2cpp -->|"enables Unity access"| node_assetbundles
node_supportil2cpp -->|"enables Unity access"| node_imageconversion
node_gameinfo -->|"reads APK assets"| node_apkassets
node_melons -.->|"exposes compatibility"| node_compat
node_patcher -.->|"prepares APK"| node_game

click node_bootstrap "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader.Bootstrap/Platforms/Android/Native/src/bootstrap.cpp"
click node_nativeentry "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader.NativeHost/NativeEntryPoint.cs"
click node_loadercore "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Core.cs"
click node_gameinfo "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/InternalUtils/UnityInformationHandler.cs"
click node_resolver "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Resolver/AssemblyManager.cs"
click node_searchdirs "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Resolver/SearchDirectoryManager.cs"
click node_folderhandler "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Melons/MelonFolderHandler.cs"
click node_melons "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Melons/MelonHandler.cs"
click node_supportil2cpp "https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/Il2Cpp/Main.cs"
click node_supportmono "https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/Mono/Main.cs"
click node_supportinterface "https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/SupportModule_To.cs"
click node_assetbundles "https://github.com/lemonloaderx/lemonloader/blob/main/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleManager.cs"
click node_imageconversion "https://github.com/lemonloaderx/lemonloader/blob/main/UnityUtilities/UnityEngine.Il2CppImageConversionManager/Il2CppImageConversionManager.cs"
click node_apkassets "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Utils/APKAssetManager.cs"
click node_compat "https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs"

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_bootstrap,node_nativeentry,node_managedruntime toneBlue
class node_loadercore,node_gameinfo,node_resolver,node_searchdirs toneAmber
class node_supportil2cpp,node_supportmono,node_supportinterface,node_assetbundles,node_imageconversion toneMint
class node_folderhandler,node_melons,node_compat toneRose
class node_apkassets,node_game,node_patcher toneIndigo
```

## Components

### Android startup

- [Native bootstrap](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader.Bootstrap/Platforms/Android/Native/src/bootstrap.cpp): `MelonLoader.Bootstrap/Platforms/Android/Native/src/bootstrap.cpp`
- [Native entry point](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader.NativeHost/NativeEntryPoint.cs): `MelonLoader.NativeHost/NativeEntryPoint.cs`
- **CoreCLR runtime**

### Loader runtime

- [Loader core](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Core.cs): `MelonLoader/Core.cs`
- [Unity discovery](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/InternalUtils/UnityInformationHandler.cs): `MelonLoader/InternalUtils/UnityInformationHandler.cs`
- [Assembly resolver](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Resolver/AssemblyManager.cs): `MelonLoader/Resolver/AssemblyManager.cs`
- [Search directories](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Resolver/SearchDirectoryManager.cs): `MelonLoader/Resolver/SearchDirectoryManager.cs`

### Unity IL2CPP

- [IL2CPP support](https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/Il2Cpp/Main.cs): `Dependencies/SupportModules/Il2Cpp/Main.cs`
- [Mono support](https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/Mono/Main.cs): `Dependencies/SupportModules/Mono/Main.cs`
- [Support interface](https://github.com/lemonloaderx/lemonloader/blob/main/Dependencies/SupportModules/SupportModule_To.cs): `Dependencies/SupportModules/SupportModule_To.cs`
- [Asset bundles](https://github.com/lemonloaderx/lemonloader/blob/main/UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleManager.cs): `UnityUtilities/UnityEngine.Il2CppAssetBundleManager/Il2CppAssetBundleManager.cs`
- [Image conversion](https://github.com/lemonloaderx/lemonloader/blob/main/UnityUtilities/UnityEngine.Il2CppImageConversionManager/Il2CppImageConversionManager.cs): `UnityUtilities/UnityEngine.Il2CppImageConversionManager/Il2CppImageConversionManager.cs`

### Mods and compatibility

- [Content discovery](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Melons/MelonFolderHandler.cs): `MelonLoader/Melons/MelonFolderHandler.cs`
- [Mods and plugins](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Melons/MelonHandler.cs): `MelonLoader/Melons/MelonHandler.cs`
- [Compatibility APIs](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs): `MelonLoader/CompatibilityLayers/MelonCompatibilityLayer.cs`

### Game resources

- [APK asset access](https://github.com/lemonloaderx/lemonloader/blob/main/MelonLoader/Utils/APKAssetManager.cs): `MelonLoader/Utils/APKAssetManager.cs`

### Other components

- **Unity game**
- **LemonLoader Patcher**

## Connections

- Unity game → Native bootstrap: starts payload
- Native bootstrap → Native entry point: enters host
- Native entry point → CoreCLR runtime: loads runtime
- CoreCLR runtime → Loader core: hosts loader
- Loader core → Unity discovery: discovers game
- Loader core → Assembly resolver: sets up resolution
- Assembly resolver → Search directories: scans directories
- Content discovery → Search directories: registers directories
- Content discovery → Mods and plugins: loads extensions
- Loader core → Content discovery: discovers content
- Loader core → IL2CPP support: initializes support
- IL2CPP support → Support interface: provides interface
- Mono support → Support interface: provides interface
- IL2CPP support → Asset bundles: enables Unity access
- IL2CPP support → Image conversion: enables Unity access
- Unity discovery → APK asset access: reads APK assets
- Mods and plugins → Compatibility APIs: exposes compatibility
- LemonLoader Patcher → Unity game: prepares APK
