# xiansheng-lu/rea architecture

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

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

## Overview

REA is a local reverse-engineering MCP server and CLI. The principal workflow is an agent or CLI user submitting a target and investigation request, REA selecting analysis capabilities, and returning findings with supporting evidence and limitations. Documented analysis spans native binaries, JavaScript/Electron, managed assemblies, websites, and specialized artifact formats. The main entry point’s wiring is visible in the excerpt; several capability links are documented in the README, while unsampled internals are not inferred.

Main entry points: [`src/main.ts`](https://github.com/xiansheng-lu/rea/blob/main/src/main.ts) (MCP server), [`src/application/AnalysisProvider.ts`](https://github.com/xiansheng-lu/rea/blob/main/src/application/AnalysisProvider.ts) (Analysis provider API), [`src/server/contractToolHandler.ts`](https://github.com/xiansheng-lu/rea/blob/main/src/server/contractToolHandler.ts) (Tool handler), [`src/application/binary/SessionProviderRouter.ts`](https://github.com/xiansheng-lu/rea/blob/main/src/application/binary/SessionProviderRouter.ts) (Binary session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_mcp["MCP server<br/>[main.ts]"]
  node_toolhandler["Tool handler"]
  node_session["Binary session"]
  node_evidence["Evidence results<br/>[evidence.ts]"]
end

subgraph group_native["Native analysis"]
  node_nativeapi["Analysis provider API"]
  node_ghidra["Ghidra provider"]
  node_hopper["Hopper client<br/>[HopperClient.ts]"]
  node_ida["IDA client"]
end

subgraph group_application["Application analysis"]
  node_jsanalysis["JavaScript analysis"]
  node_jsworker["JavaScript worker"]
  node_browser["Browser observation"]
  node_managed[".NET analysis"]
  node_android["Android analysis"]
end

subgraph group_artifacts["Artifact analysis"]
  node_elf["ELF diagnostics"]
  node_go["Go inspection<br/>[GoBinaryService.ts]"]
  node_evm["EVM interface"]
  node_sqlite["SQLite inspection"]
end

node_agent(("Agent"))
node_cli(("CLI user"))

node_agent -->|"requests analysis"| node_mcp
node_cli -->|"runs workflows"| node_mcp
node_mcp -->|"creates session"| node_session
node_mcp -->|"starts transport"| node_toolhandler
node_toolhandler -->|"uses provider API"| node_nativeapi
node_session -->|"routes providers"| node_nativeapi
node_nativeapi -->|"implemented by"| node_ghidra
node_ghidra -.->|"records findings"| node_evidence
node_agent -.->|"requests app analysis"| node_jsanalysis
node_agent -.->|"requests observation"| node_browser
node_agent -.->|"requests inspection"| node_managed
node_agent -.->|"requests inspection"| node_android
node_agent -.->|"requests diagnostics"| node_elf
node_agent -.->|"requests inspection"| node_go
node_agent -.->|"requests analysis"| node_evm
node_agent -.->|"requests inspection"| node_sqlite
node_jsanalysis -.->|"delegates analysis"| node_jsworker
node_mcp -.->|"returns findings"| node_evidence
node_hopper -.->|"implements provider"| node_nativeapi
node_ida -->|"implements provider"| node_nativeapi

click node_mcp "https://github.com/xiansheng-lu/rea/blob/main/src/main.ts"
click node_toolhandler "https://github.com/xiansheng-lu/rea/blob/main/src/server/contractToolHandler.ts"
click node_session "https://github.com/xiansheng-lu/rea/blob/main/src/application/binary/SessionProviderRouter.ts"
click node_evidence "https://github.com/xiansheng-lu/rea/blob/main/src/domain/evidence.ts"
click node_nativeapi "https://github.com/xiansheng-lu/rea/blob/main/src/application/AnalysisProvider.ts"
click node_ghidra "https://github.com/xiansheng-lu/rea/blob/main/src/ghidra/GhidraProviderClient.ts"
click node_hopper "https://github.com/xiansheng-lu/rea/blob/main/src/hopper/HopperClient.ts"
click node_ida "https://github.com/xiansheng-lu/rea/blob/main/src/ida/IdaSessionClient.ts"
click node_jsanalysis "https://github.com/xiansheng-lu/rea/blob/main/src/application/javascript/JavaScriptApplicationService.ts"
click node_jsworker "https://github.com/xiansheng-lu/rea/blob/main/src/javascript/analysis/JavaScriptAnalysisWorker.ts"
click node_browser "https://github.com/xiansheng-lu/rea/blob/main/src/application/BrowserObservationService.ts"
click node_managed "https://github.com/xiansheng-lu/rea/blob/main/src/application/managed/ManagedMemberComparisonService.ts"
click node_android "https://github.com/xiansheng-lu/rea/blob/main/src/application/android/AndroidAnalysisService.ts"
click node_elf "https://github.com/xiansheng-lu/rea/blob/main/src/application/binaryDiagnostics/BinaryLayoutService.ts"
click node_go "https://github.com/xiansheng-lu/rea/blob/main/src/application/go/GoBinaryService.ts"
click node_evm "https://github.com/xiansheng-lu/rea/blob/main/src/application/evm/EvmInterfaceService.ts"
click node_sqlite "https://github.com/xiansheng-lu/rea/blob/main/src/sqlite/SqliteDatabaseInspection.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_mcp,node_toolhandler,node_session,node_evidence,node_cli toneBlue
class node_nativeapi,node_ghidra,node_hopper,node_ida toneAmber
class node_jsanalysis,node_jsworker,node_browser,node_managed,node_android toneMint
class node_elf,node_go,node_evm,node_sqlite toneRose
class node_agent toneIndigo
```

## Components

### Entry and orchestration

- [MCP server](https://github.com/xiansheng-lu/rea/blob/main/src/main.ts): `src/main.ts`
- [Tool handler](https://github.com/xiansheng-lu/rea/blob/main/src/server/contractToolHandler.ts): `src/server/contractToolHandler.ts`
- [Binary session](https://github.com/xiansheng-lu/rea/blob/main/src/application/binary/SessionProviderRouter.ts): `src/application/binary/SessionProviderRouter.ts`
- [Evidence results](https://github.com/xiansheng-lu/rea/blob/main/src/domain/evidence.ts): `src/domain/evidence.ts`

### Native analysis

- [Analysis provider API](https://github.com/xiansheng-lu/rea/blob/main/src/application/AnalysisProvider.ts): `src/application/AnalysisProvider.ts`
- [Ghidra provider](https://github.com/xiansheng-lu/rea/blob/main/src/ghidra/GhidraProviderClient.ts): `src/ghidra/GhidraProviderClient.ts`
- [Hopper client](https://github.com/xiansheng-lu/rea/blob/main/src/hopper/HopperClient.ts): `src/hopper/HopperClient.ts`
- [IDA client](https://github.com/xiansheng-lu/rea/blob/main/src/ida/IdaSessionClient.ts): `src/ida/IdaSessionClient.ts`

### Application analysis

- [JavaScript analysis](https://github.com/xiansheng-lu/rea/blob/main/src/application/javascript/JavaScriptApplicationService.ts): `src/application/javascript/JavaScriptApplicationService.ts`
- [JavaScript worker](https://github.com/xiansheng-lu/rea/blob/main/src/javascript/analysis/JavaScriptAnalysisWorker.ts): `src/javascript/analysis/JavaScriptAnalysisWorker.ts`
- [Browser observation](https://github.com/xiansheng-lu/rea/blob/main/src/application/BrowserObservationService.ts): `src/application/BrowserObservationService.ts`
- [.NET analysis](https://github.com/xiansheng-lu/rea/blob/main/src/application/managed/ManagedMemberComparisonService.ts): `src/application/managed/ManagedMemberComparisonService.ts`
- [Android analysis](https://github.com/xiansheng-lu/rea/blob/main/src/application/android/AndroidAnalysisService.ts): `src/application/android/AndroidAnalysisService.ts`

### Artifact analysis

- [ELF diagnostics](https://github.com/xiansheng-lu/rea/blob/main/src/application/binaryDiagnostics/BinaryLayoutService.ts): `src/application/binaryDiagnostics/BinaryLayoutService.ts`
- [Go inspection](https://github.com/xiansheng-lu/rea/blob/main/src/application/go/GoBinaryService.ts): `src/application/go/GoBinaryService.ts`
- [EVM interface](https://github.com/xiansheng-lu/rea/blob/main/src/application/evm/EvmInterfaceService.ts): `src/application/evm/EvmInterfaceService.ts`
- [SQLite inspection](https://github.com/xiansheng-lu/rea/blob/main/src/sqlite/SqliteDatabaseInspection.ts): `src/sqlite/SqliteDatabaseInspection.ts`

### Other components

- **Agent**
- **CLI user**

## Connections

- Agent → MCP server: requests analysis (evidence: `README.md`)
- CLI user → MCP server: runs workflows (evidence: `README.md`)
- MCP server → Binary session: creates session (evidence: `src/main.ts`)
- MCP server → Tool handler: starts transport (evidence: `src/main.ts`)
- Tool handler → Analysis provider API: uses provider API (evidence: `src/server/contractToolHandler.ts`)
- Binary session → Analysis provider API: routes providers (evidence: `src/application/binary/SessionProviderRouter.ts`)
- Analysis provider API → Ghidra provider: implemented by (evidence: `src/ghidra/GhidraProviderClient.ts`)
- Ghidra provider → Evidence results: records findings (evidence: `src/ghidra/GhidraProviderClient.ts`)
- Agent → JavaScript analysis: requests app analysis
- Agent → Browser observation: requests observation
- Agent → .NET analysis: requests inspection
- Agent → Android analysis: requests inspection
- Agent → ELF diagnostics: requests diagnostics
- Agent → Go inspection: requests inspection
- Agent → EVM interface: requests analysis
- Agent → SQLite inspection: requests inspection
- JavaScript analysis → JavaScript worker: delegates analysis
- MCP server → Evidence results: returns findings
- Hopper client → Analysis provider API: implements provider
- IDA client → Analysis provider API: implements provider (evidence: `src/ida/IdaSessionClient.ts`)
