# amrex-codes/amrex-agent architecture

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

- Interactive diagram: https://gitdiagram.com/amrex-codes/amrex-agent
- Repository: https://github.com/amrex-codes/amrex-agent

## Overview

AMReXAgent turns natural-language requests into configured AMReX-family simulation runs, with optional result analysis and visualization. Its documented workflow includes solver/case discovery, planning and review, input generation, execution, and result handling; it also offers multiple retrieval strategies and MCP access. The README establishes the product capabilities, while the available source excerpts do not show most node-to-node calls, so those internal workflow links are marked dashed and unverified rather than asserted as observed calls.

Main entry points: [`src/main.py`](https://github.com/amrex-codes/amrex-agent/blob/development/src/main.py) (CLI workflow), [`src/nodes/architect_node.py`](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/architect_node.py) (Plan and baseline), [`src/nodes/runner_node.py`](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/runner_node.py) (Build and run), [`src/services/embedding.py`](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/embedding.py) (Embedding retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow orchestration"]
  node_cli["CLI workflow<br/>[main.py]"]
  node_config["Agent configuration<br/>[config.py]"]
  node_clarification["Clarification"]
end

subgraph group_discovery["Solver discovery"]
  node_solver_configs["Solver configurations<br/>[pelec_config.py]"]
  node_retrieval["Embedding retrieval<br/>[embedding.py]"]
  node_level0["Solver search<br/>[level0_searcher.py]"]
  node_level2["Case search<br/>[level2_searcher.py]"]
end

subgraph group_planning["Planning and validation"]
  node_architect["Plan and baseline<br/>[architect_node.py]"]
  node_reviewer["Plan review<br/>[reviewer_node.py]"]
  node_validation["Plan validation<br/>[validation.py]"]
end

subgraph group_execution["Simulation execution"]
  node_input_writer["Input generation"]
  node_runner["Build and run<br/>[runner_node.py]"]
  node_local_runner["Local execution<br/>[run_local.py]"]
  node_sf_runner["Superfacility execution"]
end

subgraph group_results["Results and interfaces"]
  node_analysis["Run analysis<br/>[analysis_node.py]"]
  node_visualization["Visualization"]
  node_viz_params["Plot parameters"]
  node_mcp["MCP interface<br/>[mcp_tools.py]"]
end

node_user(("Prompt user"))
node_solver["AMReX solver"]
node_orchestrator(("External orchestrator"))

node_user -->|"submits prompt"| node_cli
node_cli -.->|"loads settings"| node_config
node_cli -.->|"clarifies intent"| node_clarification
node_cli -.->|"starts planning"| node_architect
node_architect -.->|"uses solver definitions"| node_solver_configs
node_architect -.->|"retrieves context"| node_retrieval
node_retrieval -.->|"searches solvers"| node_level0
node_retrieval -.->|"searches cases"| node_level2
node_architect -.->|"submits plan"| node_reviewer
node_reviewer -.->|"validates plan"| node_validation
node_reviewer -.->|"approves plan"| node_input_writer
node_input_writer -.->|"prepares run"| node_runner
node_runner -.->|"runs locally"| node_local_runner
node_runner -.->|"submits remotely"| node_sf_runner
node_local_runner -.->|"executes"| node_solver
node_sf_runner -.->|"executes"| node_solver
node_runner -.->|"provides run status"| node_analysis
node_analysis -.->|"routes results"| node_visualization
node_visualization -.->|"extracts plot inputs"| node_viz_params
node_orchestrator -->|"invokes tools"| node_mcp
node_mcp -.->|"exposes workflow"| node_cli

click node_cli "https://github.com/amrex-codes/amrex-agent/blob/development/src/main.py"
click node_config "https://github.com/amrex-codes/amrex-agent/blob/development/src/config.py"
click node_clarification "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/clarification_handler_node.py"
click node_solver_configs "https://github.com/amrex-codes/amrex-agent/blob/development/database/configs/pelec_config.py"
click node_retrieval "https://github.com/amrex-codes/amrex-agent/blob/development/src/services/embedding.py"
click node_level0 "https://github.com/amrex-codes/amrex-agent/blob/development/database/indexing/level0_searcher.py"
click node_level2 "https://github.com/amrex-codes/amrex-agent/blob/development/database/indexing/level2_searcher.py"
click node_architect "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/architect_node.py"
click node_reviewer "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/reviewer_node.py"
click node_validation "https://github.com/amrex-codes/amrex-agent/blob/development/src/services/validation.py"
click node_input_writer "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/input_writer_node.py"
click node_runner "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/runner_node.py"
click node_local_runner "https://github.com/amrex-codes/amrex-agent/blob/development/src/services/run_local.py"
click node_sf_runner "https://github.com/amrex-codes/amrex-agent/blob/development/src/services/run_superfacility_tools.py"
click node_analysis "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/analysis_node.py"
click node_visualization "https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/visualization_node.py"
click node_viz_params "https://github.com/amrex-codes/amrex-agent/blob/development/src/services/viz_param_extractor.py"
click node_mcp "https://github.com/amrex-codes/amrex-agent/blob/development/src/mcp_tools.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,node_clarification,node_user toneBlue
class node_solver_configs,node_retrieval,node_level0,node_level2 toneAmber
class node_architect,node_reviewer,node_validation toneMint
class node_input_writer,node_runner,node_local_runner,node_sf_runner toneRose
class node_analysis,node_visualization,node_viz_params,node_mcp,node_solver,node_orchestrator toneIndigo
```

## Components

### Workflow orchestration

- [CLI workflow](https://github.com/amrex-codes/amrex-agent/blob/development/src/main.py): `src/main.py`
- [Agent configuration](https://github.com/amrex-codes/amrex-agent/blob/development/src/config.py): `src/config.py`
- [Clarification](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/clarification_handler_node.py): `src/nodes/clarification_handler_node.py`

### Solver discovery

- [Solver configurations](https://github.com/amrex-codes/amrex-agent/blob/development/database/configs/pelec_config.py): `database/configs/pelec_config.py`
- [Embedding retrieval](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/embedding.py): `src/services/embedding.py`
- [Solver search](https://github.com/amrex-codes/amrex-agent/blob/development/database/indexing/level0_searcher.py): `database/indexing/level0_searcher.py`
- [Case search](https://github.com/amrex-codes/amrex-agent/blob/development/database/indexing/level2_searcher.py): `database/indexing/level2_searcher.py`

### Planning and validation

- [Plan and baseline](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/architect_node.py): `src/nodes/architect_node.py`
- [Plan review](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/reviewer_node.py): `src/nodes/reviewer_node.py`
- [Plan validation](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/validation.py): `src/services/validation.py`

### Simulation execution

- [Input generation](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/input_writer_node.py): `src/nodes/input_writer_node.py`
- [Build and run](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/runner_node.py): `src/nodes/runner_node.py`
- [Local execution](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/run_local.py): `src/services/run_local.py`
- [Superfacility execution](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/run_superfacility_tools.py): `src/services/run_superfacility_tools.py`

### Results and interfaces

- [Run analysis](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/analysis_node.py): `src/nodes/analysis_node.py`
- [Visualization](https://github.com/amrex-codes/amrex-agent/blob/development/src/nodes/visualization_node.py): `src/nodes/visualization_node.py`
- [Plot parameters](https://github.com/amrex-codes/amrex-agent/blob/development/src/services/viz_param_extractor.py): `src/services/viz_param_extractor.py`
- [MCP interface](https://github.com/amrex-codes/amrex-agent/blob/development/src/mcp_tools.py): `src/mcp_tools.py`

### Other components

- **Prompt user**
- **AMReX solver**
- **External orchestrator**

## Connections

- Prompt user → CLI workflow: submits prompt
- CLI workflow → Agent configuration: loads settings (evidence: `src/main.py`)
- CLI workflow → Clarification: clarifies intent
- CLI workflow → Plan and baseline: starts planning
- Plan and baseline → Solver configurations: uses solver definitions
- Plan and baseline → Embedding retrieval: retrieves context
- Embedding retrieval → Solver search: searches solvers
- Embedding retrieval → Case search: searches cases
- Plan and baseline → Plan review: submits plan
- Plan review → Plan validation: validates plan
- Plan review → Input generation: approves plan
- Input generation → Build and run: prepares run
- Build and run → Local execution: runs locally
- Build and run → Superfacility execution: submits remotely
- Local execution → AMReX solver: executes
- Superfacility execution → AMReX solver: executes
- Build and run → Run analysis: provides run status
- Run analysis → Visualization: routes results
- Visualization → Plot parameters: extracts plot inputs
- External orchestrator → MCP interface: invokes tools
- MCP interface → CLI workflow: exposes workflow
