# tsuna/gohbase architecture

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

- Interactive diagram: https://gitdiagram.com/tsuna/gohbase
- Repository: https://github.com/tsuna/gohbase

## Overview

##### Main Components Identification

a) Client Interface Layer:
- High-level API methods (Get, Put, Scan) that users interact with

b) HRPC (HBase Remote Procedure Call) Layer:
- Hrpc package which contains all RPC definitions
- Different types of operations (get.go, put.go, scan.go, etc.)

c) Region Management Layer:
- Region package handling region client operations
- Region discovery and management components

d) Protocol Buffer Layer:
- Pb directory containing all protobuf definitions
- Communication protocol with HBase

e) ZooKeeper Integration:
- Zk package that handles cluster discovery and configuration

##### Component Relationships

**[Client Application] → [GoHBase Client Interface]**
- ↓
**[HRPC Layer] ← → [Region Management] ← → [Protocol Buffers]**
- ↓
**[ZooKeeper Client] ← → [HBase Cluster]**

##### Specific Elements

- Rectangles: Main client interface
- Hexagons: HRPC operations
- Parallelograms: Protocol buffer interfaces

b) Support Components:
- Compression handling (compression package)
- Filtering mechanisms (filter package)
- Caching layer (caches.go)

##### Data Flow Representation

- Client request flow: Application → Client Interface → HRPC → Region Management → HBase
- Response flow: HBase → Protocol Buffers → Region Management → Client Interface → Application
- Metadata flow: ZooKeeper ← → Region Management

##### Important Details to Highlight

- Green: Read operations (Get, Scan)
- Blue: Write operations (Put, Delete)
- Yellow: Admin operations
- Gray: Support functions

- Annotations for:
- Compression options
- Filter capabilities
- Error handling paths
- Retry mechanisms

##### Technical Specifications

Technical notes for:
- Protocol Buffer message types
- Supported HBase versions (≥ 1.0)
- Go module dependencies
- Compression codecs supported

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        CI[Client Interface]
        AC[Admin Client]
        click CI "https://github.com/tsuna/gohbase/blob/master/client.go"
        click AC "https://github.com/tsuna/gohbase/blob/master/admin_client.go"
    end

    subgraph HRPC
        Call[RPC Call Handler]
        Get[Get Operations]
        Put[Put Operations]
        Scan[Scan Operations]
        Mutate[Mutate Operations]
        Query[Query Operations]
        click Call "https://github.com/tsuna/gohbase/blob/master/hrpc/call.go"
        click Get "https://github.com/tsuna/gohbase/blob/master/hrpc/get.go"
        click Put "https://github.com/tsuna/gohbase/blob/master/hrpc/put.go"
        click Scan "https://github.com/tsuna/gohbase/blob/master/hrpc/scan.go"
        click Mutate "https://github.com/tsuna/gohbase/blob/master/hrpc/mutate.go"
        click Query "https://github.com/tsuna/gohbase/blob/master/hrpc/query.go"
    end

    subgraph "Region Management"
        RC[Region Client]
        RI[Region Info]
        RN[Region New]
        RM[Region Multi]
        click RC "https://github.com/tsuna/gohbase/blob/master/region/client.go"
        click RI "https://github.com/tsuna/gohbase/blob/master/region/info.go"
        click RN "https://github.com/tsuna/gohbase/blob/master/region/new.go"
        click RM "https://github.com/tsuna/gohbase/blob/master/region/multi.go"
    end

    subgraph "Protocol Buffers"
        HBasePB[HBase Protobuf]
        ClientPB[Client Protobuf]
        RPCPB[RPC Protobuf]
        ZKPB[ZooKeeper Protobuf]
        CellPB[Cell Protobuf]
        click HBasePB "https://github.com/tsuna/gohbase/blob/master/pb/HBase.pb.go"
        click ClientPB "https://github.com/tsuna/gohbase/blob/master/pb/Client.pb.go"
        click RPCPB "https://github.com/tsuna/gohbase/blob/master/pb/RPC.pb.go"
        click ZKPB "https://github.com/tsuna/gohbase/blob/master/pb/ZooKeeper.pb.go"
        click CellPB "https://github.com/tsuna/gohbase/blob/master/pb/Cell.pb.go"
    end

    subgraph "Support Components"
        Comp[Compression]
        CompSnappy[Snappy Compression]
        Filter[Filtering]
        Cache[Caching]
        click Comp "https://github.com/tsuna/gohbase/blob/master/compression/codec.go"
        click CompSnappy "https://github.com/tsuna/gohbase/blob/master/compression/snappy/snappy.go"
        click Filter "https://github.com/tsuna/gohbase/blob/master/filter/filter.go"
        click Cache "https://github.com/tsuna/gohbase/blob/master/caches.go"
    end

    subgraph "Core RPC"
        RPCCore[RPC Core]
        Scanner[Scanner]
        click RPCCore "https://github.com/tsuna/gohbase/blob/master/rpc.go"
        click Scanner "https://github.com/tsuna/gohbase/blob/master/scanner.go"
    end

    subgraph "Observability"
        Obs[Observability]
        Prom[Prometheus]
        click Obs "https://github.com/tsuna/gohbase/blob/master/internal/observability/observability.go"
        click Prom "https://github.com/tsuna/gohbase/blob/master/prometheus.go"
    end

    subgraph "ZooKeeper"
        ZK[ZooKeeper Client]
        click ZK "https://github.com/tsuna/gohbase/blob/master/zk/client.go"
    end

    %% Connections
    CI --> Call
    AC --> Call
    Call --> Get & Put & Scan & Mutate & Query
    Get & Put & Scan & Mutate & Query --> RC
    RC --> RI
    RC --> RN
    RC --> RM
    RC --> HBasePB
    RC --> ClientPB
    RC --> RPCPB
    RC --> CellPB
    RC --> ZK
    RC --> Comp
    Comp --> CompSnappy
    RC --> Filter
    RC --> Cache
    RC --> RPCCore
    RPCCore --> Scanner
    RPCCore --> Obs
    Obs --> Prom
    ZK --> ZKPB

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef client fill:#e1f5fe,stroke:#0288d1
    classDef hrpc fill:#fff3e0,stroke:#ff9800
    classDef region fill:#e8f5e9,stroke:#4caf50
    classDef protobuf fill:#fce4ec,stroke:#e91e63
    classDef support fill:#f3e5f5,stroke:#9c27b0
    classDef rpc fill:#fffde7,stroke:#ffd600
    classDef obs fill:#efebe9,stroke:#795548
    classDef zk fill:#e8eaf6,stroke:#3f51b5

    class CI,AC client
    class Call,Get,Put,Scan,Mutate,Query hrpc
    class RC,RI,RN,RM region
    class HBasePB,ClientPB,RPCPB,ZKPB,CellPB protobuf
    class Comp,CompSnappy,Filter,Cache support
    class RPCCore,Scanner rpc
    class Obs,Prom obs
    class ZK zk
```
