# paypal/junodb architecture

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

- Interactive diagram: https://gitdiagram.com/paypal/junodb
- Repository: https://github.com/paypal/junodb

## Overview

##### Main Components

a. Client Layer:
- Java Client Implementation
- Ruby Client Implementation
- Command-line Tools (junocli, junoload)
- Client Configuration Management

b. Proxy Layer (cmd/proxy):
- Request Handler
- Connection Management
- Statistics Collection
- Monitoring Workers
- Request Processors

c. Storage Layer (cmd/storageserv):
- Storage Manager
- Storage Workers
- Monitoring Workers
- RocksDB Integration
- Data Compaction

d. Cluster Management Layer:
- ETCD Service (cmd/etcdsvr)
- Cluster Configuration
- Shard Management
- Node Management
- Zone Management

##### Key Relationships to Highlight

a. Data Flow:
- Client → Proxy → Storage Server
- Bidirectional communication between components
- TLS/SSL secure connections

b. Management Flow:
- ETCD → Cluster Manager → Proxy/Storage nodes
- Configuration distribution
- Health monitoring

##### Architectural Patterns

a. Multi-layer Architecture:
- Clear separation between proxy and storage layers
- Independent scaling of components

b. High Availability:
- Multiple storage nodes
- Cluster management
- Replication mechanisms

##### Specific Implementation Details

a. Security Components:
- TLS/SSL implementation
- Certificate management
- Key store configuration

b. Monitoring & Statistics:
- OpenTelemetry integration
- Prometheus metrics
- Grafana dashboards

##### Specific elements

- Client SDKs (Java/Ruby)
- Proxy service with worker pools
- Storage servers with RocksDB
- ETCD cluster
- Monitoring components
- Security layer
- Configuration management
- Load balancing
- Replication paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef client fill:#90EE90,stroke:#333,stroke-width:2px
    classDef proxy fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef storage fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef management fill:#FFD700,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef monitoring fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer
        JavaClient["Java Client"]:::client
        RubyClient["Ruby Client"]:::client
        CLI["Command Line Tools"]:::client
        ClientConfig["Client Configuration"]:::client
    end

    %% Proxy Layer
    subgraph ProxyLayer
        ProxyService["Proxy Service"]:::proxy
        ReqHandler["Request Handler"]:::proxy
        ReqProcessor["Request Processor"]:::proxy
        ConnManager["Connection Manager"]:::proxy
        ProxyStats["Statistics Collector"]:::proxy
        ProxyMonitor["Monitoring Workers"]:::proxy
    end

    %% Storage Layer
    subgraph StorageLayer
        StorageService["Storage Service"]:::storage
        StorageManager["Storage Manager"]:::storage
        StorageWorkers["Storage Workers"]:::storage
        RocksDB["RocksDB"]:::storage
        DataCompaction["Data Compaction"]:::storage
    end

    %% Cluster Management Layer
    subgraph ClusterLayer
        ETCD["ETCD Service"]:::management
        ClusterMgr["Cluster Manager"]:::management
        ShardMgr["Shard Management"]:::management
        NodeMgr["Node Management"]:::management
        ZoneMgr["Zone Management"]:::management
    end

    %% Security Components
    subgraph SecurityLayer
        TLS["TLS/SSL"]:::security
        CertMgr["Certificate Manager"]:::security
        KeyStore["Key Store"]:::security
    end

    %% Monitoring Components
    subgraph MonitoringLayer
        OpenTelemetry["OpenTelemetry"]:::monitoring
        Prometheus["Prometheus"]:::monitoring
        Grafana["Grafana"]:::monitoring
    end

    %% Relationships
    JavaClient --> ProxyService
    RubyClient --> ProxyService
    CLI --> ProxyService
    ProxyService --> ReqHandler
    ReqHandler --> ReqProcessor
    ReqProcessor --> StorageService
    StorageService --> StorageManager
    StorageManager --> RocksDB
    ETCD --> ClusterMgr
    ClusterMgr --> ProxyService
    ClusterMgr --> StorageService
    OpenTelemetry --> Prometheus
    Prometheus --> Grafana

    %% Click events
    click JavaClient "https://github.com/paypal/junodb/tree/dev/client/Java/Juno/"
    click RubyClient "https://github.com/paypal/junodb/tree/dev/client/Ruby/juno/"
    click CLI "https://github.com/paypal/junodb/tree/dev/cmd/tools/junocli/"
    click ProxyService "https://github.com/paypal/junodb/tree/dev/cmd/proxy/"
    click ReqHandler "https://github.com/paypal/junodb/blob/dev/cmd/proxy/handler/requestHandler.go"
    click ReqProcessor "https://github.com/paypal/junodb/tree/dev/cmd/proxy/proc/"
    click StorageService "https://github.com/paypal/junodb/tree/dev/cmd/storageserv/"
    click StorageManager "https://github.com/paypal/junodb/blob/dev/cmd/storageserv/storage/storage.go"
    click RocksDB "https://github.com/paypal/junodb/blob/dev/cmd/storageserv/storage/db/rocksdb.go"
    click ETCD "https://github.com/paypal/junodb/tree/dev/cmd/etcdsvr/"
    click ClusterMgr "https://github.com/paypal/junodb/tree/dev/cmd/clustermgr/"
    click ShardMgr "https://github.com/paypal/junodb/blob/dev/pkg/cluster/shardmgr.go"
    click ProxyStats "https://github.com/paypal/junodb/tree/dev/pkg/stats/"
    click TLS "https://github.com/paypal/junodb/tree/dev/pkg/sec/"
    click OpenTelemetry "https://github.com/paypal/junodb/tree/dev/pkg/logging/otel/"
    click ClientConfig "https://github.com/paypal/junodb/tree/dev/pkg/cfg/"

    %% Legend
    subgraph Legend
        Client[Client Components]:::client
        Proxy[Proxy Components]:::proxy
        Storage[Storage Components]:::storage
        Management[Management Components]:::management
        Security[Security Components]:::security
        Monitoring[Monitoring Components]:::monitoring
    end
```
