# 0xmoncif213/rollupthecrowd architecture

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

- Interactive diagram: https://gitdiagram.com/0xmoncif213/rollupthecrowd
- Repository: https://github.com/0xmoncif213/rollupthecrowd

## Overview

##### Project type and purpose
- RollupTheCrowd is a blockchain-based, privacy-preserving crowdsourcing platform built on zkRollups (zkSync) and Chainlink oracles. It spans on-chain smart contracts (L1 & L2), off-chain deployment and interaction scripts, benchmarking, monitoring, and result analysis.

##### File structure
- Top-level directories:
- setup/: docker-based bootstrap for Chainlink nodes, PostgreSQL, zkSync local node
- contracts/: Solidity code (LINK token, Oracle contracts, core system contracts & libraries)
- interactions/: Hardhat/TypeScript scripts for L1 and L2 contract deployment & method calls
- benchmark/: Hyperledger Caliper configs and workloads for BusinessLogic, PreEvaluation, ReputationModel, AccessManagement
- monitor/: Docker-Compose + Prometheus + Grafana setup for collecting geth & node metrics
- results/: Raw data, Python plotting scripts, visualizations of gas, latency, effectiveness
- Notice the clear separation of concerns: on-chain artifacts, off-chain orchestration, performance testing, observability, and data analysis.

##### README for additional insights
- The README confirms:
- “BC-Client/Chainlink/ZkSync nodes” must be orchestrated
- Each sub-directory includes its own README guiding installation and usage
- The aim is to reproduce experiments from the associated paper

a. Main components
– Ethereum L1 network (Geth node)
– zkSync L2 rollup node
– Chainlink oracle node(s) (dockerized)
– Smart contracts deployed on L1 & L2:
· LINK token (L1)
· Oracle-interface contracts (L1)
· System-contracts (L2) implementing tasks, bids, solutions, reputation
– Off-chain orchestration:
· Hardhat scripts (interactions/L1 & L2) for deployment & calls
· Hyperledger Caliper (benchmark) workload runners
– Monitoring stack: Prometheus scraping node metrics, Grafana dashboards
– Results & plotting environment (Python scripts)
b. Relationships & interactions
– Hardhat→ deploys contracts to L1 & L2
– Front-end or CLI (not present but implied) invokes scripts under interactions/ to call contract methods
– Contracts on L2 reference oracles on L1 via Chainlink nodes
– Caliper clients send transactions to L1/L2 as workloads, collect throughput/latency
– Prometheus crawls geth/zkSync/Chainlink metrics → Grafana visualizes
– Results folder ingests Caliper JSON output → Python scripts generate graphs
c. Architectural patterns & principles
– On-chain/off-chain separation
– Layer-2 rollup pattern for scalability
– Modular smart contract design (token, oracle adapter, business logic)
– Micro-benchmarking suite decoupled from main code
– Infrastructure as code via Docker-Compose
d. Key technologies/frameworks
– Solidity (contracts)
– Hardhat + TypeScript (deployment & interaction)
– Hyperledger Caliper (benchmarks)
– Docker & Docker-Compose (setup, monitor)
– Prometheus & Grafana (observability)
– zkSync local node (L2 rollup)
– Chainlink node (oracles)

##### Essential architectural elements
- You include every sub-system: setup scripts, smart contract groups, interaction scripts, benchmark workloads, monitoring/observability, result analysis
- Avoid overcrowding: group similar workloads or contracts as a single “Business Logic Contracts” block but annotate its internal modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% On-Chain Layer
    subgraph "Ethereum L1"
        direction TB
        Geth["Geth Node"]:::onchain
        Chainlink["Chainlink Node(s)"]:::onchain
        LINKToken["LINK Token Contract"]:::onchain
        OracleInterface["Oracle-Interface Contracts"]:::onchain
    end

    subgraph "zkSync L2"
        direction TB
        zkSync["zkSync Rollup Node"]:::onchain
        SysContracts["System Contracts (tasks, bids, solutions, reputation)"]:::onchain
    end

    %% Off-Chain Deployment
    HardhatL1(["Hardhat L1 Scripts"]):::offchain
    HardhatL2A(["L2 Deploy & Interact Scripts"]):::offchain
    HardhatL2B(["L2 Library Deployment Scripts"]):::offchain

    %% Benchmarking
    Caliper(["Caliper Benchmark Clients"]):::benchmark

    %% Monitoring
    Prometheus["Prometheus"]:::monitor
    Grafana["Grafana"]:::monitor

    %% Results & Analysis
    ResultsData(["Results Data"]):::results
    PlotScripts(["Python Plotting Scripts"]):::results

    %% Deployment Flows
    HardhatL1 -->|"deploy via JSON-RPC"| Geth
    HardhatL1 -->|"deploy"| LINKToken
    HardhatL1 -->|"deploy"| OracleInterface
    HardhatL2A -->|"deploy"| zkSync
    HardhatL2A -->|"deploy"| SysContracts
    HardhatL2B -->|"deploy libraries"| SysContracts

    %% Benchmark Workloads
    Caliper -->|"JSON-RPC"| Geth
    Caliper -->|"JSON-RPC"| zkSync

    %% Oracle Interaction
    Chainlink -.->|"oracle responses"| SysContracts

    %% Monitoring Metrics
    Geth -->|"metrics"| Prometheus
    zkSync -->|"metrics"| Prometheus
    Chainlink -->|"metrics"| Prometheus
    Prometheus -->|"visualize"| Grafana

    %% Results Processing
    Caliper -->|"benchmark data"| ResultsData
    ResultsData -->|"plot data"| PlotScripts

    %% Click Events
    click Geth "https://github.com/0xmoncif213/rollupthecrowd/blob/main/setup/chainlink-docker-services/docker-compose.yml"
    click Chainlink "https://github.com/0xmoncif213/rollupthecrowd/blob/main/setup/chainlink-docker-services/docker-compose.yml"
    click zkSync "https://github.com/0xmoncif213/rollupthecrowd/blob/main/setup/zkSync-local-node/docker-compose.yml"
    click LINKToken "https://github.com/0xmoncif213/rollupthecrowd/tree/main/contracts/LINKTOKEN-V0.6/"
    click OracleInterface "https://github.com/0xmoncif213/rollupthecrowd/tree/main/contracts/Oracle-contracts/"
    click SysContracts "https://github.com/0xmoncif213/rollupthecrowd/tree/main/contracts/System-contracts/"
    click HardhatL1 "https://github.com/0xmoncif213/rollupthecrowd/tree/main/interactions/L1/hardhat-sever-deployement/"
    click HardhatL2A "https://github.com/0xmoncif213/rollupthecrowd/tree/main/interactions/L2/deploy-interact-contract/"
    click HardhatL2B "https://github.com/0xmoncif213/rollupthecrowd/tree/main/interactions/L2/deploy-libraries/"
    click Caliper "https://github.com/0xmoncif213/rollupthecrowd/tree/main/benchmark/"
    click Prometheus "https://github.com/0xmoncif213/rollupthecrowd/blob/main/monitor/prometheus.yml"
    click Grafana "https://github.com/0xmoncif213/rollupthecrowd/blob/main/monitor/grafana-dashboard.json"
    click ResultsData "https://github.com/0xmoncif213/rollupthecrowd/tree/main/results/data/"
    click PlotScripts "https://github.com/0xmoncif213/rollupthecrowd/tree/main/results/plot-scripts/"

    %% Styles
    classDef onchain fill:#add8e6,stroke:#333,stroke-width:1px;
    classDef offchain fill:#90ee90,stroke:#333,stroke-width:1px;
    classDef benchmark fill:#ffa500,stroke:#333,stroke-width:1px;
    classDef monitor fill:#dda0dd,stroke:#333,stroke-width:1px;
    classDef results fill:#d3d3d3,stroke:#333,stroke-width:1px;
```
