# saoxuan/rust-mev-bot-shared architecture

> Architecture diagram of the GitHub repository saoxuan/rust-mev-bot-shared, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saoxuan/rust-mev-bot-shared
- Repository: https://github.com/saoxuan/rust-mev-bot-shared

## Overview

##### Project Identification
- The project is a high‐performance Solana MEV arbitrage bot written in Rust. Its main purpose is to execute automated arbitrage trades on the Solana network using multiple engines (with a special focus on Jito Bundle), integrating with Jupiter aggregator for swap functionality.
- Key features mentioned in the README include automated arbitrage trading, parallel processing using multiple Jito engine nodes, real-time error monitoring, multi-IP and multi-node support, and high-speed trade execution (under 10ms).

##### Analyzing the File Structure
- Top-Level Files and Scripts:
– README.md: Contains the project overview and usage instructions.
– config.yaml.example: Indicates that configuration settings (e.g., API keys, node URLs, trading parameters) are externalized to a YAML config file.
– Several shell scripts (kill-process.sh, mints-query.sh, run-jup.sh, run.sh, upgrade.sh): These scripts are utilities for starting, stopping, or updating various parts of the system.
– jupiter-swap-api and rust-mev-bot: These appear to be the core executable components. "rust-mev-bot" is most likely the main arbitrage engine written in Rust. "jupiter-swap-api" may encapsulate functionality related to interfacing with the Jupiter aggregator (for swap data, routing, or trade execution).

##### Main Components
- Rust MEV Bot Engine:
– The heart of the system, responsible for monitoring markets, executing arbitrage logic, and managing concurrent trade executions.
- Jupiter Swap API Module:
– Acts as the intermediary between the Rust MEV Bot and the Jupiter aggregator service. This component handles market data, swap routing, and trading operations through Jupiter.
- Configuration Module:
– Loaded from “config.yaml” (using the provided example file), it holds all runtime parameters, API keys, node configurations, and trading parameters.
- External Services/Dependencies:
– Solana Blockchain Network: The primary blockchain for executing arbitrage transactions.
– RPC Providers & GRPC Services: As recommended in the README (such as Helius, Quicknode, Shyft, and KawaiiLabs), these external connections are critical for interacting with the Solana network and retrieving real-time data.
– Jito Bundle Engine Nodes: The arbitrage bot leverages multiple Jito engine nodes to parallelize processing and optimize trade execution speeds.

##### Illustrating Relationships and Data Flow
- A communication channel from the bot engine to the Jupiter Swap API module, which will manage the interaction with the Jupiter aggregator.
- Configuration module feeding essential parameters into both the bot engine and the API module.
- Parallel and multi-node processing (e.g., grouping several Jito nodes) that the Rust MEV Bot utilizes for high-performance arbitrage.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly distinguish between the arbitrage engine, the API integration module, the configuration management, and external service integration.
- Modular Design: Each component (Rust MEV Bot, Jupiter Swap API) should be represented as a separate module that interacts through well-defined interfaces.
- High Concurrency: Emphasize the parallel processing capabilities, particularly with the multi-Jito node support where multiple threads or processes run concurrently.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        rpc("Solana RPC/GRPC Providers"):::external
        aggregator("Jupiter Aggregator"):::external
    end

    %% Configuration Module
    config("Configuration Module"):::config

    %% Core Trading Logic Layer
    subgraph "Core Trading Logic"
        bot("Rust MEV Bot Engine"):::core
        jito("Jito Bundle Engine Node Cluster"):::core
    end

    %% API Integration Layer
    subgraph "API Integration"
        jupiterapi("Jupiter Swap API Module"):::api
    end

    %% Deployment & Management Scripts
    subgraph "Deployment & Management Scripts"
        script1("README.md"):::script
        script2("kill-process.sh"):::script
        script3("mints-query.sh"):::script
        script4("run-jup.sh"):::script
        script5("run.sh"):::script
        script6("upgrade.sh"):::script
    end

    %% Connections
    rpc -->|"feedsData"| bot
    config -->|"configFeeds"| bot
    config -->|"configFeeds"| jupiterapi
    bot -->|"triggersSwap"| jupiterapi
    bot -->|"parallelProcess"| jito
    jupiterapi -->|"callsAggregator"| aggregator

    %% Styles
    classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef core fill:#FCF3CF,stroke:#F1C40F,stroke-width:2px;
    classDef api fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef script fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;

    %% Click Events
    click bot "https://github.com/saoxuan/rust-mev-bot-shared/tree/main/rust-mev-bot"
    click jupiterapi "https://github.com/saoxuan/rust-mev-bot-shared/tree/main/jupiter-swap-api"
    click config "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/config.yaml.example"
    click script1 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/README.md"
    click script2 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/kill-process.sh"
    click script3 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/mints-query.sh"
    click script4 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/run-jup.sh"
    click script5 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/run.sh"
    click script6 "https://github.com/saoxuan/rust-mev-bot-shared/blob/main/upgrade.sh"
```
