# solstackapp/geyserbench architecture

> Architecture diagram of the GitHub repository solstackapp/geyserbench, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/solstackapp/geyserbench
- Repository: https://github.com/solstackapp/geyserbench

## Overview

##### Main Components
- Config Loader: This part of the system is responsible for creating and reading the default “config.toml” file that holds your benchmarking parameters (number of transactions, account address, commitment level, and gRPC endpoint configurations).
- Benchmarking Core: This module manages the load generation (i.e., sending requests), collects responses, and measures performance (first detection rate, average delay, median, 95th percentile, etc.).
- Metrics Aggregator & Analyzer: After gathering raw data from each endpoint, this component computes the detailed statistics and prepares both simple summary and extended reports.
- Output Formatter: It presents the results to the user via the terminal, generating both quick summaries and detailed breakdowns.

##### Component Interactions
- The system starts by loading configurations from the “config.toml” file.
- The Config Loader passes endpoint and benchmarking parameters to the gRPC Client Manager.
- The gRPC Client Manager concurrently initiates connections with all endpoints.
- Query or transaction generation is managed by the Benchmarking Core, which sends out the benchmarking workload across endpoints.
- Streaming and asynchronous responses from endpoints are collected, and data is forwarded for processing to the Metrics Aggregator.
- Finally, the output is formatted by the Output Formatter and displayed on the command line.

##### Architectural Patterns & Design Principles
- Concurrency/Parallelism: Since multiple endpoints are benchmarked concurrently, be sure to illustrate asynchronous execution (e.g., using Rust’s async runtime like Tokio if applicable).
- Data Flow: Emphasize directional data flow from configuration input to network requests, asynchronous response collection, and finally metrics computation leading to user output.
- Error Handling & Logging (implicit): You might also note that certain parts of the code (likely within the gRPC Client Manager and Benchmarking Core) handle errors in networking or malformed responses.

##### Technologies & Frameworks
- Rust as the primary language (as indicated by Cargo.toml and src/main.rs).
- gRPC for communication with the Solana endpoints.
- An asynchronous runtime (like Tokio) if used for concurrently managing network requests.
- Libraries for metrics aggregation and possibly serialization/deserialization for configuration (e.g., using toml crate).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "GeyserBench Core"
        ConfigLoader("Config Loader"):::internal
        benchCore("Benchmarking Core"):::internal
        grpcClient("gRPC Client Manager"):::internal
        metricsAgg("Metrics Aggregator & Analyzer"):::internal
        outputFormatter("Output Formatter"):::internal
    end

    subgraph "External Endpoints"
        ep1("Solana gRPC Endpoint 1"):::external
        ep2("Solana gRPC Endpoint 2"):::external
        ep3("Solana gRPC Endpoint 3"):::external
    end

    %% Component Interactions
    ConfigLoader -->|"loadConfig"| grpcClient
    ConfigLoader -->|"passParams"| benchCore
    benchCore -->|"sendLoad"| grpcClient
    grpcClient -->|"connectsTo"| ep1
    grpcClient -->|"connectsTo"| ep2
    grpcClient -->|"connectsTo"| ep3
    ep1 -->|"sendResponse"| metricsAgg
    ep2 -->|"sendResponse"| metricsAgg
    ep3 -->|"sendResponse"| metricsAgg
    metricsAgg -->|"processMetrics"| outputFormatter

    %% Click Events
    click ConfigLoader "https://github.com/solstackapp/geyserbench/blob/main/src/main.rs"
    click grpcClient "https://github.com/solstackapp/geyserbench/blob/main/src/main.rs"
    click benchCore "https://github.com/solstackapp/geyserbench/blob/main/src/main.rs"
    click metricsAgg "https://github.com/solstackapp/geyserbench/blob/main/src/main.rs"
    click outputFormatter "https://github.com/solstackapp/geyserbench/blob/main/src/main.rs"

    %% Styles
    classDef internal fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px,color:#0D47A1;
    classDef external fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,color:#2E7D32;
```
