# chame1eon/jnitrace architecture

> Architecture diagram of the GitHub repository chame1eon/jnitrace, 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/chame1eon/jnitrace
- Repository: https://github.com/chame1eon/jnitrace

## Overview

jnitrace is a Frida-based dynamic analyzer for JNI calls in Android apps. The user selects an installed app, libraries and trace options; the Python CLI connects to Frida and injects the tracing script. The injected runtime watches libraries, configures JNI/JavaVM interceptions, turns calls into structured trace data, and reports it for console display or JSON output. The graph includes the sampled data-model and type helpers. README capabilities such as filtering, backtraces and custom scripts are represented where supported; unsampled host-side callback wiring is not inferred.

Main entry points: [`jnitrace/jnitrace.py`](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/jnitrace.py) (CLI and injection), [`jnitrace/src/main.ts`](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/main.ts) (JNI interception), [`jnitrace/src/transport/data_transport.ts`](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/transport/data_transport.ts) (Trace transport), [`jnitrace/src/utils/method_data.ts`](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/method_data.ts) (Call data model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host CLI"]
  node_cli["CLI and injection<br/>[jnitrace.py]"]
  node_display["Trace output<br/>[jnitrace.py]"]
end

subgraph group_runtime["Injected tracer"]
  node_watcher["Library watcher<br/>[main.ts]"]
  node_interception["JNI interception<br/>[main.ts]"]
end

subgraph group_data["Trace data"]
  node_transport["Trace transport<br/>[data_transport.ts]"]
  node_methoddata["Call data model<br/>[method_data.ts]"]
  node_types["JNI type conversion<br/>[types.ts]"]
  node_signature["Java signature parser<br/>[java_method.ts]"]
end

subgraph group_external["External runtime"]
  node_engine["JNI tracing engine"]
  node_frida["Frida device/server"]
  node_android["Android app"]
end

node_user(("Analyst"))

node_user -->|"configures trace"| node_cli
node_cli -->|"connects and injects"| node_frida
node_cli -->|"posts configuration"| node_watcher
node_frida -->|"runs script in"| node_android
node_watcher -->|"registers load callback"| node_engine
node_interception -->|"attaches callbacks"| node_engine
node_android -.->|"invokes JNI calls"| node_interception
node_interception -->|"constructs call data"| node_methoddata
node_interception -->|"reports calls"| node_transport
node_transport -->|"reads call fields"| node_methoddata
node_transport -->|"uses type helpers"| node_types
node_signature -->|"converts signatures"| node_types
node_transport -.->|"sends trace records"| node_display
node_cli -->|"renders and saves"| node_display

click node_cli "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/jnitrace.py"
click node_display "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/jnitrace.py"
click node_watcher "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/main.ts"
click node_interception "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/main.ts"
click node_transport "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/transport/data_transport.ts"
click node_methoddata "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/method_data.ts"
click node_types "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/types.ts"
click node_signature "https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/java_method.ts"

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_display toneBlue
class node_watcher,node_interception toneAmber
class node_transport,node_methoddata,node_types,node_signature toneMint
class node_engine,node_frida,node_android toneRose
class node_user toneIndigo
```

## Components

### Host CLI

- [CLI and injection](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/jnitrace.py): `jnitrace/jnitrace.py`
- [Trace output](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/jnitrace.py): `jnitrace/jnitrace.py`

### Injected tracer

- [Library watcher](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/main.ts): `jnitrace/src/main.ts`
- [JNI interception](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/main.ts): `jnitrace/src/main.ts`

### Trace data

- [Trace transport](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/transport/data_transport.ts): `jnitrace/src/transport/data_transport.ts`
- [Call data model](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/method_data.ts): `jnitrace/src/utils/method_data.ts`
- [JNI type conversion](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/types.ts): `jnitrace/src/utils/types.ts`
- [Java signature parser](https://github.com/chame1eon/jnitrace/blob/master/jnitrace/src/utils/java_method.ts): `jnitrace/src/utils/java_method.ts`

### External runtime

- **JNI tracing engine**
- **Frida device/server**
- **Android app**

### Other components

- **Analyst**

## Connections

- Analyst → CLI and injection: configures trace (evidence: `README.md`)
- CLI and injection → Frida device/server: connects and injects (evidence: `README.md`)
- CLI and injection → Library watcher: posts configuration (evidence: `jnitrace/jnitrace.py`)
- Frida device/server → Android app: runs script in (evidence: `README.md`)
- Library watcher → JNI tracing engine: registers load callback (evidence: `jnitrace/src/main.ts`)
- JNI interception → JNI tracing engine: attaches callbacks (evidence: `jnitrace/src/main.ts`)
- Android app → JNI interception: invokes JNI calls
- JNI interception → Call data model: constructs call data (evidence: `jnitrace/src/main.ts`)
- JNI interception → Trace transport: reports calls (evidence: `jnitrace/src/main.ts`)
- Trace transport → Call data model: reads call fields (evidence: `jnitrace/src/transport/data_transport.ts`)
- Trace transport → JNI type conversion: uses type helpers (evidence: `jnitrace/src/transport/data_transport.ts`)
- Java signature parser → JNI type conversion: converts signatures (evidence: `jnitrace/src/utils/java_method.ts`)
- Trace transport → Trace output: sends trace records
- CLI and injection → Trace output: renders and saves (evidence: `README.md`)
