# pothome/morluto-rea architecture

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

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

## Overview

REA is a local reverse-engineering product exposed through a CLI and an MCP server. An agent or operator asks about an app or feature; REA opens an analysis session, gathers native, artifact, browser, Electron, or process observations, and returns structured results and evidence for investigation. The README also documents setup and agent integrations as product capabilities. Edges reflect the excerpts, SOURCE INDEX references, or README; unsampled wiring is left out or marked unverified.

Main entry points: [`src/application/BinarySession.ts`](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/BinarySession.ts) (Analysis session), [`src/server/createServer.ts`](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/server/createServer.ts) (MCP server), [`src/main.ts`](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/main.ts) (Runtime entry), [`src/cli.ts`](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/cli.ts) (REA CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["REA CLI<br/>[cli.ts]"]
  node_runtime["Runtime entry<br/>[main.ts]"]
  node_mcp["MCP server<br/>[createServer.ts]"]
  node_contracts["Tool contracts<br/>[toolContracts.ts]"]
end

subgraph group_analysis["Analysis engines"]
  node_session["Analysis session<br/>[BinarySession.ts]"]
  node_provider["Provider interface"]
  node_hopper["Hopper bridge<br/>[HopperClient.ts]"]
  node_native["Native inspection"]
  node_artifacts["Artifact analysis"]
end

subgraph group_observation["Runtime observation"]
  node_browser["Browser observation"]
  node_cdp["CDP browser adapter"]
  node_electron["Electron observation"]
  node_process["Process capture<br/>[ProcessHarness.ts]"]
end

subgraph group_investigation["Evidence and investigation"]
  node_evidence["Evidence records<br/>[evidence.ts]"]
  node_workspaces[("Investigation workspace")]
  node_reference["Reference source reader"]
end

subgraph group_governance["Setup and permissions"]
  node_permissions["Permission authority"]
  node_setup["Setup workflow<br/>[Setup.ts]"]
  node_clients["Agent registration<br/>[SetupClients.ts]"]
end

node_operator(("Agent or operator"))

node_operator -->|"invokes"| node_cli
node_operator -->|"requests tools"| node_mcp
node_cli -->|"analyzes"| node_session
node_runtime -->|"creates"| node_session
node_runtime -->|"creates"| node_mcp
node_mcp -.->|"registers tools"| node_contracts
node_mcp -->|"dispatches session tools"| node_session
node_session -->|"uses provider port"| node_provider
node_native -->|"implements analysis"| node_provider
node_artifacts -->|"uses provider"| node_provider
node_session -.->|"may analyze via Hopper"| node_hopper
node_runtime -->|"creates browser provider"| node_cdp
node_browser -->|"records observations"| node_evidence
node_electron -->|"records observations"| node_evidence
node_mcp -->|"captures scenarios"| node_process
node_session -->|"maintains evidence"| node_evidence
node_cli -->|"runs setup"| node_setup
node_setup -->|"configures clients"| node_clients
node_runtime -->|"loads policy"| node_permissions

click node_cli "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/cli.ts"
click node_runtime "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/main.ts"
click node_mcp "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/server/createServer.ts"
click node_contracts "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/contracts/toolContracts.ts"
click node_session "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/BinarySession.ts"
click node_provider "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/AnalysisProvider.ts"
click node_hopper "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/hopper/HopperClient.ts"
click node_native "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/native/NativeMacOSProvider.ts"
click node_artifacts "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/artifacts/ArtifactProvider.ts"
click node_browser "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/BrowserObservationService.ts"
click node_cdp "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/browser/CdpBrowserProvider.ts"
click node_electron "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/ElectronObservationService.ts"
click node_process "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/ProcessHarness.ts"
click node_evidence "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/domain/evidence.ts"
click node_workspaces "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/InvestigationWorkspaceStore.ts"
click node_reference "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/reference/ReferenceSourceReaderEntries.ts"
click node_permissions "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/PermissionAuthority.ts"
click node_setup "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/Setup.ts"
click node_clients "https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/SetupClients.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_runtime,node_mcp,node_contracts toneBlue
class node_session,node_provider,node_hopper,node_native,node_artifacts toneAmber
class node_browser,node_cdp,node_electron,node_process toneMint
class node_evidence,node_workspaces,node_reference toneRose
class node_permissions,node_setup,node_clients,node_operator toneIndigo
```

## Components

### Entry points

- [REA CLI](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/cli.ts): `src/cli.ts`
- [Runtime entry](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/main.ts): `src/main.ts`
- [MCP server](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/server/createServer.ts): `src/server/createServer.ts`
- [Tool contracts](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/contracts/toolContracts.ts): `src/contracts/toolContracts.ts`

### Analysis engines

- [Analysis session](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/BinarySession.ts): `src/application/BinarySession.ts`
- [Provider interface](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/AnalysisProvider.ts): `src/application/AnalysisProvider.ts`
- [Hopper bridge](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/hopper/HopperClient.ts): `src/hopper/HopperClient.ts`
- [Native inspection](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/native/NativeMacOSProvider.ts): `src/native/NativeMacOSProvider.ts`
- [Artifact analysis](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/artifacts/ArtifactProvider.ts): `src/artifacts/ArtifactProvider.ts`

### Runtime observation

- [Browser observation](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/BrowserObservationService.ts): `src/application/BrowserObservationService.ts`
- [CDP browser adapter](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/browser/CdpBrowserProvider.ts): `src/browser/CdpBrowserProvider.ts`
- [Electron observation](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/ElectronObservationService.ts): `src/application/ElectronObservationService.ts`
- [Process capture](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/ProcessHarness.ts): `src/application/ProcessHarness.ts`

### Evidence and investigation

- [Evidence records](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/domain/evidence.ts): `src/domain/evidence.ts`
- [Investigation workspace](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/InvestigationWorkspaceStore.ts): `src/application/InvestigationWorkspaceStore.ts`
- [Reference source reader](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/reference/ReferenceSourceReaderEntries.ts): `src/reference/ReferenceSourceReaderEntries.ts`

### Setup and permissions

- [Permission authority](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/PermissionAuthority.ts): `src/application/PermissionAuthority.ts`
- [Setup workflow](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/Setup.ts): `src/application/Setup.ts`
- [Agent registration](https://github.com/pothome/morluto-rea/blob/agent/process-cleanup/src/application/SetupClients.ts): `src/application/SetupClients.ts`

### Other components

- **Agent or operator**

## Connections

- Agent or operator → REA CLI: invokes
- Agent or operator → MCP server: requests tools
- REA CLI → Analysis session: analyzes (evidence: `src/cli.ts`)
- Runtime entry → Analysis session: creates (evidence: `src/main.ts`)
- Runtime entry → MCP server: creates (evidence: `src/main.ts`)
- MCP server → Tool contracts: registers tools
- MCP server → Analysis session: dispatches session tools
- Analysis session → Provider interface: uses provider port (evidence: `src/application/BinarySession.ts`)
- Native inspection → Provider interface: implements analysis (evidence: `src/native/NativeMacOSProvider.ts`)
- Artifact analysis → Provider interface: uses provider (evidence: `src/artifacts/ArtifactProvider.ts`)
- Analysis session → Hopper bridge: may analyze via Hopper
- Runtime entry → CDP browser adapter: creates browser provider (evidence: `src/main.ts`)
- Browser observation → Evidence records: records observations (evidence: `src/application/BrowserObservationService.ts`)
- Electron observation → Evidence records: records observations (evidence: `src/application/ElectronObservationService.ts`)
- MCP server → Process capture: captures scenarios
- Analysis session → Evidence records: maintains evidence (evidence: `src/application/BinarySession.ts`)
- REA CLI → Setup workflow: runs setup (evidence: `src/cli.ts`)
- Setup workflow → Agent registration: configures clients (evidence: `src/application/Setup.ts`)
- Runtime entry → Permission authority: loads policy (evidence: `src/main.ts`)
