# abdullah-a-qazi/mev-project architecture

> Architecture diagram of the GitHub repository abdullah-a-qazi/mev-project, 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/abdullah-a-qazi/mev-project
- Repository: https://github.com/abdullah-a-qazi/mev-project

## Overview

MEV Monitor is a historical Ethereum MEV research pipeline: sampled blocks are collected and normalized, V2 swaps are decoded and checked for verified pools, arbitrage and sandwiches are detected, then victim loss and bundle-level realised profit are measured for analysis. The graph also includes RPC budgeting and caching, which support data collection and later lookups. Several subsystem links follow the README’s documented workflow; unsampled implementation details are not inferred beyond the provided references.

Main entry points: [`collector/rpc.py`](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/rpc.py) (RPC client), [`detectors/load.py`](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/load.py) (Swap loading), [`collector/pipeline.py`](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/pipeline.py) (Block collection), [`detectors/sandwich.py`](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/sandwich.py) (Sandwich detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection"]
  node_sample["Block sample<br/>[sample_blocks.csv]"]
  node_sampler["Block sampler<br/>[sampling.py]"]
  node_collector["Block collection<br/>[pipeline.py]"]
  node_rpc["RPC client<br/>[rpc.py]"]
  node_cache[("RPC response cache<br/>[cache.py]")]
  node_ledger[("Credit ledger<br/>[credits.py]")]
end

subgraph group_shared["Shared infrastructure"]
  node_config["Configuration<br/>[config.py]"]
end

subgraph group_detection["Detection"]
  node_poolcheck["Pool verification<br/>[pools.py]"]
  node_swapload["Swap loading<br/>[load.py]"]
  node_swapdecode["V2 swap decoding<br/>[swaps.py]"]
  node_arbitrage["Arbitrage detection<br/>[arbitrage.py]"]
  node_sandwich["Sandwich detection<br/>[sandwich.py]"]
end

subgraph group_measurement["Measurement"]
  node_victimloss["Victim loss<br/>[victim_loss.py]"]
  node_bundles["MEV bundle grouping<br/>[bundles.py]"]
  node_realised["Realised profit<br/>[realised.py]"]
  node_pricing["ETH pricing<br/>[pricing.py]"]
  node_amm["V2 AMM maths<br/>[uniswap_v2.py]"]
end

subgraph group_analysis["Analysis"]
  node_analysis["Research analysis<br/>[summary.py]"]
  node_stats["Summary statistics<br/>[stats.py]"]
end

node_researcher(("Researcher"))
node_providers{{"Ethereum RPC providers"}}

node_researcher -->|"chooses sample"| node_sampler
node_sampler -->|"writes blocks"| node_sample
node_sample -->|"feeds blocks"| node_collector
node_collector -->|"fetches blocks"| node_rpc
node_rpc -->|"sends requests"| node_providers
node_rpc -->|"reads and writes"| node_cache
node_rpc -->|"checks credits"| node_ledger
node_config -->|"configures providers"| node_rpc
node_collector -->|"provides tables"| node_swapload
node_swapload -->|"verifies pools"| node_poolcheck
node_poolcheck -->|"reads pool metadata"| node_rpc
node_swapload -->|"decodes logs"| node_swapdecode
node_swapdecode -->|"reconstructs reserves"| node_amm
node_swapload -->|"supplies swaps"| node_arbitrage
node_swapload -->|"supplies swaps"| node_sandwich
node_sandwich -->|"identifies victims"| node_victimloss
node_arbitrage -->|"contributes events"| node_bundles
node_sandwich -->|"contributes events"| node_bundles
node_bundles -->|"groups transactions"| node_realised
node_realised -->|"prices residuals"| node_pricing
node_pricing -->|"uses swap maths"| node_amm
node_realised -->|"feeds results"| node_analysis
node_analysis -->|"summarizes data"| node_stats

click node_sample "https://github.com/abdullah-a-qazi/mev-project/blob/main/sample_blocks.csv"
click node_sampler "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/sampling.py"
click node_collector "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/pipeline.py"
click node_rpc "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/rpc.py"
click node_cache "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/cache.py"
click node_ledger "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/credits.py"
click node_config "https://github.com/abdullah-a-qazi/mev-project/blob/main/common/config.py"
click node_poolcheck "https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/pools.py"
click node_swapload "https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/load.py"
click node_swapdecode "https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/swaps.py"
click node_arbitrage "https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/arbitrage.py"
click node_sandwich "https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/sandwich.py"
click node_victimloss "https://github.com/abdullah-a-qazi/mev-project/blob/main/mitigation/victim_loss.py"
click node_bundles "https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/bundles.py"
click node_realised "https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/realised.py"
click node_pricing "https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/pricing.py"
click node_amm "https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/uniswap_v2.py"
click node_analysis "https://github.com/abdullah-a-qazi/mev-project/blob/main/analysis/summary.py"
click node_stats "https://github.com/abdullah-a-qazi/mev-project/blob/main/analysis/stats.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_sample,node_sampler,node_collector,node_rpc,node_cache,node_ledger toneBlue
class node_config toneAmber
class node_poolcheck,node_swapload,node_swapdecode,node_arbitrage,node_sandwich toneMint
class node_victimloss,node_bundles,node_realised,node_pricing,node_amm toneRose
class node_analysis,node_stats,node_researcher,node_providers toneIndigo
```

## Components

### Collection

- [Block sample](https://github.com/abdullah-a-qazi/mev-project/blob/main/sample_blocks.csv): `sample_blocks.csv`
- [Block sampler](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/sampling.py): `collector/sampling.py`
- [Block collection](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/pipeline.py): `collector/pipeline.py`
- [RPC client](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/rpc.py): `collector/rpc.py`
- [RPC response cache](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/cache.py): `collector/cache.py`
- [Credit ledger](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/credits.py): `collector/credits.py`

### Shared infrastructure

- [Configuration](https://github.com/abdullah-a-qazi/mev-project/blob/main/common/config.py): `common/config.py`

### Detection

- [Pool verification](https://github.com/abdullah-a-qazi/mev-project/blob/main/collector/pools.py): `collector/pools.py`
- [Swap loading](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/load.py): `detectors/load.py`
- [V2 swap decoding](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/swaps.py): `detectors/swaps.py`
- [Arbitrage detection](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/arbitrage.py): `detectors/arbitrage.py`
- [Sandwich detection](https://github.com/abdullah-a-qazi/mev-project/blob/main/detectors/sandwich.py): `detectors/sandwich.py`

### Measurement

- [Victim loss](https://github.com/abdullah-a-qazi/mev-project/blob/main/mitigation/victim_loss.py): `mitigation/victim_loss.py`
- [MEV bundle grouping](https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/bundles.py): `profit/bundles.py`
- [Realised profit](https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/realised.py): `profit/realised.py`
- [ETH pricing](https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/pricing.py): `profit/pricing.py`
- [V2 AMM maths](https://github.com/abdullah-a-qazi/mev-project/blob/main/profit/uniswap_v2.py): `profit/uniswap_v2.py`

### Analysis

- [Research analysis](https://github.com/abdullah-a-qazi/mev-project/blob/main/analysis/summary.py): `analysis/summary.py`
- [Summary statistics](https://github.com/abdullah-a-qazi/mev-project/blob/main/analysis/stats.py): `analysis/stats.py`

### Other components

- **Researcher**
- **Ethereum RPC providers**

## Connections

- Researcher → Block sampler: chooses sample (evidence: `README.md`)
- Block sampler → Block sample: writes blocks (evidence: `README.md`)
- Block sample → Block collection: feeds blocks (evidence: `README.md`)
- Block collection → RPC client: fetches blocks (evidence: `collector/pipeline.py`)
- RPC client → Ethereum RPC providers: sends requests (evidence: `README.md`)
- RPC client → RPC response cache: reads and writes (evidence: `collector/rpc.py`)
- RPC client → Credit ledger: checks credits (evidence: `README.md`)
- Configuration → RPC client: configures providers (evidence: `common/config.py`)
- Block collection → Swap loading: provides tables (evidence: `README.md`)
- Swap loading → Pool verification: verifies pools (evidence: `detectors/load.py`)
- Pool verification → RPC client: reads pool metadata (evidence: `collector/pools.py`)
- Swap loading → V2 swap decoding: decodes logs (evidence: `detectors/load.py`)
- V2 swap decoding → V2 AMM maths: reconstructs reserves (evidence: `detectors/swaps.py`)
- Swap loading → Arbitrage detection: supplies swaps (evidence: `README.md`)
- Swap loading → Sandwich detection: supplies swaps (evidence: `README.md`)
- Sandwich detection → Victim loss: identifies victims (evidence: `mitigation/victim_loss.py`)
- Arbitrage detection → MEV bundle grouping: contributes events (evidence: `README.md`)
- Sandwich detection → MEV bundle grouping: contributes events (evidence: `README.md`)
- MEV bundle grouping → Realised profit: groups transactions (evidence: `README.md`)
- Realised profit → ETH pricing: prices residuals (evidence: `README.md`)
- ETH pricing → V2 AMM maths: uses swap maths (evidence: `profit/pricing.py`)
- Realised profit → Research analysis: feeds results (evidence: `README.md`)
- Research analysis → Summary statistics: summarizes data (evidence: `analysis/summary.py`)
