# foundry-rs/foundry architecture

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

## Overview

Foundry is a Rust toolkit for Ethereum development, centered on Forge, Cast, Anvil, and Chisel. A developer can build and test Solidity projects with Forge, inspect or interact with chains using Cast, run a local node with Anvil, and experiment interactively in Chisel. Shared EVM execution, compilation, configuration, and trace facilities support those workflows. The README documents the major product capabilities; the tree supports subsystem placement, but unsampled implementation details do not establish additional call relationships.

Main entry points: [`crates/forge/src/args.rs`](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/args.rs) (Forge commands), [`crates/cast/src/args.rs`](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/args.rs) (Cast commands), [`crates/forge/src/cmd/build.rs`](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/cmd/build.rs) (Build and compile), [`crates/anvil/src/eth/backend/mod.rs`](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mod.rs) (Chain backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_forge["Forge"]
  node_forge_cli["Forge CLI<br/>[main.rs]"]
  node_forge_dispatch["Forge commands<br/>[args.rs]"]
  node_forge_build["Build and compile<br/>[build.rs]"]
  node_forge_test["Test and fuzz<br/>[runner.rs]"]
  node_forge_debug["Debug and inspect<br/>[debugger.rs]"]
  node_forge_lsp["Editor integration<br/>[lsp.rs]"]
end

subgraph group_cast["Cast"]
  node_cast_cli["Cast CLI<br/>[main.rs]"]
  node_cast_dispatch["Cast commands<br/>[args.rs]"]
  node_cast_rpc["Chain RPC<br/>[rpc.rs]"]
  node_cast_send["Transactions<br/>[send.rs]"]
  node_cast_queries["Chain queries<br/>[call.rs]"]
  node_cast_storage["Storage decoding<br/>[storage.rs]"]
end

subgraph group_anvil["Anvil"]
  node_anvil_cli["Anvil CLI<br/>[main.rs]"]
  node_anvil_service["Node service<br/>[service.rs]"]
  node_anvil_rpc["RPC handlers<br/>[rpc_handlers.rs]"]
  node_anvil_backend["Chain backend<br/>[mod.rs]"]
  node_anvil_storage[("Block state<br/>[storage.rs]")]
end

subgraph group_chisel["Chisel"]
  node_chisel_cli["Chisel CLI<br/>[main.rs]"]
  node_chisel_dispatch["REPL dispatcher<br/>[dispatcher.rs]"]
  node_chisel_session["REPL session<br/>[session.rs]"]
  node_chisel_executor["Code execution<br/>[executor.rs]"]
end

subgraph group_shared["Shared runtime"]
  node_compilation["Solidity compilation<br/>[compile.rs]"]
  node_evm["EVM execution<br/>[mod.rs]"]
  node_traces["Execution traces<br/>[lib.rs]"]
end

node_developer(("Developer"))
node_rpc_provider(("Ethereum RPC"))
node_chain(("Ethereum network"))
node_solidity_project["Solidity project"]

node_developer -->|"invokes"| node_forge_cli
node_forge_cli -->|"runs"| node_forge_dispatch
node_forge_dispatch -->|"dispatches"| node_forge_build
node_forge_dispatch -->|"dispatches"| node_forge_test
node_forge_dispatch -->|"dispatches"| node_forge_debug
node_forge_dispatch -->|"dispatches"| node_forge_lsp
node_forge_build -->|"compiles"| node_compilation
node_forge_test -->|"executes tests"| node_evm
node_forge_debug -->|"uses traces"| node_traces
node_developer -->|"invokes"| node_cast_cli
node_cast_cli -->|"runs"| node_cast_dispatch
node_cast_dispatch -->|"dispatches"| node_cast_rpc
node_cast_dispatch -->|"dispatches"| node_cast_send
node_cast_dispatch -->|"dispatches"| node_cast_queries
node_cast_dispatch -->|"dispatches"| node_cast_storage
node_cast_rpc -->|"sends requests"| node_rpc_provider
node_cast_send -->|"broadcasts transactions"| node_rpc_provider
node_cast_queries -->|"queries"| node_rpc_provider
node_cast_storage -->|"reads slots"| node_rpc_provider
node_rpc_provider -->|"connects to"| node_chain
node_developer -->|"starts"| node_anvil_cli
node_anvil_cli -->|"runs"| node_anvil_service
node_anvil_service -->|"serves"| node_anvil_rpc
node_anvil_rpc -->|"handles requests"| node_anvil_backend
node_anvil_backend -->|"executes transactions"| node_evm
node_anvil_backend -->|"reads and writes"| node_anvil_storage
node_developer -->|"invokes"| node_chisel_cli
node_chisel_cli -->|"runs"| node_chisel_dispatch
node_chisel_dispatch -->|"manages"| node_chisel_session
node_chisel_dispatch -->|"dispatches"| node_chisel_executor
node_chisel_executor -->|"compiles input"| node_compilation
node_chisel_executor -->|"executes input"| node_evm
node_forge_build -->|"builds"| node_solidity_project

click node_forge_cli "https://github.com/foundry-rs/foundry/blob/master/crates/forge/bin/main.rs"
click node_forge_dispatch "https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/args.rs"
click node_forge_build "https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/cmd/build.rs"
click node_forge_test "https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/runner.rs"
click node_forge_debug "https://github.com/foundry-rs/foundry/blob/master/crates/debugger/src/debugger.rs"
click node_forge_lsp "https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/cmd/lsp.rs"
click node_cast_cli "https://github.com/foundry-rs/foundry/blob/master/crates/cast/bin/main.rs"
click node_cast_dispatch "https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/args.rs"
click node_cast_rpc "https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/rpc.rs"
click node_cast_send "https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/send.rs"
click node_cast_queries "https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/call.rs"
click node_cast_storage "https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/storage.rs"
click node_anvil_cli "https://github.com/foundry-rs/foundry/blob/master/crates/anvil/bin/main.rs"
click node_anvil_service "https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/service.rs"
click node_anvil_rpc "https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/server/rpc_handlers.rs"
click node_anvil_backend "https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mod.rs"
click node_anvil_storage "https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mem/storage.rs"
click node_chisel_cli "https://github.com/foundry-rs/foundry/blob/master/crates/chisel/bin/main.rs"
click node_chisel_dispatch "https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/dispatcher.rs"
click node_chisel_session "https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/session.rs"
click node_chisel_executor "https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/executor.rs"
click node_compilation "https://github.com/foundry-rs/foundry/blob/master/crates/common/src/compile.rs"
click node_evm "https://github.com/foundry-rs/foundry/blob/master/crates/evm/core/src/evm/mod.rs"
click node_traces "https://github.com/foundry-rs/foundry/blob/master/crates/evm/traces/src/lib.rs"

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_forge_cli,node_forge_dispatch,node_forge_build,node_forge_test,node_forge_debug,node_forge_lsp toneBlue
class node_cast_cli,node_cast_dispatch,node_cast_rpc,node_cast_send,node_cast_queries,node_cast_storage toneAmber
class node_anvil_cli,node_anvil_service,node_anvil_rpc,node_anvil_backend,node_anvil_storage toneMint
class node_chisel_cli,node_chisel_dispatch,node_chisel_session,node_chisel_executor toneRose
class node_compilation,node_evm,node_traces,node_developer,node_rpc_provider,node_chain,node_solidity_project toneIndigo
```

## Components

### Forge

- [Forge CLI](https://github.com/foundry-rs/foundry/blob/master/crates/forge/bin/main.rs): `crates/forge/bin/main.rs`
- [Forge commands](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/args.rs): `crates/forge/src/args.rs`
- [Build and compile](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/cmd/build.rs): `crates/forge/src/cmd/build.rs`
- [Test and fuzz](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/runner.rs): `crates/forge/src/runner.rs`
- [Debug and inspect](https://github.com/foundry-rs/foundry/blob/master/crates/debugger/src/debugger.rs): `crates/debugger/src/debugger.rs`
- [Editor integration](https://github.com/foundry-rs/foundry/blob/master/crates/forge/src/cmd/lsp.rs): `crates/forge/src/cmd/lsp.rs`

### Cast

- [Cast CLI](https://github.com/foundry-rs/foundry/blob/master/crates/cast/bin/main.rs): `crates/cast/bin/main.rs`
- [Cast commands](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/args.rs): `crates/cast/src/args.rs`
- [Chain RPC](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/rpc.rs): `crates/cast/src/cmd/rpc.rs`
- [Transactions](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/send.rs): `crates/cast/src/cmd/send.rs`
- [Chain queries](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/call.rs): `crates/cast/src/cmd/call.rs`
- [Storage decoding](https://github.com/foundry-rs/foundry/blob/master/crates/cast/src/cmd/storage.rs): `crates/cast/src/cmd/storage.rs`

### Anvil

- [Anvil CLI](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/bin/main.rs): `crates/anvil/bin/main.rs`
- [Node service](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/service.rs): `crates/anvil/src/service.rs`
- [RPC handlers](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/server/rpc_handlers.rs): `crates/anvil/src/server/rpc_handlers.rs`
- [Chain backend](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mod.rs): `crates/anvil/src/eth/backend/mod.rs`
- [Block state](https://github.com/foundry-rs/foundry/blob/master/crates/anvil/src/eth/backend/mem/storage.rs): `crates/anvil/src/eth/backend/mem/storage.rs`

### Chisel

- [Chisel CLI](https://github.com/foundry-rs/foundry/blob/master/crates/chisel/bin/main.rs): `crates/chisel/bin/main.rs`
- [REPL dispatcher](https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/dispatcher.rs): `crates/chisel/src/dispatcher.rs`
- [REPL session](https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/session.rs): `crates/chisel/src/session.rs`
- [Code execution](https://github.com/foundry-rs/foundry/blob/master/crates/chisel/src/executor.rs): `crates/chisel/src/executor.rs`

### Shared runtime

- [Solidity compilation](https://github.com/foundry-rs/foundry/blob/master/crates/common/src/compile.rs): `crates/common/src/compile.rs`
- [EVM execution](https://github.com/foundry-rs/foundry/blob/master/crates/evm/core/src/evm/mod.rs): `crates/evm/core/src/evm/mod.rs`
- [Execution traces](https://github.com/foundry-rs/foundry/blob/master/crates/evm/traces/src/lib.rs): `crates/evm/traces/src/lib.rs`

### Other components

- **Developer**
- **Ethereum RPC**
- **Ethereum network**
- **Solidity project**

## Connections

- Developer → Forge CLI: invokes
- Forge CLI → Forge commands: runs
- Forge commands → Build and compile: dispatches
- Forge commands → Test and fuzz: dispatches
- Forge commands → Debug and inspect: dispatches
- Forge commands → Editor integration: dispatches
- Build and compile → Solidity compilation: compiles
- Test and fuzz → EVM execution: executes tests
- Debug and inspect → Execution traces: uses traces
- Developer → Cast CLI: invokes
- Cast CLI → Cast commands: runs
- Cast commands → Chain RPC: dispatches
- Cast commands → Transactions: dispatches
- Cast commands → Chain queries: dispatches
- Cast commands → Storage decoding: dispatches
- Chain RPC → Ethereum RPC: sends requests
- Transactions → Ethereum RPC: broadcasts transactions
- Chain queries → Ethereum RPC: queries
- Storage decoding → Ethereum RPC: reads slots
- Ethereum RPC → Ethereum network: connects to
- Developer → Anvil CLI: starts
- Anvil CLI → Node service: runs
- Node service → RPC handlers: serves
- RPC handlers → Chain backend: handles requests
- Chain backend → EVM execution: executes transactions
- Chain backend → Block state: reads and writes
- Developer → Chisel CLI: invokes
- Chisel CLI → REPL dispatcher: runs
- REPL dispatcher → REPL session: manages
- REPL dispatcher → Code execution: dispatches
- Code execution → Solidity compilation: compiles input
- Code execution → EVM execution: executes input
- Build and compile → Solidity project: builds
