# erfanoabdi/apklayer architecture

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

- Interactive diagram: https://gitdiagram.com/erfanoabdi/apklayer
- Repository: https://github.com/erfanoabdi/apklayer

## Overview

apklayer runs Android APKs as host processes: the CLI installs and converts an APK, the JVM runtime hosts its Android framework and native libraries, and Android services use host hardware interfaces before apps appear in Wayland windows. The README documents the main data path and capabilities; source excerpts confirm CLI dispatch, dex conversion, binder operation, storage callbacks, and shell startup. Several service and hub implementations are unsampled, so their internal links are omitted or shown only where the README documents them.

Main entry points: [`runtime/host/java/apklayer/host/Main.java`](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/Main.java) (Application host), [`aosp/hals/servicemanager/Access.cpp`](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/servicemanager/Access.cpp) (Android services), [`cli/main.cpp`](https://github.com/erfanoabdi/apklayer/blob/main/cli/main.cpp) (apklayer CLI), [`runtime/host/java/apklayer/host/HubClient.java`](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HubClient.java) (Instance hub)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App lifecycle"]
  node_cli["apklayer CLI<br/>[main.cpp]"]
  node_install["Install and manage<br/>[apps.cpp]"]
  node_converter["DEX converter<br/>[DexConverter.java]"]
  node_translator["Bytecode translator<br/>[Translator.java]"]
  node_manager["Desktop manager<br/>[main.cpp]"]
end

subgraph group_runtime["Android runtime"]
  node_apphost["Application host<br/>[Main.java]"]
  node_nativebridge["Native bridge<br/>[native_bridge.c]"]
  node_binder["Userspace binder<br/>[main.cpp]"]
end

subgraph group_services["Android services"]
  node_hub["Instance hub<br/>[HubClient.java]"]
  node_hubdirectory["Hub directory<br/>[HubDirectory.java]"]
  node_package["Package services"]
  node_storage["Storage integration<br/>[HostVolumes.java]"]
  node_androidservices["Android services<br/>[Access.cpp]"]
end

subgraph group_hardware["Host hardware"]
  node_graphics["Graphics HAL<br/>[Allocator.cpp]"]
  node_audio["Audio HAL<br/>[Service.cpp]"]
  node_media["Media services<br/>[MediaServices.cpp]"]
  node_hostinterfaces["Linux interfaces<br/>[graphics.c]"]
  node_vulkan["Texture decompression"]
end

subgraph group_presentation["User interface"]
  node_shell["Wayland shell<br/>[main.c]"]
  node_window["App window<br/>[window.c]"]
end

node_user(("Linux user"))
node_apk["APK package"]

node_user -->|"invokes"| node_cli
node_apk -->|"installs"| node_install
node_cli -->|"dispatches"| node_install
node_install -->|"converts DEX"| node_converter
node_converter -.->|"translates bytecode"| node_translator
node_cli -->|"launches app"| node_apphost
node_apphost -->|"loads native libraries"| node_nativebridge
node_apphost -->|"uses binder"| node_binder
node_binder -->|"connects services"| node_androidservices
node_apphost -.->|"provides package APIs"| node_package
node_apphost -->|"uses instance hub"| node_hub
node_hub -.->|"routes requests"| node_hubdirectory
node_hub -.->|"coordinates volumes"| node_storage
node_storage -->|"binds service"| node_hubdirectory
node_androidservices -->|"provides graphics"| node_graphics
node_androidservices -->|"provides audio"| node_audio
node_androidservices -->|"provides media"| node_media
node_graphics -->|"uses host graphics"| node_hostinterfaces
node_audio -->|"uses host audio"| node_hostinterfaces
node_media -->|"uses host media"| node_hostinterfaces
node_androidservices -.->|"emulates textures"| node_vulkan
node_apphost -->|"presents app"| node_shell
node_shell -.->|"creates window"| node_window
node_user -->|"manages apps"| node_manager
node_manager -->|"runs CLI"| node_cli

click node_cli "https://github.com/erfanoabdi/apklayer/blob/main/cli/main.cpp"
click node_install "https://github.com/erfanoabdi/apklayer/blob/main/cli/apps.cpp"
click node_converter "https://github.com/erfanoabdi/apklayer/blob/main/runtime/dex2jvm/io/github/kksimp/dex2jvm/DexConverter.java"
click node_translator "https://github.com/erfanoabdi/apklayer/blob/main/runtime/dex2jvm/io/github/kksimp/dex2jvm/Translator.java"
click node_apphost "https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/Main.java"
click node_nativebridge "https://github.com/erfanoabdi/apklayer/blob/main/bridge/native/native_bridge.c"
click node_binder "https://github.com/erfanoabdi/apklayer/blob/main/bridge/binderd/main.cpp"
click node_hub "https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HubClient.java"
click node_hubdirectory "https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HubDirectory.java"
click node_package "https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/ShadowHostPackageManager.java"
click node_storage "https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HostVolumes.java"
click node_androidservices "https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/servicemanager/Access.cpp"
click node_graphics "https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/graphics/allocator/Allocator.cpp"
click node_audio "https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/audio/Service.cpp"
click node_media "https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/media/services/MediaServices.cpp"
click node_hostinterfaces "https://github.com/erfanoabdi/apklayer/blob/main/bridge/hals/graphics/graphics.c"
click node_shell "https://github.com/erfanoabdi/apklayer/blob/main/bridge/shell/main.c"
click node_window "https://github.com/erfanoabdi/apklayer/blob/main/bridge/shell/window.c"
click node_manager "https://github.com/erfanoabdi/apklayer/blob/main/manager/src/main.cpp"
click node_vulkan "https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/graphics/vulkan/gfxstream/vulkan/emulated_textures/gpu_decompression_pipeline.cpp"

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_cli,node_install,node_converter,node_translator,node_manager,node_user toneBlue
class node_apphost,node_nativebridge,node_binder toneAmber
class node_hub,node_hubdirectory,node_package,node_storage,node_androidservices toneMint
class node_graphics,node_audio,node_media,node_hostinterfaces,node_vulkan toneRose
class node_shell,node_window,node_apk toneIndigo
```

## Components

### App lifecycle

- [apklayer CLI](https://github.com/erfanoabdi/apklayer/blob/main/cli/main.cpp): `cli/main.cpp`
- [Install and manage](https://github.com/erfanoabdi/apklayer/blob/main/cli/apps.cpp): `cli/apps.cpp`
- [DEX converter](https://github.com/erfanoabdi/apklayer/blob/main/runtime/dex2jvm/io/github/kksimp/dex2jvm/DexConverter.java): `runtime/dex2jvm/io/github/kksimp/dex2jvm/DexConverter.java`
- [Bytecode translator](https://github.com/erfanoabdi/apklayer/blob/main/runtime/dex2jvm/io/github/kksimp/dex2jvm/Translator.java): `runtime/dex2jvm/io/github/kksimp/dex2jvm/Translator.java`
- [Desktop manager](https://github.com/erfanoabdi/apklayer/blob/main/manager/src/main.cpp): `manager/src/main.cpp`

### Android runtime

- [Application host](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/Main.java): `runtime/host/java/apklayer/host/Main.java`
- [Native bridge](https://github.com/erfanoabdi/apklayer/blob/main/bridge/native/native_bridge.c): `bridge/native/native_bridge.c`
- [Userspace binder](https://github.com/erfanoabdi/apklayer/blob/main/bridge/binderd/main.cpp): `bridge/binderd/main.cpp`

### Android services

- [Instance hub](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HubClient.java): `runtime/host/java/apklayer/host/HubClient.java`
- [Hub directory](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HubDirectory.java): `runtime/host/java/apklayer/host/HubDirectory.java`
- [Package services](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/ShadowHostPackageManager.java): `runtime/host/java/apklayer/host/ShadowHostPackageManager.java`
- [Storage integration](https://github.com/erfanoabdi/apklayer/blob/main/runtime/host/java/apklayer/host/HostVolumes.java): `runtime/host/java/apklayer/host/HostVolumes.java`
- [Android services](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/servicemanager/Access.cpp): `aosp/hals/servicemanager/Access.cpp`

### Host hardware

- [Graphics HAL](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/graphics/allocator/Allocator.cpp): `aosp/hals/graphics/allocator/Allocator.cpp`
- [Audio HAL](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/audio/Service.cpp): `aosp/hals/audio/Service.cpp`
- [Media services](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/media/services/MediaServices.cpp): `aosp/hals/media/services/MediaServices.cpp`
- [Linux interfaces](https://github.com/erfanoabdi/apklayer/blob/main/bridge/hals/graphics/graphics.c): `bridge/hals/graphics/graphics.c`
- [Texture decompression](https://github.com/erfanoabdi/apklayer/blob/main/aosp/hals/graphics/vulkan/gfxstream/vulkan/emulated_textures/gpu_decompression_pipeline.cpp): `aosp/hals/graphics/vulkan/gfxstream/vulkan/emulated_textures/gpu_decompression_pipeline.cpp`

### User interface

- [Wayland shell](https://github.com/erfanoabdi/apklayer/blob/main/bridge/shell/main.c): `bridge/shell/main.c`
- [App window](https://github.com/erfanoabdi/apklayer/blob/main/bridge/shell/window.c): `bridge/shell/window.c`

### Other components

- **Linux user**
- **APK package**

## Connections

- Linux user → apklayer CLI: invokes (evidence: `README.md`)
- APK package → Install and manage: installs
- apklayer CLI → Install and manage: dispatches (evidence: `cli/main.cpp`)
- Install and manage → DEX converter: converts DEX (evidence: `cli/apps.cpp`)
- DEX converter → Bytecode translator: translates bytecode
- apklayer CLI → Application host: launches app (evidence: `README.md`)
- Application host → Native bridge: loads native libraries (evidence: `README.md`)
- Application host → Userspace binder: uses binder (evidence: `README.md`)
- Userspace binder → Android services: connects services (evidence: `README.md`)
- Application host → Package services: provides package APIs
- Application host → Instance hub: uses instance hub (evidence: `README.md`)
- Instance hub → Hub directory: routes requests
- Instance hub → Storage integration: coordinates volumes
- Storage integration → Hub directory: binds service
- Android services → Graphics HAL: provides graphics (evidence: `README.md`)
- Android services → Audio HAL: provides audio (evidence: `README.md`)
- Android services → Media services: provides media (evidence: `README.md`)
- Graphics HAL → Linux interfaces: uses host graphics (evidence: `README.md`)
- Audio HAL → Linux interfaces: uses host audio (evidence: `README.md`)
- Media services → Linux interfaces: uses host media (evidence: `README.md`)
- Android services → Texture decompression: emulates textures
- Application host → Wayland shell: presents app (evidence: `README.md`)
- Wayland shell → App window: creates window
- Linux user → Desktop manager: manages apps (evidence: `README.md`)
- Desktop manager → apklayer CLI: runs CLI (evidence: `manager/src/main.cpp`)
