# shijianzhong/rea architecture

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

## Overview

REA is a local reverse-engineering toolkit exposed through an MCP server and a CLI. An agent or terminal user supplies an application or binary; REA routes analysis to suitable providers and returns findings with evidence and limitations. The README documents static JavaScript/Electron analysis, native-engine analysis, browser/runtime observation, managed and mobile analysis, and reconstruction workflows. Sampled source confirms MCP startup and session creation, provider routing, and some provider adapters; links to other capabilities are documented at the product level rather than verified through their full implementation.

Main entry points: [`src/application/binary/SessionProviderRouter.ts`](https://github.com/shijianzhong/rea/blob/main/src/application/binary/SessionProviderRouter.ts) (Provider router), [`src/main.ts`](https://github.com/shijianzhong/rea/blob/main/src/main.ts) (MCP server), [`src/application/javascript/JavaScriptApplicationWorkflowService.ts`](https://github.com/shijianzhong/rea/blob/main/src/application/javascript/JavaScriptApplicationWorkflowService.ts) (JavaScript analysis), [`src/composition/binary.ts`](https://github.com/shijianzhong/rea/blob/main/src/composition/binary.ts) (Binary session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_mcp["MCP server<br/>[main.ts]"]
  node_cli["CLI<br/>[cli.ts]"]
end

subgraph group_orchestration["Analysis orchestration"]
  node_session["Binary session<br/>[binary.ts]"]
  node_router["Provider router"]
  node_provider_api["Provider API"]
end

subgraph group_analysis["Analysis capabilities"]
  node_artifacts["Artifact inspection"]
  node_javascript["JavaScript analysis"]
  node_browser["Browser observation"]
  node_managed["Managed analysis"]
  node_android["Android analysis"]
  node_firmware["Firmware analysis"]
  node_reconstruction["Reconstruction coverage"]
end

subgraph group_providers["Analysis providers"]
  node_ghidra["Ghidra adapter"]
  node_hopper["Hopper adapter<br/>[HopperClient.ts]"]
  node_ida["IDA adapter"]
end

subgraph group_results["Evidence and results"]
  node_evidence["Evidence output<br/>[BrowserEvidence.ts]"]
  node_errors["Safe error projection"]
end

node_agent(("AI agent"))
node_terminal(("Terminal user"))

node_agent -->|"uses tools"| node_mcp
node_terminal -->|"runs commands"| node_cli
node_mcp -->|"creates session"| node_session
node_mcp -->|"projects errors"| node_errors
node_session -.->|"routes analysis"| node_router
node_router -->|"uses provider API"| node_provider_api
node_agent -->|"requests analysis"| node_javascript
node_terminal -->|"runs analysis"| node_javascript
node_agent -->|"requests inspection"| node_artifacts
node_agent -->|"requests observation"| node_browser
node_agent -->|"requests analysis"| node_managed
node_agent -->|"requests analysis"| node_android
node_agent -->|"requests analysis"| node_firmware
node_agent -->|"requests assessment"| node_reconstruction
node_router -.->|"selects provider"| node_ghidra
node_router -.->|"selects provider"| node_hopper
node_router -.->|"selects provider"| node_ida
node_javascript -->|"returns evidence"| node_evidence
node_browser -->|"returns evidence"| node_evidence

click node_mcp "https://github.com/shijianzhong/rea/blob/main/src/main.ts"
click node_cli "https://github.com/shijianzhong/rea/blob/main/src/cli.ts"
click node_session "https://github.com/shijianzhong/rea/blob/main/src/composition/binary.ts"
click node_router "https://github.com/shijianzhong/rea/blob/main/src/application/binary/SessionProviderRouter.ts"
click node_provider_api "https://github.com/shijianzhong/rea/blob/main/src/application/AnalysisProvider.ts"
click node_artifacts "https://github.com/shijianzhong/rea/blob/main/src/artifacts/inventory/ArtifactInventory.ts"
click node_javascript "https://github.com/shijianzhong/rea/blob/main/src/application/javascript/JavaScriptApplicationWorkflowService.ts"
click node_browser "https://github.com/shijianzhong/rea/blob/main/src/application/BrowserObservationService.ts"
click node_managed "https://github.com/shijianzhong/rea/blob/main/src/application/managed/ManagedReconstructionService.ts"
click node_android "https://github.com/shijianzhong/rea/blob/main/src/application/android/AndroidAnalysisService.ts"
click node_firmware "https://github.com/shijianzhong/rea/blob/main/src/application/firmware/FirmwareAnalysisService.ts"
click node_reconstruction "https://github.com/shijianzhong/rea/blob/main/src/application/ReconstructionCoverageService.ts"
click node_ghidra "https://github.com/shijianzhong/rea/blob/main/src/ghidra/GhidraProviderClient.ts"
click node_hopper "https://github.com/shijianzhong/rea/blob/main/src/hopper/HopperClient.ts"
click node_ida "https://github.com/shijianzhong/rea/blob/main/src/ida/IdaSessionClient.ts"
click node_evidence "https://github.com/shijianzhong/rea/blob/main/src/application/BrowserEvidence.ts"
click node_errors "https://github.com/shijianzhong/rea/blob/main/src/domain/analysisErrorProjection.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_cli,node_terminal toneBlue
class node_session,node_router,node_provider_api toneAmber
class node_artifacts,node_javascript,node_browser,node_managed,node_android,node_firmware,node_reconstruction toneMint
class node_ghidra,node_hopper,node_ida toneRose
class node_evidence,node_errors,node_agent toneIndigo
```

## Components

### User interfaces

- [MCP server](https://github.com/shijianzhong/rea/blob/main/src/main.ts): `src/main.ts`
- [CLI](https://github.com/shijianzhong/rea/blob/main/src/cli.ts): `src/cli.ts`

### Analysis orchestration

- [Binary session](https://github.com/shijianzhong/rea/blob/main/src/composition/binary.ts): `src/composition/binary.ts`
- [Provider router](https://github.com/shijianzhong/rea/blob/main/src/application/binary/SessionProviderRouter.ts): `src/application/binary/SessionProviderRouter.ts`
- [Provider API](https://github.com/shijianzhong/rea/blob/main/src/application/AnalysisProvider.ts): `src/application/AnalysisProvider.ts`

### Analysis capabilities

- [Artifact inspection](https://github.com/shijianzhong/rea/blob/main/src/artifacts/inventory/ArtifactInventory.ts): `src/artifacts/inventory/ArtifactInventory.ts`
- [JavaScript analysis](https://github.com/shijianzhong/rea/blob/main/src/application/javascript/JavaScriptApplicationWorkflowService.ts): `src/application/javascript/JavaScriptApplicationWorkflowService.ts`
- [Browser observation](https://github.com/shijianzhong/rea/blob/main/src/application/BrowserObservationService.ts): `src/application/BrowserObservationService.ts`
- [Managed analysis](https://github.com/shijianzhong/rea/blob/main/src/application/managed/ManagedReconstructionService.ts): `src/application/managed/ManagedReconstructionService.ts`
- [Android analysis](https://github.com/shijianzhong/rea/blob/main/src/application/android/AndroidAnalysisService.ts): `src/application/android/AndroidAnalysisService.ts`
- [Firmware analysis](https://github.com/shijianzhong/rea/blob/main/src/application/firmware/FirmwareAnalysisService.ts): `src/application/firmware/FirmwareAnalysisService.ts`
- [Reconstruction coverage](https://github.com/shijianzhong/rea/blob/main/src/application/ReconstructionCoverageService.ts): `src/application/ReconstructionCoverageService.ts`

### Analysis providers

- [Ghidra adapter](https://github.com/shijianzhong/rea/blob/main/src/ghidra/GhidraProviderClient.ts): `src/ghidra/GhidraProviderClient.ts`
- [Hopper adapter](https://github.com/shijianzhong/rea/blob/main/src/hopper/HopperClient.ts): `src/hopper/HopperClient.ts`
- [IDA adapter](https://github.com/shijianzhong/rea/blob/main/src/ida/IdaSessionClient.ts): `src/ida/IdaSessionClient.ts`

### Evidence and results

- [Evidence output](https://github.com/shijianzhong/rea/blob/main/src/application/BrowserEvidence.ts): `src/application/BrowserEvidence.ts`
- [Safe error projection](https://github.com/shijianzhong/rea/blob/main/src/domain/analysisErrorProjection.ts): `src/domain/analysisErrorProjection.ts`

### Other components

- **AI agent**
- **Terminal user**

## Connections

- AI agent → MCP server: uses tools (evidence: `README.md`)
- Terminal user → CLI: runs commands (evidence: `README.md`)
- MCP server → Binary session: creates session (evidence: `src/main.ts`)
- MCP server → Safe error projection: projects errors (evidence: `src/main.ts`)
- Binary session → Provider router: routes analysis
- Provider router → Provider API: uses provider API (evidence: `src/application/binary/SessionProviderRouter.ts`)
- AI agent → JavaScript analysis: requests analysis (evidence: `README.md`)
- Terminal user → JavaScript analysis: runs analysis (evidence: `README.md`)
- AI agent → Artifact inspection: requests inspection (evidence: `README.md`)
- AI agent → Browser observation: requests observation (evidence: `README.md`)
- AI agent → Managed analysis: requests analysis (evidence: `README.md`)
- AI agent → Android analysis: requests analysis (evidence: `README.md`)
- AI agent → Firmware analysis: requests analysis (evidence: `README.md`)
- AI agent → Reconstruction coverage: requests assessment (evidence: `README.md`)
- Provider router → Ghidra adapter: selects provider
- Provider router → Hopper adapter: selects provider
- Provider router → IDA adapter: selects provider
- JavaScript analysis → Evidence output: returns evidence (evidence: `README.md`)
- Browser observation → Evidence output: returns evidence (evidence: `README.md`)
