# kveld9/kveld-morphe-patches architecture

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

- Interactive diagram: https://gitdiagram.com/kveld9/kveld-morphe-patches
- Repository: https://github.com/kveld9/kveld-morphe-patches

## Overview

Morphe Patches is an Android APK patch suite: users select a supported app and apply compile-time bytecode, resource, or native changes through the Morphe patcher, producing a modified APK without a resident runtime. The repository also contains an APK audit harness that analyzes packages and checks target-specific contracts; the sampled pipeline excerpt shows transactional execution and reporting, but not every stage. The README documents broad patch capabilities, while unsampled patch implementations are represented by their existing source directories. Harness edges are limited to relationships visible in excerpts or the SOURCE INDEX.

Main entry points: [`harness/core/dex.py`](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/dex.py) (DEX indexing), [`harness/core/pipeline.py`](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/pipeline.py) (Pipeline executor), [`harness/gboard/validator.py`](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/validator.py) (Gboard validator), [`harness/tiktok/validator.py`](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/tiktok/validator.py) (TikTok validator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_patches["Patch suite"]
  node_patches_brave["Brave patches"]
  node_patches_chromium["Chromium patches"]
  node_patches_gboard["Gboard patches"]
  node_patches_tiktok_privacy["TikTok privacy"]
  node_patches_tiktok_usability["TikTok usability"]
  node_patches_tiktok_performance["TikTok performance"]
  node_patches_tiktok_slimmer["TikTok asset trimming"]
  node_patches_other["Other app patches"]
  node_patches_universal["Universal patches"]
  node_constants["Target compatibility<br/>[Constants.kt]"]
end

subgraph group_extensions["Runtime extensions"]
  node_gboard_extension["Gboard extension"]
  node_gboard_i18n["Gboard languages<br/>[GboardI18n.java]"]
  node_tiktok_hooks["TikTok hooks"]
end

subgraph group_harness["APK audit harness"]
  node_harness_pipeline["Pipeline executor<br/>[pipeline.py]"]
  node_apk_context["APK extraction<br/>[apk.py]"]
  node_dex_index["DEX indexing<br/>[dex.py]"]
  node_elf_analyzer["ELF analysis<br/>[elf.py]"]
  node_fingerprints["Fingerprint queries<br/>[fingerprints.py]"]
  node_symbols["Symbol resolution<br/>[symbols.py]"]
  node_telemetry["Telemetry scan<br/>[telemetry.py]"]
  node_gboard_contracts["Gboard contracts<br/>[contracts.py]"]
  node_gboard_invariants["Gboard invariants<br/>[invariants.py]"]
  node_gboard_themes["Gboard theme audit<br/>[themes.py]"]
  node_gboard_validator["Gboard validator<br/>[validator.py]"]
  node_tiktok_contracts["TikTok contracts<br/>[contracts.py]"]
  node_tiktok_validator["TikTok validator<br/>[validator.py]"]
  node_reporter["Audit reports<br/>[reporter.py]"]
end

subgraph group_validation["Validation tools"]
  node_validation_runner["Device harness<br/>[run_harness.py]"]
end

node_user(("Android user"))
node_morphe["Morphe patcher"]
node_targetapk["Target APK"]

node_user -->|"selects patches"| node_morphe
node_morphe -->|"patches APK"| node_targetapk
node_patches_brave -.->|"modifies app"| node_targetapk
node_patches_chromium -.->|"modifies app"| node_targetapk
node_patches_gboard -.->|"modifies app"| node_targetapk
node_patches_tiktok_privacy -.->|"modifies app"| node_targetapk
node_patches_tiktok_usability -.->|"modifies app"| node_targetapk
node_patches_tiktok_performance -.->|"modifies app"| node_targetapk
node_patches_tiktok_slimmer -.->|"trims assets"| node_targetapk
node_patches_other -.->|"modifies app"| node_targetapk
node_patches_universal -.->|"modifies app"| node_targetapk
node_gboard_extension -->|"uses languages"| node_gboard_i18n
node_harness_pipeline -->|"reads APK"| node_apk_context
node_harness_pipeline -->|"indexes DEX"| node_dex_index
node_harness_pipeline -->|"analyzes native"| node_elf_analyzer
node_harness_pipeline -->|"writes report"| node_reporter
node_fingerprints -->|"queries DEX"| node_dex_index
node_symbols -->|"queries DEX"| node_dex_index
node_telemetry -->|"scans ELF"| node_elf_analyzer
node_gboard_contracts -->|"defines queries"| node_fingerprints
node_gboard_invariants -->|"checks package"| node_apk_context
node_gboard_invariants -->|"checks classes"| node_dex_index
node_gboard_themes -->|"checks references"| node_dex_index
node_gboard_validator -->|"audits contracts"| node_gboard_contracts
node_gboard_validator -->|"runs checks"| node_gboard_invariants
node_gboard_validator -->|"audits themes"| node_gboard_themes
node_tiktok_validator -->|"audits contracts"| node_tiktok_contracts
node_tiktok_validator -->|"checks DEX"| node_dex_index
node_tiktok_validator -->|"reports results"| node_reporter

click node_patches_brave "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/brave"
click node_patches_chromium "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/chromium"
click node_patches_gboard "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/gboard"
click node_patches_tiktok_privacy "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/privacy"
click node_patches_tiktok_usability "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/usability"
click node_patches_tiktok_performance "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/performance"
click node_patches_tiktok_slimmer "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/slimmer"
click node_patches_other "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches"
click node_patches_universal "https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/universal"
click node_constants "https://github.com/kveld9/kveld-morphe-patches/blob/main/patches/src/main/kotlin/app/morphe/patches/shared/Constants.kt"
click node_gboard_extension "https://github.com/kveld9/kveld-morphe-patches/blob/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/GboardExtension.java"
click node_gboard_i18n "https://github.com/kveld9/kveld-morphe-patches/blob/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/i18n/GboardI18n.java"
click node_tiktok_hooks "https://github.com/kveld9/kveld-morphe-patches/tree/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/tiktok"
click node_harness_pipeline "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/pipeline.py"
click node_apk_context "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/apk.py"
click node_dex_index "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/dex.py"
click node_elf_analyzer "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/elf.py"
click node_fingerprints "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/fingerprints.py"
click node_symbols "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/symbols.py"
click node_telemetry "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/telemetry.py"
click node_gboard_contracts "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/contracts.py"
click node_gboard_invariants "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/invariants.py"
click node_gboard_themes "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/themes.py"
click node_gboard_validator "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/validator.py"
click node_tiktok_contracts "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/tiktok/contracts.py"
click node_tiktok_validator "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/tiktok/validator.py"
click node_reporter "https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/reporting/reporter.py"
click node_validation_runner "https://github.com/kveld9/kveld-morphe-patches/blob/main/validation/physical_harness/run_harness.py"

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_patches_brave,node_patches_chromium,node_patches_gboard,node_patches_tiktok_privacy,node_patches_tiktok_usability,node_patches_tiktok_performance,node_patches_tiktok_slimmer,node_patches_other,node_patches_universal,node_constants,node_user toneBlue
class node_gboard_extension,node_gboard_i18n,node_tiktok_hooks toneAmber
class node_harness_pipeline,node_apk_context,node_dex_index,node_elf_analyzer,node_fingerprints,node_symbols,node_telemetry,node_gboard_contracts,node_gboard_invariants,node_gboard_themes,node_gboard_validator,node_tiktok_contracts,node_tiktok_validator,node_reporter toneMint
class node_validation_runner toneRose
class node_morphe,node_targetapk toneIndigo
```

## Components

### Patch suite

- [Brave patches](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/brave): `patches/src/main/kotlin/app/morphe/patches/brave`
- [Chromium patches](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/chromium): `patches/src/main/kotlin/app/morphe/patches/chromium`
- [Gboard patches](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/gboard): `patches/src/main/kotlin/app/morphe/patches/gboard`
- [TikTok privacy](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/privacy): `patches/src/main/kotlin/app/morphe/patches/tiktok/privacy`
- [TikTok usability](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/usability): `patches/src/main/kotlin/app/morphe/patches/tiktok/usability`
- [TikTok performance](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/performance): `patches/src/main/kotlin/app/morphe/patches/tiktok/performance`
- [TikTok asset trimming](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/tiktok/slimmer): `patches/src/main/kotlin/app/morphe/patches/tiktok/slimmer`
- [Other app patches](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches): `patches/src/main/kotlin/app/morphe/patches`
- [Universal patches](https://github.com/kveld9/kveld-morphe-patches/tree/main/patches/src/main/kotlin/app/morphe/patches/universal): `patches/src/main/kotlin/app/morphe/patches/universal`
- [Target compatibility](https://github.com/kveld9/kveld-morphe-patches/blob/main/patches/src/main/kotlin/app/morphe/patches/shared/Constants.kt): `patches/src/main/kotlin/app/morphe/patches/shared/Constants.kt`

### Runtime extensions

- [Gboard extension](https://github.com/kveld9/kveld-morphe-patches/blob/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/GboardExtension.java): `extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/GboardExtension.java`
- [Gboard languages](https://github.com/kveld9/kveld-morphe-patches/blob/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/i18n/GboardI18n.java): `extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/i18n/GboardI18n.java`
- [TikTok hooks](https://github.com/kveld9/kveld-morphe-patches/tree/main/extensions/extension/src/main/java/com/kveld9/morphe/extension/tiktok): `extensions/extension/src/main/java/com/kveld9/morphe/extension/tiktok`

### APK audit harness

- [Pipeline executor](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/pipeline.py): `harness/core/pipeline.py`
- [APK extraction](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/apk.py): `harness/core/apk.py`
- [DEX indexing](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/dex.py): `harness/core/dex.py`
- [ELF analysis](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/elf.py): `harness/core/elf.py`
- [Fingerprint queries](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/fingerprints.py): `harness/core/fingerprints.py`
- [Symbol resolution](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/symbols.py): `harness/core/symbols.py`
- [Telemetry scan](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/core/telemetry.py): `harness/core/telemetry.py`
- [Gboard contracts](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/contracts.py): `harness/gboard/contracts.py`
- [Gboard invariants](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/invariants.py): `harness/gboard/invariants.py`
- [Gboard theme audit](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/themes.py): `harness/gboard/themes.py`
- [Gboard validator](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/gboard/validator.py): `harness/gboard/validator.py`
- [TikTok contracts](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/tiktok/contracts.py): `harness/tiktok/contracts.py`
- [TikTok validator](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/tiktok/validator.py): `harness/tiktok/validator.py`
- [Audit reports](https://github.com/kveld9/kveld-morphe-patches/blob/main/harness/reporting/reporter.py): `harness/reporting/reporter.py`

### Validation tools

- [Device harness](https://github.com/kveld9/kveld-morphe-patches/blob/main/validation/physical_harness/run_harness.py): `validation/physical_harness/run_harness.py`

### Other components

- **Android user**
- **Morphe patcher**
- **Target APK**

## Connections

- Android user → Morphe patcher: selects patches (evidence: `README.md`)
- Morphe patcher → Target APK: patches APK (evidence: `README.md`)
- Brave patches → Target APK: modifies app
- Chromium patches → Target APK: modifies app
- Gboard patches → Target APK: modifies app
- TikTok privacy → Target APK: modifies app
- TikTok usability → Target APK: modifies app
- TikTok performance → Target APK: modifies app
- TikTok asset trimming → Target APK: trims assets
- Other app patches → Target APK: modifies app
- Universal patches → Target APK: modifies app
- Gboard extension → Gboard languages: uses languages (evidence: `extensions/extension/src/main/java/com/kveld9/morphe/extension/gboard/GboardExtension.java`)
- Pipeline executor → APK extraction: reads APK (evidence: `harness/core/pipeline.py`)
- Pipeline executor → DEX indexing: indexes DEX (evidence: `harness/core/pipeline.py`)
- Pipeline executor → ELF analysis: analyzes native (evidence: `harness/core/pipeline.py`)
- Pipeline executor → Audit reports: writes report (evidence: `harness/core/pipeline.py`)
- Fingerprint queries → DEX indexing: queries DEX (evidence: `harness/core/fingerprints.py`)
- Symbol resolution → DEX indexing: queries DEX (evidence: `harness/core/symbols.py`)
- Telemetry scan → ELF analysis: scans ELF (evidence: `harness/core/telemetry.py`)
- Gboard contracts → Fingerprint queries: defines queries (evidence: `harness/gboard/contracts.py`)
- Gboard invariants → APK extraction: checks package (evidence: `harness/gboard/invariants.py`)
- Gboard invariants → DEX indexing: checks classes (evidence: `harness/gboard/invariants.py`)
- Gboard theme audit → DEX indexing: checks references (evidence: `harness/gboard/themes.py`)
- Gboard validator → Gboard contracts: audits contracts (evidence: `harness/gboard/validator.py`)
- Gboard validator → Gboard invariants: runs checks (evidence: `harness/gboard/validator.py`)
- Gboard validator → Gboard theme audit: audits themes (evidence: `harness/gboard/validator.py`)
- TikTok validator → TikTok contracts: audits contracts (evidence: `harness/tiktok/validator.py`)
- TikTok validator → DEX indexing: checks DEX (evidence: `harness/tiktok/validator.py`)
- TikTok validator → Audit reports: reports results (evidence: `harness/tiktok/validator.py`)
