# babybear-labs/benchmark architecture

> Architecture diagram of the GitHub repository babybear-labs/benchmark, 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/babybear-labs/benchmark
- Repository: https://github.com/babybear-labs/benchmark

## Overview

##### Main Components
- Independent Proof System Modules: Represent each major subcomponent as an independent module (Circom, Jolt, Nexus, Powdr, Halo2, RISC Zero, SP1, Zokrates, etc.). For each module, indicate:
– Its source code (e.g., Rust code for Jolt/Nexus, shell scripts and circuits for Circom).
– Specific directories for tests, circuits/algorithms, and build scripts.
- Reporting/Aggregation Module: Show a module (or folder) for “reports” that collects and stores benchmark results and related metrics.
- Documentation and Utility Components: Include components such as the “documentation” folder, ancillary scripts (e.g., compile scripts in Circom), and configuration files that inform each module’s operation.

##### Relationships and Interactions
- Data Flow: Illustrate that the Benchmark Orchestrator (whether manual or automated) initiates tests on each individual proof system module.
- Each module runs its specific tests (e.g., compiling circuits, running proof generation, and verification routines) then outputs performance metrics and results.
- The results are then gathered into the Reports module (with directories for each proof system, e.g., reports/jolt, reports/circom, etc.).

##### Architectural Patterns and Design Principles
- Layered Structure: At the top, the Benchmark Orchestrator sits as a “driver/manager” that interacts with the lower-level modules (each implementing one ZK-proof system).
- Reusability & Extensibility: Since many benchmarking scripts (e.g., test_fibonacci.py, test_poseidon.py) and build configuration files (Cargo.toml, Makefile, etc.) can be reused or extended, highlight extensibility points in the design.
- Integration Points: Show where common libraries or environments (e.g., Rust/Cargo for many modules, shell scripts for Circom) fit within each module.

##### Relevant Technologies and Frameworks
- Rust and Cargo: Used widely in modules like Jolt, Nexus, Powdr, RISC Zero, and SP1.
- Circom HDL: Used in the Circom module, along with its associated bash scripts, Python utilities, and circuit files.
- Build and Scripting Tools: Makefiles, shell scripts, and Python test harnesses are present to manage compilation and execution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    BO("Benchmark Orchestrator"):::orchestrator
    REP("Reporting/Aggregation Module"):::report
    DOC("Documentation Component"):::doc

    %% Proof System Modules
    subgraph "Proof System Modules"
        %% Circom Module with internal details
        subgraph "Circom Module"
            COV("Overview"):::module
            C1("Circuits"):::subcomponent
            C2("Compilation&Proving Scripts"):::subcomponent
            C3("Test Scripts"):::subcomponent
            COV --> C1
            C1 --> C2
            C2 --> C3
        end
        H("Halo2 Module"):::module
        J("Jolt Module"):::module
        N("Nexus Module"):::module
        P("Powdr Module"):::module
        RZ("RISC Zero Module"):::module
        SP("SP1 Module"):::module
        Z("Zokrates Module"):::module
    end

    %% Data Flow Connections from Orchestrator to Modules
    BO -->|"triggers"| COV
    BO -->|"triggers"| H
    BO -->|"triggers"| J
    BO -->|"triggers"| N
    BO -->|"triggers"| P
    BO -->|"triggers"| RZ
    BO -->|"triggers"| SP
    BO -->|"triggers"| Z

    %% Modules output benchmark results to Reporting Module
    COV -->|"outputs"| REP
    H -->|"outputs"| REP
    J -->|"outputs"| REP
    N -->|"outputs"| REP
    P -->|"outputs"| REP
    RZ -->|"outputs"| REP
    SP -->|"outputs"| REP
    Z -->|"outputs"| REP

    %% Documentation guides Orchestrator and Modules
    DOC ---|"guides"| BO
    DOC ---|"guides"| COV
    DOC ---|"guides"| H
    DOC ---|"guides"| J
    DOC ---|"guides"| N
    DOC ---|"guides"| P
    DOC ---|"guides"| RZ
    DOC ---|"guides"| SP
    DOC ---|"guides"| Z

    %% Click Events for Component Mapping
    click COV "https://github.com/babybear-labs/benchmark/tree/main/circom"
    click C1 "https://github.com/babybear-labs/benchmark/tree/main/circom/circuits"
    click C2 "https://github.com/babybear-labs/benchmark/blob/main/circom/scripts/compile_circuit.sh"
    click C3 "https://github.com/babybear-labs/benchmark/blob/main/circom/test_fibonacci.py"
    click H "https://github.com/babybear-labs/benchmark/tree/main/halo2"
    click J "https://github.com/babybear-labs/benchmark/tree/main/jolt"
    click N "https://github.com/babybear-labs/benchmark/tree/main/nexus"
    click P "https://github.com/babybear-labs/benchmark/tree/main/powdr"
    click RZ "https://github.com/babybear-labs/benchmark/tree/main/risc-zero"
    click SP "https://github.com/babybear-labs/benchmark/tree/main/sp1"
    click Z "https://github.com/babybear-labs/benchmark/tree/main/zokrates"
    click REP "https://github.com/babybear-labs/benchmark/tree/main/reports"
    click DOC "https://github.com/babybear-labs/benchmark/blob/main/documentation/Documentation.pdf"

    %% Styles
    classDef orchestrator fill:#FFCCFF,stroke:#990099,stroke-width:2px;
    classDef module fill:#BBDEFF,stroke:#0D47A1,stroke-width:2px;
    classDef subcomponent fill:#E3F2FD,stroke:#1565C0,stroke-width:1px;
    classDef report fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef doc fill:#FFE0B2,stroke:#E65100,stroke-width:2px;
```
