# lovelyzy7/lunar-scripts-jp architecture

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

- Interactive diagram: https://gitdiagram.com/lovelyzy7/lunar-scripts-jp
- Repository: https://github.com/lovelyzy7/lunar-scripts-jp

## Overview

This repository is a NieR Re[in]carnation JP private-server client patch toolkit. The principal workflow takes a decompiled APK, applies endpoint and client-behavior patches, then rebuilds and signs an installable APK; the local runner can optionally patch master data. Separate utilities handle Octo asset bundles and their catalog, plus master-data extraction and export. The README documents these capabilities and the workflow; source excerpts are partial, so the graph omits unverified internal patch call relationships.

Main entry points: [`android/patch_apk_jp.py`](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py) (Client Patcher), [`local/run_local.py`](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/local/run_local.py) (Local Runner), [`assetbundles/assetbundle_crypt.py`](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/assetbundle_crypt.py) (Bundle Crypto), [`assetbundles/decrypt_assetbundle.py`](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/decrypt_assetbundle.py) (Bundle Decryption)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apk["APK Client Patching"]
  node_patcher["Client Patcher<br/>[patch_apk_jp.py]"]
  node_endpoint["Endpoint Rewriting<br/>[patch_apk_jp.py]"]
  node_network["Network Bypass<br/>[patch_apk_jp.py]"]
  node_purchase["Purchase Patches<br/>[patch_apk_jp.py]"]
  node_auth["Dynamic Auth<br/>[patch_apk_jp.py]"]
  node_build["APK Build and Sign<br/>[build_apk.py]"]
end

subgraph group_asset["Asset Bundles"]
  node_crypto["Bundle Crypto"]
  node_decrypt["Bundle Decryption"]
  node_encrypt["Bundle Encryption"]
  node_listbin["Catalog Refresh<br/>[patch_listbin.py]"]
  node_octo["Octo Protobuf<br/>[octo_pb2.py]"]
end

subgraph group_master["Master Data"]
  node_dump["Master Data Dump<br/>[dump_masterdata.py]"]
  node_extract["Table Extraction"]
  node_convert["JSON Conversion<br/>[msgpack_to_json.py]"]
  node_masterpatch["Master Data Patch"]
end

subgraph group_local["Local Workflow"]
  node_local["Local Runner<br/>[run_local.py]"]
end

node_operator(("Toolkit User"))
node_decompiled["Decompiled APK"]

node_operator -->|"runs workflow"| node_local
node_operator -->|"configures patches"| node_patcher
node_decompiled -->|"patches input"| node_patcher
node_patcher -->|"rewrites endpoints"| node_endpoint
node_patcher -->|"bypasses checks"| node_network
node_patcher -->|"patches purchases"| node_purchase
node_patcher -->|"adds dynamic auth"| node_auth
node_local -->|"invokes patcher"| node_patcher
node_local -->|"optionally invokes"| node_masterpatch
node_local -->|"invokes build"| node_build
node_decrypt -->|"uses helpers"| node_crypto
node_encrypt -->|"uses helpers"| node_crypto
node_listbin -->|"uses schema"| node_octo

click node_patcher "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py"
click node_endpoint "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py"
click node_network "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py"
click node_purchase "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py"
click node_auth "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py"
click node_build "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/build_apk.py"
click node_crypto "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/assetbundle_crypt.py"
click node_decrypt "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/decrypt_assetbundle.py"
click node_encrypt "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/encrypt_assetbundle.py"
click node_listbin "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/patch_listbin.py"
click node_octo "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/octo_pb2.py"
click node_dump "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/dump_masterdata.py"
click node_extract "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/extract_master_data.py"
click node_convert "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/msgpack_to_json.py"
click node_masterpatch "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/patch_masterdata.py"
click node_local "https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/local/run_local.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_patcher,node_endpoint,node_network,node_purchase,node_auth,node_build,node_operator toneBlue
class node_crypto,node_decrypt,node_encrypt,node_listbin,node_octo toneAmber
class node_dump,node_extract,node_convert,node_masterpatch toneMint
class node_local toneRose
class node_decompiled toneIndigo
```

## Components

### APK Client Patching

- [Client Patcher](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py): `android/patch_apk_jp.py`
- [Endpoint Rewriting](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py): `android/patch_apk_jp.py`
- [Network Bypass](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py): `android/patch_apk_jp.py`
- [Purchase Patches](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py): `android/patch_apk_jp.py`
- [Dynamic Auth](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/patch_apk_jp.py): `android/patch_apk_jp.py`
- [APK Build and Sign](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/android/build_apk.py): `android/build_apk.py`

### Asset Bundles

- [Bundle Crypto](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/assetbundle_crypt.py): `assetbundles/assetbundle_crypt.py`
- [Bundle Decryption](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/decrypt_assetbundle.py): `assetbundles/decrypt_assetbundle.py`
- [Bundle Encryption](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/encrypt_assetbundle.py): `assetbundles/encrypt_assetbundle.py`
- [Catalog Refresh](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/patch_listbin.py): `assetbundles/patch_listbin.py`
- [Octo Protobuf](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/assetbundles/octo_pb2.py): `assetbundles/octo_pb2.py`

### Master Data

- [Master Data Dump](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/dump_masterdata.py): `masterdata/dump_masterdata.py`
- [Table Extraction](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/extract_master_data.py): `masterdata/extract_master_data.py`
- [JSON Conversion](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/msgpack_to_json.py): `masterdata/msgpack_to_json.py`
- [Master Data Patch](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/masterdata/patch_masterdata.py): `masterdata/patch_masterdata.py`

### Local Workflow

- [Local Runner](https://github.com/lovelyzy7/lunar-scripts-jp/blob/main/local/run_local.py): `local/run_local.py`

### Other components

- **Toolkit User**
- **Decompiled APK**

## Connections

- Toolkit User → Local Runner: runs workflow (evidence: `README.md`)
- Toolkit User → Client Patcher: configures patches (evidence: `README.md`)
- Decompiled APK → Client Patcher: patches input (evidence: `README.md`)
- Client Patcher → Endpoint Rewriting: rewrites endpoints (evidence: `README.md`)
- Client Patcher → Network Bypass: bypasses checks (evidence: `README.md`)
- Client Patcher → Purchase Patches: patches purchases (evidence: `README.md`)
- Client Patcher → Dynamic Auth: adds dynamic auth (evidence: `README.md`)
- Local Runner → Client Patcher: invokes patcher (evidence: `local/run_local.py`)
- Local Runner → Master Data Patch: optionally invokes (evidence: `local/run_local.py`)
- Local Runner → APK Build and Sign: invokes build (evidence: `local/run_local.py`)
- Bundle Decryption → Bundle Crypto: uses helpers (evidence: `assetbundles/decrypt_assetbundle.py`)
- Bundle Encryption → Bundle Crypto: uses helpers (evidence: `assetbundles/encrypt_assetbundle.py`)
- Catalog Refresh → Octo Protobuf: uses schema (evidence: `assetbundles/patch_listbin.py`)
