# anas-chortani/crypto-arbitrage-scanner architecture

> Architecture diagram of the GitHub repository anas-chortani/crypto-arbitrage-scanner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anas-chortani/crypto-arbitrage-scanner
- Repository: https://github.com/anas-chortani/crypto-arbitrage-scanner

## Overview

Crypto Arbitrage Scanner is a read-only monitor: the user starts a scan, configured public or simulated adapters provide order books, and the scanner filters and evaluates cross-exchange routes before sending results to listeners. Its main stages are configuration and adapter setup, market-data acquisition, fee-aware route analysis and episode tracking, then console, file, alert, report, or dashboard output. The graph follows documented architecture and indexed references; some source excerpts are partial, so uncertain internal links are omitted.

Main entry points: [`src/arb_scanner/scanner.py`](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/scanner.py) (Scan orchestration), [`src/arb_scanner/cli.py`](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/cli.py) (CLI commands), [`src/arb_scanner/exchanges/registry.py`](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/registry.py) (Adapter registry), [`src/arb_scanner/exchanges/base.py`](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/base.py) (Adapter interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Setup and control"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_config["Validated config<br/>[config.py]"]
  node_assembly["Application assembly<br/>[app.py]"]
end

subgraph group_feeds["Market data"]
  node_registry["Adapter registry<br/>[registry.py]"]
  node_adapter["Adapter interface<br/>[base.py]"]
  node_ccxt["Public exchange adapter<br/>[ccxt_public.py]"]
  node_simulator["Market simulator<br/>[simulated.py]"]
end

subgraph group_analysis["Analysis and tracking"]
  node_models["Market and result models<br/>[models.py]"]
  node_scanner["Scan orchestration<br/>[scanner.py]"]
  node_analysis["Route analysis<br/>[analysis.py]"]
end

subgraph group_outputs["Results and monitoring"]
  node_alerts["Alerts<br/>[alerts.py]"]
  node_export["CSV and JSONL export<br/>[export.py]"]
  node_report["Run report<br/>[report.py]"]
  node_dashboard["Live dashboard<br/>[app.py]"]
  node_logging["Logging setup<br/>[logging_setup.py]"]
end

node_user(("Operator"))
node_venue{{"Exchange public APIs"}}
node_webhook{{"Optional webhook"}}

node_user -->|"runs commands"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"starts scanning"| node_assembly
node_assembly -->|"builds adapters"| node_registry
node_assembly -->|"creates scanner"| node_scanner
node_config -->|"validates venues"| node_registry
node_registry -->|"creates public adapter"| node_ccxt
node_registry -->|"creates simulator"| node_simulator
node_ccxt -->|"implements interface"| node_adapter
node_simulator -->|"implements interface"| node_adapter
node_ccxt -->|"fetches order books"| node_venue
node_scanner -->|"fetches books"| node_adapter
node_adapter -->|"returns order books"| node_models
node_scanner -->|"records scan results"| node_models
node_scanner -->|"evaluates routes"| node_analysis
node_analysis -->|"produces quotes"| node_models
node_scanner -->|"notifies listener"| node_alerts
node_scanner -->|"notifies listener"| node_export
node_scanner -->|"notifies listener"| node_report
node_scanner -->|"updates dashboard"| node_dashboard
node_alerts -.->|"sends optional alerts"| node_webhook
node_cli -->|"serves dashboard"| node_dashboard
node_cli -->|"prints report"| node_report
node_cli -->|"configures logging"| node_logging
node_alerts -->|"uses logging"| node_logging

click node_cli "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/cli.py"
click node_config "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/config.py"
click node_assembly "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/app.py"
click node_registry "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/registry.py"
click node_adapter "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/base.py"
click node_ccxt "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/ccxt_public.py"
click node_simulator "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/simulated.py"
click node_models "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/models.py"
click node_scanner "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/scanner.py"
click node_analysis "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/analysis.py"
click node_alerts "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/alerts.py"
click node_export "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/export.py"
click node_report "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/report.py"
click node_dashboard "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/dashboard/app.py"
click node_logging "https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/logging_setup.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_assembly toneBlue
class node_registry,node_adapter,node_ccxt,node_simulator toneAmber
class node_models,node_scanner,node_analysis,node_venue,node_webhook toneMint
class node_alerts,node_export,node_report,node_dashboard,node_logging toneRose
class node_user toneIndigo
```

## Components

### Setup and control

- [CLI commands](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/cli.py): `src/arb_scanner/cli.py`
- [Validated config](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/config.py): `src/arb_scanner/config.py`
- [Application assembly](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/app.py): `src/arb_scanner/app.py`

### Market data

- [Adapter registry](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/registry.py): `src/arb_scanner/exchanges/registry.py`
- [Adapter interface](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/base.py): `src/arb_scanner/exchanges/base.py`
- [Public exchange adapter](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/ccxt_public.py): `src/arb_scanner/exchanges/ccxt_public.py`
- [Market simulator](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/exchanges/simulated.py): `src/arb_scanner/exchanges/simulated.py`

### Analysis and tracking

- [Market and result models](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/models.py): `src/arb_scanner/models.py`
- [Scan orchestration](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/scanner.py): `src/arb_scanner/scanner.py`
- [Route analysis](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/analysis.py): `src/arb_scanner/analysis.py`

### Results and monitoring

- [Alerts](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/alerts.py): `src/arb_scanner/alerts.py`
- [CSV and JSONL export](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/export.py): `src/arb_scanner/export.py`
- [Run report](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/report.py): `src/arb_scanner/report.py`
- [Live dashboard](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/dashboard/app.py): `src/arb_scanner/dashboard/app.py`
- [Logging setup](https://github.com/anas-chortani/crypto-arbitrage-scanner/blob/main/src/arb_scanner/logging_setup.py): `src/arb_scanner/logging_setup.py`

### Other components

- **Operator**
- **Exchange public APIs**
- **Optional webhook**

## Connections

- Operator → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Validated config: loads settings (evidence: `src/arb_scanner/cli.py`)
- CLI commands → Application assembly: starts scanning (evidence: `src/arb_scanner/cli.py`)
- Application assembly → Adapter registry: builds adapters (evidence: `src/arb_scanner/app.py`)
- Application assembly → Scan orchestration: creates scanner (evidence: `src/arb_scanner/app.py`)
- Validated config → Adapter registry: validates venues (evidence: `src/arb_scanner/config.py`)
- Adapter registry → Public exchange adapter: creates public adapter (evidence: `src/arb_scanner/exchanges/registry.py`)
- Adapter registry → Market simulator: creates simulator (evidence: `src/arb_scanner/exchanges/registry.py`)
- Public exchange adapter → Adapter interface: implements interface (evidence: `src/arb_scanner/exchanges/ccxt_public.py`)
- Market simulator → Adapter interface: implements interface (evidence: `src/arb_scanner/exchanges/simulated.py`)
- Public exchange adapter → Exchange public APIs: fetches order books (evidence: `README.md`)
- Scan orchestration → Adapter interface: fetches books (evidence: `README.md`)
- Adapter interface → Market and result models: returns order books (evidence: `src/arb_scanner/exchanges/base.py`)
- Scan orchestration → Market and result models: records scan results (evidence: `src/arb_scanner/scanner.py`)
- Scan orchestration → Route analysis: evaluates routes (evidence: `src/arb_scanner/scanner.py`)
- Route analysis → Market and result models: produces quotes (evidence: `src/arb_scanner/analysis.py`)
- Scan orchestration → Alerts: notifies listener (evidence: `README.md`)
- Scan orchestration → CSV and JSONL export: notifies listener (evidence: `README.md`)
- Scan orchestration → Run report: notifies listener (evidence: `README.md`)
- Scan orchestration → Live dashboard: updates dashboard (evidence: `README.md`)
- Alerts → Optional webhook: sends optional alerts (evidence: `README.md`)
- CLI commands → Live dashboard: serves dashboard (evidence: `src/arb_scanner/cli.py`)
- CLI commands → Run report: prints report (evidence: `src/arb_scanner/cli.py`)
- CLI commands → Logging setup: configures logging (evidence: `src/arb_scanner/cli.py`)
- Alerts → Logging setup: uses logging (evidence: `src/arb_scanner/alerts.py`)
