# rust-bitcoin/corepc architecture

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

- Interactive diagram: https://gitdiagram.com/rust-bitcoin/corepc
- Repository: https://github.com/rust-bitcoin/corepc

## Overview

##### Project Type and Purpose
- This is a Rust workspace providing:
- corepc-types: strongly typed Rust representations of every Bitcoin Core JSON-RPC method across versions (v17–v28).
- corepc-client: a blocking JSON-RPC client (not for production) that exercises types.
- corepc-node: a regtest node launcher for integration tests.
- jsonrpc: minimal JSONRPC 2.0 transport layer over HTTP/TCP/UDS.
- integration_test: end-to-end tests combining node + client + types.
- fuzz: fuzz harnesses targeting the JSONRPC client and types.
- verify: a tool that reads RPC API spec files and ensures the types/clients cover every method.

##### File‐Structure Analysis
- Top‐level crates: types/, client/, node/, jsonrpc/, integration_test/, fuzz/, verify/.
- Versioned Rust modules under types/src/v17…v28 and client/src/client_sync/v17…v28.
- Contrib/ directories with helper scripts; GitHub workflows for CI/fuzz.
- Cargo.toml in root plus per‐crate manifests – a typical Cargo workspace.

##### README Insights
- Describes crate roles, MSRV, design goal (exhaustive per‐version coverage), intended use (types in production; client only for tests).
- No runtime service‐oriented architecture; rather a multi-crate toolchain for testing and type generation.

##### Detail Level
- Per‐version modules only if zooming into the type schema component. Otherwise, show “types/src/v*/” as one grouped block.
- Explicitly show how verify uses RPC spec files (verify/rpc-api-v*.txt) to drive coverage checking.
- For fuzz, show two targets: HTTP transport fuzzing and JSON parsing fuzzing.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Libraries
    subgraph "Libraries"
        direction TB
        types["corepc-types: schema library"]:::libs
        jsonrpc["jsonrpc: transport library"]:::libs
    end

    %% Clients/Executables
    subgraph "Clients/Executables"
        direction TB
        client["corepc-client: test client"]:::clients
        node["corepc-node: regtest node launcher"]:::clients
        verify["verify: spec coverage checker"]:::clients
    end

    %% Testing Orchestration
    subgraph "Testing Orchestration"
        direction TB
        integration_test["integration_test: end-to-end tests"]:::qa
        fuzz["fuzz: fuzz runner & targets"]:::qa
    end

    %% External Service
    BitcoinCore["Bitcoin Core (bitcoind)"]:::external

    %% Data Flows
    client -->|"invoke send_request"| jsonrpc
    jsonrpc -->|"HTTP/TCP/UDS: JSONRPC 2.0 request"| BitcoinCore
    BitcoinCore -->|"JSONRPC response"| jsonrpc
    jsonrpc -->|"raw JSON"| client
    client -->|"deserialize JSON→typed structs/enums"| types

    integration_test -->|"launches"| node
    node -->|"starts regtest bitcoind"| BitcoinCore
    integration_test -->|"invokes"| client
    integration_test -->|"asserts round-trip via"| types

    fuzz -->|"fuzz http transport"| jsonrpc
    fuzz -->|"fuzz JSON parsing"| types

    verify -->|"reads RPC spec files"| verify
    verify -->|"inspects modules"| types
    verify -->|"inspects modules"| client

    %% Click Events
    click types "https://github.com/rust-bitcoin/corepc/tree/master/types/"
    click jsonrpc "https://github.com/rust-bitcoin/corepc/tree/master/jsonrpc/"
    click client "https://github.com/rust-bitcoin/corepc/tree/master/client/"
    click node "https://github.com/rust-bitcoin/corepc/tree/master/node/"
    click integration_test "https://github.com/rust-bitcoin/corepc/tree/master/integration_test/"
    click fuzz "https://github.com/rust-bitcoin/corepc/tree/master/fuzz/"
    click verify "https://github.com/rust-bitcoin/corepc/tree/master/verify/"

    %% Styles
    classDef libs fill:lightgreen,stroke:#333,stroke-width:1px
    classDef clients fill:lightblue,stroke:#333,stroke-width:1px
    classDef qa fill:lightsalmon,stroke:#333,stroke-width:1px
    classDef external fill:lightcoral,stroke:#333,stroke-width:1px
```
