# dryxio/reagent architecture

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

- Interactive diagram: https://gitdiagram.com/dryxio/reagent
- Repository: https://github.com/dryxio/reagent

## Overview

ReAgent is an AI-assisted binary reverse-engineering tool: users select or plan functions, gather Ghidra and nearby-source evidence, generate and review candidate C/C++ implementations, then apply structural, build/test/runtime, and parity checks. The CLI and configuration layer support the workflow, while manifests, session history, checkpoints, and reports track progress. README documents several capabilities whose internal wiring was not sampled; those are shown at subsystem level, and uncertain call relationships are omitted.

Main entry points: [`src/re_agent/orchestrator/single.py`](https://github.com/dryxio/reagent/blob/main/src/re_agent/orchestrator/single.py) (Single reversal), [`src/re_agent/cli/main.py`](https://github.com/dryxio/reagent/blob/main/src/re_agent/cli/main.py) (CLI commands), [`src/re_agent/agents/loop.py`](https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/loop.py) (Review and fix loop), [`src/re_agent/backend/registry.py`](https://github.com/dryxio/reagent/blob/main/src/re_agent/backend/registry.py) (Backend registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_cli["CLI commands<br/>[main.py]"]
  node_config["Configuration<br/>[loader.py]"]
end

subgraph group_analysis["Target analysis"]
  node_planner["Function planning<br/>[target_plan.py]"]
  node_backend["Backend registry<br/>[registry.py]"]
  node_ghidra["Ghidra bridge<br/>[ghidra_bridge.py]"]
  node_source["Source context<br/>[source_context.py]"]
end

subgraph group_reversal["Reconstruction"]
  node_orchestrator["Single reversal<br/>[single.py]"]
  node_agentloop["Review and fix loop<br/>[loop.py]"]
  node_reverser["Reverser agent<br/>[reverser.py]"]
  node_checker["Checker agent<br/>[checker.py]"]
  node_llm["LLM providers<br/>[registry.py]"]
end

subgraph group_validation["Validation"]
  node_objective["Structural verifier<br/>[objective.py]"]
  node_candidate["Candidate validation<br/>[candidate.py]"]
  node_parity["Parity analysis<br/>[engine.py]"]
end

subgraph group_state["Progress and reports"]
  node_session[("Session history<br/>[session.py]")]
  node_reports["Reports and coverage<br/>[coverage.py]"]
  node_manifest["Target manifest<br/>[target_plan.py]"]
end

node_user(("Engineer"))
node_project["Target project"]
node_bridge_service["Ghidra analysis"]
node_model_service["LLM service or CLI"]

node_user -->|"invokes"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"plans targets"| node_planner
node_planner -->|"queries targets"| node_backend
node_planner -->|"exports plan"| node_manifest
node_cli -->|"starts reversal"| node_orchestrator
node_orchestrator -->|"requests evidence"| node_backend
node_backend -->|"dispatches queries"| node_ghidra
node_ghidra -->|"runs analysis"| node_bridge_service
node_orchestrator -->|"runs loop"| node_agentloop
node_agentloop -->|"gathers context"| node_source
node_source -->|"reads source"| node_project
node_agentloop -->|"requests candidate"| node_reverser
node_agentloop -->|"requests review"| node_checker
node_reverser -->|"generates code"| node_llm
node_checker -->|"reviews code"| node_llm
node_llm -->|"sends prompts"| node_model_service
node_orchestrator -->|"checks structure"| node_objective
node_orchestrator -->|"validates candidate"| node_candidate
node_candidate -->|"builds and tests"| node_project
node_orchestrator -.->|"checks parity"| node_parity
node_parity -.->|"fetches Ghidra data"| node_backend
node_orchestrator -->|"records results"| node_session
node_cli -->|"reports status"| node_reports
node_reports -->|"reads progress"| node_session
node_reports -->|"reconciles targets"| node_manifest

click node_cli "https://github.com/dryxio/reagent/blob/main/src/re_agent/cli/main.py"
click node_config "https://github.com/dryxio/reagent/blob/main/src/re_agent/config/loader.py"
click node_planner "https://github.com/dryxio/reagent/blob/main/src/re_agent/core/target_plan.py"
click node_backend "https://github.com/dryxio/reagent/blob/main/src/re_agent/backend/registry.py"
click node_ghidra "https://github.com/dryxio/reagent/blob/main/src/re_agent/backend/ghidra_bridge.py"
click node_source "https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/source_context.py"
click node_orchestrator "https://github.com/dryxio/reagent/blob/main/src/re_agent/orchestrator/single.py"
click node_agentloop "https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/loop.py"
click node_reverser "https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/reverser.py"
click node_checker "https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/checker.py"
click node_llm "https://github.com/dryxio/reagent/blob/main/src/re_agent/llm/registry.py"
click node_objective "https://github.com/dryxio/reagent/blob/main/src/re_agent/verification/objective.py"
click node_candidate "https://github.com/dryxio/reagent/blob/main/src/re_agent/verification/candidate.py"
click node_parity "https://github.com/dryxio/reagent/blob/main/src/re_agent/parity/engine.py"
click node_session "https://github.com/dryxio/reagent/blob/main/src/re_agent/core/session.py"
click node_reports "https://github.com/dryxio/reagent/blob/main/src/re_agent/reports/coverage.py"
click node_manifest "https://github.com/dryxio/reagent/blob/main/src/re_agent/core/target_plan.py"

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_config toneBlue
class node_planner,node_backend,node_ghidra,node_source toneAmber
class node_orchestrator,node_agentloop,node_reverser,node_checker,node_llm toneMint
class node_objective,node_candidate,node_parity toneRose
class node_session,node_reports,node_manifest,node_user,node_project,node_bridge_service,node_model_service toneIndigo
```

## Components

### User entry

- [CLI commands](https://github.com/dryxio/reagent/blob/main/src/re_agent/cli/main.py): `src/re_agent/cli/main.py`
- [Configuration](https://github.com/dryxio/reagent/blob/main/src/re_agent/config/loader.py): `src/re_agent/config/loader.py`

### Target analysis

- [Function planning](https://github.com/dryxio/reagent/blob/main/src/re_agent/core/target_plan.py): `src/re_agent/core/target_plan.py`
- [Backend registry](https://github.com/dryxio/reagent/blob/main/src/re_agent/backend/registry.py): `src/re_agent/backend/registry.py`
- [Ghidra bridge](https://github.com/dryxio/reagent/blob/main/src/re_agent/backend/ghidra_bridge.py): `src/re_agent/backend/ghidra_bridge.py`
- [Source context](https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/source_context.py): `src/re_agent/agents/source_context.py`

### Reconstruction

- [Single reversal](https://github.com/dryxio/reagent/blob/main/src/re_agent/orchestrator/single.py): `src/re_agent/orchestrator/single.py`
- [Review and fix loop](https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/loop.py): `src/re_agent/agents/loop.py`
- [Reverser agent](https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/reverser.py): `src/re_agent/agents/reverser.py`
- [Checker agent](https://github.com/dryxio/reagent/blob/main/src/re_agent/agents/checker.py): `src/re_agent/agents/checker.py`
- [LLM providers](https://github.com/dryxio/reagent/blob/main/src/re_agent/llm/registry.py): `src/re_agent/llm/registry.py`

### Validation

- [Structural verifier](https://github.com/dryxio/reagent/blob/main/src/re_agent/verification/objective.py): `src/re_agent/verification/objective.py`
- [Candidate validation](https://github.com/dryxio/reagent/blob/main/src/re_agent/verification/candidate.py): `src/re_agent/verification/candidate.py`
- [Parity analysis](https://github.com/dryxio/reagent/blob/main/src/re_agent/parity/engine.py): `src/re_agent/parity/engine.py`

### Progress and reports

- [Session history](https://github.com/dryxio/reagent/blob/main/src/re_agent/core/session.py): `src/re_agent/core/session.py`
- [Reports and coverage](https://github.com/dryxio/reagent/blob/main/src/re_agent/reports/coverage.py): `src/re_agent/reports/coverage.py`
- [Target manifest](https://github.com/dryxio/reagent/blob/main/src/re_agent/core/target_plan.py): `src/re_agent/core/target_plan.py`

### Other components

- **Engineer**
- **Target project**
- **Ghidra analysis**
- **LLM service or CLI**

## Connections

- Engineer → CLI commands: invokes
- CLI commands → Configuration: loads settings
- CLI commands → Function planning: plans targets
- Function planning → Backend registry: queries targets
- Function planning → Target manifest: exports plan
- CLI commands → Single reversal: starts reversal
- Single reversal → Backend registry: requests evidence
- Backend registry → Ghidra bridge: dispatches queries
- Ghidra bridge → Ghidra analysis: runs analysis
- Single reversal → Review and fix loop: runs loop
- Review and fix loop → Source context: gathers context
- Source context → Target project: reads source
- Review and fix loop → Reverser agent: requests candidate
- Review and fix loop → Checker agent: requests review
- Reverser agent → LLM providers: generates code
- Checker agent → LLM providers: reviews code
- LLM providers → LLM service or CLI: sends prompts
- Single reversal → Structural verifier: checks structure
- Single reversal → Candidate validation: validates candidate
- Candidate validation → Target project: builds and tests
- Single reversal → Parity analysis: checks parity
- Parity analysis → Backend registry: fetches Ghidra data
- Single reversal → Session history: records results
- CLI commands → Reports and coverage: reports status
- Reports and coverage → Session history: reads progress
- Reports and coverage → Target manifest: reconciles targets
