# jtapolcai/tycho-searcher architecture

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

- Interactive diagram: https://gitdiagram.com/jtapolcai/tycho-searcher
- Repository: https://github.com/jtapolcai/tycho-searcher

## Overview

Tycho Searcher consumes live pool updates, maintains a token-and-pool graph, isolates connected components, detects candidate arbitrage cycles, and evaluates their profitability with gas-aware trade sizing. Profitable opportunities can be logged or saved; graph export is also a documented capability. The sampled excerpts show the stream handoff, component build, quoting, optimization, and cycle evaluation, but omit some orchestration details, so uncertain internal links are left out.

Main entry points: [`src/searcher/mod.rs`](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/mod.rs) (Searcher), [`src/main.rs`](https://github.com/jtapolcai/tycho-searcher/blob/main/src/main.rs) (Runtime Runner), [`src/searcher/bellman_ford.rs`](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/bellman_ford.rs) (Cycle Detection), [`src/searcher/price_quoter.rs`](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/price_quoter.rs) (Pool Quoter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Input and Updates"]
  node_cli["CLI Configuration"]
  node_runner["Runtime Runner<br/>[main.rs]"]
  node_updates["Block Updates<br/>[main.rs]"]
end

subgraph group_graph["Market Graph"]
  node_searcher["Searcher<br/>[mod.rs]"]
  node_marketgraph["Token Pool Graph<br/>[graph_types.rs]"]
  node_components["Component Analysis"]
  node_quoter["Pool Quoter<br/>[price_quoter.rs]"]
end

subgraph group_analysis["Arbitrage Analysis"]
  node_bellman["Cycle Detection<br/>[bellman_ford.rs]"]
  node_optimizer["Trade Optimization"]
  node_merger["Cycle Merging<br/>[merge_cycles.rs]"]
  node_validator["Opportunity Verification<br/>[arbitrage_save.rs]"]
end

subgraph group_output["Results and Observability"]
  node_exporter["Arbitrage Export<br/>[arbitrage_save.rs]"]
  node_logger["Logging<br/>[logging.rs]"]
  node_graph_export["Graph Export<br/>[mod.rs]"]
end

node_operator(("Operator"))
node_tycho{{"Tycho Feed"}}
node_rpc{{"Chain RPC"}}

node_operator -->|"sets options"| node_cli
node_cli -->|"configures run"| node_runner
node_runner -.->|"checks endpoint"| node_rpc
node_runner -->|"builds stream"| node_tycho
node_tycho -->|"emits blocks"| node_updates
node_runner -->|"sends updates"| node_updates
node_updates -->|"delivers updates"| node_searcher
node_searcher -->|"updates pools"| node_marketgraph
node_searcher -->|"builds components"| node_components
node_searcher -->|"runs detection"| node_bellman
node_bellman -->|"optimizes candidates"| node_optimizer
node_bellman -->|"simulates trades"| node_quoter
node_optimizer -->|"queries prices"| node_quoter
node_searcher -->|"merges cycles"| node_merger
node_searcher -->|"verifies opportunities"| node_validator
node_validator -->|"simulates cycle"| node_quoter
node_searcher -->|"saves opportunity"| node_exporter
node_searcher -->|"exports graph"| node_graph_export
node_searcher -->|"reports activity"| node_logger
node_quoter -->|"reports quotes"| node_logger
node_bellman -->|"reports candidates"| node_logger

click node_cli "https://github.com/jtapolcai/tycho-searcher/blob/main/src/command_line_parameters.rs"
click node_runner "https://github.com/jtapolcai/tycho-searcher/blob/main/src/main.rs"
click node_updates "https://github.com/jtapolcai/tycho-searcher/blob/main/src/main.rs"
click node_searcher "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/mod.rs"
click node_marketgraph "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/graph_types.rs"
click node_components "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/graph_components.rs"
click node_quoter "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/price_quoter.rs"
click node_bellman "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/bellman_ford.rs"
click node_optimizer "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/one_dimensional_optimisation.rs"
click node_merger "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/merge_cycles.rs"
click node_validator "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/arbitrage_save.rs"
click node_exporter "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/arbitrage_save.rs"
click node_logger "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/logging.rs"
click node_graph_export "https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/mod.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_cli,node_runner,node_updates toneBlue
class node_searcher,node_marketgraph,node_components,node_quoter toneAmber
class node_bellman,node_optimizer,node_merger,node_validator toneMint
class node_exporter,node_logger,node_graph_export toneRose
class node_operator,node_tycho,node_rpc toneIndigo
```

## Components

### Input and Updates

- [CLI Configuration](https://github.com/jtapolcai/tycho-searcher/blob/main/src/command_line_parameters.rs): `src/command_line_parameters.rs`
- [Runtime Runner](https://github.com/jtapolcai/tycho-searcher/blob/main/src/main.rs): `src/main.rs`
- [Block Updates](https://github.com/jtapolcai/tycho-searcher/blob/main/src/main.rs): `src/main.rs`

### Market Graph

- [Searcher](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/mod.rs): `src/searcher/mod.rs`
- [Token Pool Graph](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/graph_types.rs): `src/searcher/graph_types.rs`
- [Component Analysis](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/graph_components.rs): `src/searcher/graph_components.rs`
- [Pool Quoter](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/price_quoter.rs): `src/searcher/price_quoter.rs`

### Arbitrage Analysis

- [Cycle Detection](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/bellman_ford.rs): `src/searcher/bellman_ford.rs`
- [Trade Optimization](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/one_dimensional_optimisation.rs): `src/searcher/one_dimensional_optimisation.rs`
- [Cycle Merging](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/merge_cycles.rs): `src/searcher/merge_cycles.rs`
- [Opportunity Verification](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/arbitrage_save.rs): `src/searcher/arbitrage_save.rs`

### Results and Observability

- [Arbitrage Export](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/arbitrage_save.rs): `src/searcher/arbitrage_save.rs`
- [Logging](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/logging.rs): `src/searcher/logging.rs`
- [Graph Export](https://github.com/jtapolcai/tycho-searcher/blob/main/src/searcher/mod.rs): `src/searcher/mod.rs`

### Other components

- **Operator**
- **Tycho Feed**
- **Chain RPC**

## Connections

- Operator → CLI Configuration: sets options
- CLI Configuration → Runtime Runner: configures run
- Runtime Runner → Chain RPC: checks endpoint
- Runtime Runner → Tycho Feed: builds stream
- Tycho Feed → Block Updates: emits blocks
- Runtime Runner → Block Updates: sends updates
- Block Updates → Searcher: delivers updates
- Searcher → Token Pool Graph: updates pools
- Searcher → Component Analysis: builds components
- Searcher → Cycle Detection: runs detection
- Cycle Detection → Trade Optimization: optimizes candidates
- Cycle Detection → Pool Quoter: simulates trades
- Trade Optimization → Pool Quoter: queries prices
- Searcher → Cycle Merging: merges cycles
- Searcher → Opportunity Verification: verifies opportunities
- Opportunity Verification → Pool Quoter: simulates cycle
- Searcher → Arbitrage Export: saves opportunity
- Searcher → Graph Export: exports graph
- Searcher → Logging: reports activity
- Pool Quoter → Logging: reports quotes
- Cycle Detection → Logging: reports candidates
