# tanbui/rea architecture

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

- Interactive diagram: https://gitdiagram.com/tanbui/rea
- Repository: https://github.com/tanbui/rea

## Overview

REA is a local reverse-engineering toolkit exposed to agents through MCP and to engineers through a CLI. The principal workflow is an agent or terminal user requesting analysis, a tool or command routing the request to analysis logic, and a provider producing evidence. The README also highlights JavaScript/Electron and website analysis, binary analysis, and runtime behavior. Edges are limited to relationships visible in the README or sampled source references; unsampled feature implementations are shown without speculative wiring.

Main entry points: [`src/domain/evidence.ts`](https://github.com/tanbui/rea/blob/main/src/domain/evidence.ts) (Analysis evidence), [`src/application/reverse/ReverseEngineeringService.ts`](https://github.com/tanbui/rea/blob/main/src/application/reverse/ReverseEngineeringService.ts) (Reverse analysis), [`src/cli/reverseEngineeringCommands.ts`](https://github.com/tanbui/rea/blob/main/src/cli/reverseEngineeringCommands.ts) (Reverse CLI), [`src/main.ts`](https://github.com/tanbui/rea/blob/main/src/main.ts) (MCP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_mcp["MCP server<br/>[main.ts]"]
  node_tool_routes["Reverse tool routes"]
  node_cli["Reverse CLI"]
end

subgraph group_analysis["Analysis services"]
  node_reverse_service["Reverse analysis"]
  node_reverse_contracts["Tool contracts"]
  node_js_scan["JavaScript routes"]
  node_js_view["JavaScript views"]
  node_coverage["Coverage service"]
end

subgraph group_providers["Analysis providers"]
  node_ghidra["Ghidra client<br/>[GhidraClient.ts]"]
  node_ida["IDA client"]
  node_kuna["Kuna client"]
  node_hopper["Hopper client<br/>[HopperClient.ts]"]
  node_gdb["GDB sessions"]
  node_rizin_debug["Rizin debugging"]
end

subgraph group_evidence["Evidence and results"]
  node_evidence["Analysis evidence<br/>[evidence.ts]"]
  node_error_projection["Error projection"]
  node_msix[("MSIX storage")]
end

subgraph group_runtime["Runtime inspection"]
  node_browser_capture["Browser capture"]
  node_browser_scenarios["Browser scenarios"]
  node_frida["Frida instrumentation"]
  node_native_calls["Native call routes"]
  node_sqlite["SQLite inspection"]
  node_website_worker["Website runtime<br/>[worker.mjs]"]
end

node_agent(("Agent"))
node_terminal(("Terminal user"))

node_agent -->|"calls tools"| node_mcp
node_terminal -->|"runs commands"| node_cli
node_mcp -->|"registers tools"| node_tool_routes
node_tool_routes -->|"invokes"| node_reverse_service
node_cli -->|"invokes"| node_reverse_service
node_reverse_service -->|"returns evidence"| node_evidence
node_reverse_service -->|"uses errors"| node_error_projection
node_cli -->|"imports contracts"| node_reverse_contracts
node_js_view -->|"uses route facts"| node_js_scan
node_msix -->|"uses result types"| node_evidence
node_gdb -->|"uses evidence types"| node_evidence
node_rizin_debug -->|"uses evidence types"| node_evidence
node_kuna -->|"uses evidence types"| node_evidence
node_browser_capture -.-> node_browser_scenarios

click node_mcp "https://github.com/tanbui/rea/blob/main/src/main.ts"
click node_tool_routes "https://github.com/tanbui/rea/blob/main/src/server/registerReverseEngineeringTools.ts"
click node_cli "https://github.com/tanbui/rea/blob/main/src/cli/reverseEngineeringCommands.ts"
click node_reverse_service "https://github.com/tanbui/rea/blob/main/src/application/reverse/ReverseEngineeringService.ts"
click node_reverse_contracts "https://github.com/tanbui/rea/blob/main/src/contracts/reverseEngineeringToolContracts.ts"
click node_js_scan "https://github.com/tanbui/rea/blob/main/src/domain/javascript/javascriptRouteScan.ts"
click node_js_view "https://github.com/tanbui/rea/blob/main/src/domain/analysisView/javascriptRoutesView.ts"
click node_coverage "https://github.com/tanbui/rea/blob/main/src/application/ReconstructionCoverageService.ts"
click node_ghidra "https://github.com/tanbui/rea/blob/main/src/ghidra/GhidraClient.ts"
click node_ida "https://github.com/tanbui/rea/blob/main/src/ida/IdaSessionClient.ts"
click node_kuna "https://github.com/tanbui/rea/blob/main/src/kuna/KunaSessionClient.ts"
click node_hopper "https://github.com/tanbui/rea/blob/main/src/hopper/HopperClient.ts"
click node_gdb "https://github.com/tanbui/rea/blob/main/src/gdb/GdbSessionManager.ts"
click node_rizin_debug "https://github.com/tanbui/rea/blob/main/src/rizin/RizinDebugSessionManager.ts"
click node_evidence "https://github.com/tanbui/rea/blob/main/src/domain/evidence.ts"
click node_error_projection "https://github.com/tanbui/rea/blob/main/src/domain/analysisErrorProjection.ts"
click node_msix "https://github.com/tanbui/rea/blob/main/src/application/MsixPackageStorage.ts"
click node_browser_capture "https://github.com/tanbui/rea/blob/main/src/browser/CdpCaptureStorageFingerprints.ts"
click node_browser_scenarios "https://github.com/tanbui/rea/blob/main/src/browser/PlaywrightScenarioStorage.ts"
click node_frida "https://github.com/tanbui/rea/blob/main/src/frida/FridaInstrumentationManager.ts"
click node_native_calls "https://github.com/tanbui/rea/blob/main/src/application/native/NativeCallRoutes.ts"
click node_sqlite "https://github.com/tanbui/rea/blob/main/src/sqlite/SqliteDatabaseInspection.ts"
click node_website_worker "https://github.com/tanbui/rea/blob/main/website/worker.mjs"

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_mcp,node_tool_routes,node_cli,node_terminal toneBlue
class node_reverse_service,node_reverse_contracts,node_js_scan,node_js_view,node_coverage toneAmber
class node_ghidra,node_ida,node_kuna,node_hopper,node_gdb,node_rizin_debug toneMint
class node_evidence,node_error_projection,node_msix toneRose
class node_browser_capture,node_browser_scenarios,node_frida,node_native_calls,node_sqlite,node_website_worker,node_agent toneIndigo
```

## Components

### User entry points

- [MCP server](https://github.com/tanbui/rea/blob/main/src/main.ts): `src/main.ts`
- [Reverse tool routes](https://github.com/tanbui/rea/blob/main/src/server/registerReverseEngineeringTools.ts): `src/server/registerReverseEngineeringTools.ts`
- [Reverse CLI](https://github.com/tanbui/rea/blob/main/src/cli/reverseEngineeringCommands.ts): `src/cli/reverseEngineeringCommands.ts`

### Analysis services

- [Reverse analysis](https://github.com/tanbui/rea/blob/main/src/application/reverse/ReverseEngineeringService.ts): `src/application/reverse/ReverseEngineeringService.ts`
- [Tool contracts](https://github.com/tanbui/rea/blob/main/src/contracts/reverseEngineeringToolContracts.ts): `src/contracts/reverseEngineeringToolContracts.ts`
- [JavaScript routes](https://github.com/tanbui/rea/blob/main/src/domain/javascript/javascriptRouteScan.ts): `src/domain/javascript/javascriptRouteScan.ts`
- [JavaScript views](https://github.com/tanbui/rea/blob/main/src/domain/analysisView/javascriptRoutesView.ts): `src/domain/analysisView/javascriptRoutesView.ts`
- [Coverage service](https://github.com/tanbui/rea/blob/main/src/application/ReconstructionCoverageService.ts): `src/application/ReconstructionCoverageService.ts`

### Analysis providers

- [Ghidra client](https://github.com/tanbui/rea/blob/main/src/ghidra/GhidraClient.ts): `src/ghidra/GhidraClient.ts`
- [IDA client](https://github.com/tanbui/rea/blob/main/src/ida/IdaSessionClient.ts): `src/ida/IdaSessionClient.ts`
- [Kuna client](https://github.com/tanbui/rea/blob/main/src/kuna/KunaSessionClient.ts): `src/kuna/KunaSessionClient.ts`
- [Hopper client](https://github.com/tanbui/rea/blob/main/src/hopper/HopperClient.ts): `src/hopper/HopperClient.ts`
- [GDB sessions](https://github.com/tanbui/rea/blob/main/src/gdb/GdbSessionManager.ts): `src/gdb/GdbSessionManager.ts`
- [Rizin debugging](https://github.com/tanbui/rea/blob/main/src/rizin/RizinDebugSessionManager.ts): `src/rizin/RizinDebugSessionManager.ts`

### Evidence and results

- [Analysis evidence](https://github.com/tanbui/rea/blob/main/src/domain/evidence.ts): `src/domain/evidence.ts`
- [Error projection](https://github.com/tanbui/rea/blob/main/src/domain/analysisErrorProjection.ts): `src/domain/analysisErrorProjection.ts`
- [MSIX storage](https://github.com/tanbui/rea/blob/main/src/application/MsixPackageStorage.ts): `src/application/MsixPackageStorage.ts`

### Runtime inspection

- [Browser capture](https://github.com/tanbui/rea/blob/main/src/browser/CdpCaptureStorageFingerprints.ts): `src/browser/CdpCaptureStorageFingerprints.ts`
- [Browser scenarios](https://github.com/tanbui/rea/blob/main/src/browser/PlaywrightScenarioStorage.ts): `src/browser/PlaywrightScenarioStorage.ts`
- [Frida instrumentation](https://github.com/tanbui/rea/blob/main/src/frida/FridaInstrumentationManager.ts): `src/frida/FridaInstrumentationManager.ts`
- [Native call routes](https://github.com/tanbui/rea/blob/main/src/application/native/NativeCallRoutes.ts): `src/application/native/NativeCallRoutes.ts`
- [SQLite inspection](https://github.com/tanbui/rea/blob/main/src/sqlite/SqliteDatabaseInspection.ts): `src/sqlite/SqliteDatabaseInspection.ts`
- [Website runtime](https://github.com/tanbui/rea/blob/main/website/worker.mjs): `website/worker.mjs`

### Other components

- **Agent**
- **Terminal user**

## Connections

- Agent → MCP server: calls tools (evidence: `README.md`)
- Terminal user → Reverse CLI: runs commands (evidence: `README.md`)
- MCP server → Reverse tool routes: registers tools (evidence: `src/main.ts`)
- Reverse tool routes → Reverse analysis: invokes (evidence: `src/server/registerReverseEngineeringTools.ts`)
- Reverse CLI → Reverse analysis: invokes (evidence: `src/cli/reverseEngineeringCommands.ts`)
- Reverse analysis → Analysis evidence: returns evidence (evidence: `src/application/reverse/ReverseEngineeringService.ts`)
- Reverse analysis → Error projection: uses errors (evidence: `src/application/reverse/ReverseEngineeringService.ts`)
- Reverse CLI → Tool contracts: imports contracts (evidence: `src/cli/reverseEngineeringCommands.ts`)
- JavaScript views → JavaScript routes: uses route facts (evidence: `src/domain/analysisView/javascriptRoutesView.ts`)
- MSIX storage → Analysis evidence: uses result types (evidence: `src/application/MsixPackageStorage.ts`)
- GDB sessions → Analysis evidence: uses evidence types (evidence: `src/gdb/GdbSessionManager.ts`)
- Rizin debugging → Analysis evidence: uses evidence types (evidence: `src/rizin/RizinDebugSessionManager.ts`)
- Kuna client → Analysis evidence: uses evidence types (evidence: `src/kuna/KunaSessionClient.ts`)
- Browser capture → Browser scenarios
