# naver/arcus-c-client architecture

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

- Interactive diagram: https://gitdiagram.com/naver/arcus-c-client
- Repository: https://github.com/naver/arcus-c-client

## Overview

##### Project type and purpose
- This is arcus-c-client, an open-source C client library for Arcus memcached (a memcached variant with collection APIs and ZooKeeper-based clustering).
- It provides core client APIs (libmemcached), hashing utilities (libhashkit), Arcus collection APIs, ZooKeeper integration, CLI tools, examples, tests, and helper utilities.

##### File structure
- Top-level modules:
- arcus/        – Arcus collection APIs and multi-process/threaded wrappers
- libhashkit/   – Hash functions and common utilities for consistent hashing
- libmemcached/ – Core client implementation, protocol handlers, collection and ZooKeeper integration
- clients/      – Command-line tools (memcat, memslap, memstat, etc.) built on the client library
- util/         – Generic utilities (daemon, logging, pidfile, signal handling)
- example/      – Sample code showing basic usage
- tests/        – Unit and integration tests
- config/, m4/  – Build configuration and autotools macros
- Notice protocol subdirectory under libmemcached for ASCII and binary handlers.
- README highlights core features: B+tree, list, set APIs, ZooKeeper cluster discovery, and build/test instructions.

##### README for additional insights
- Describes layering: arcus functions call into libmemcached, which uses libhashkit for hashing and a protocol layer to communicate with memcached servers.
- ZooKeeper integration is optional; enabled at configure time; Arcus startup functions abstract cluster discovery.
- Example code shows API calls, underlying library usage, and server invocation.

##### Detail
- Protocol layer subcomponents: ascii_handler, binary_handler.
- Multi-threaded vs. multi-process entry points (arcus/multi_threaded.c, arcus/multi_process.c).
- Autotools configuration flow (autorun.sh, configure → Makefile).

Clarity by grouping related modules, using consistent iconography for libraries vs. services, and explicitly showing optional integrations (ZooKeeper).
This detailed, layered view will provide an accurate and comprehensive structural overview of the project.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "User Applications"
        CLI["CLI Tools"]:::cli
        EX["Sample Code"]:::cli
    end

    subgraph "Arcus-C-Client Library"
        ARCAPI["Arcus API Layer"]:::internal
        CORE["Core Client API (libmemcached)"]:::internal
        HASH["Hashing Engine (libhashkit)"]:::internal
        PROT["Protocol Handlers"]:::internal
        LMUTIL["LibmemcachedUtil"]:::internal
        UTIL["Generic Utilities"]:::internal
    end

    subgraph "External Services"
        MEMC["Memcached Servers"]:::external
        ZK["ZooKeeper Ensemble"]:::external
    end

    subgraph "Tests & Build"
        TESTS["Test Harness"]:::test
        CONFIG["Build Configurations"]:::config
        M4MAC["Autotools Macros"]:::config
    end

    %% Relationships
    CLI -->|"uses"| ARCAPI
    EX -->|"demonstrates"| ARCAPI

    ARCAPI -->|"calls"| CORE
    CORE -->|"uses"| HASH
    CORE -->|"invokes"| PROT
    CORE -->|"links to"| LMUTIL
    CORE -->|"links to"| UTIL

    PROT -->|"network I/O"| MEMC
    ARCAPI -->|"discovers cluster"| ZK

    TESTS -->|"exercise"| ARCAPI
    TESTS -->|"exercise"| CORE

    CONFIG -->|"configures build"| ARCAPI
    CONFIG -->|"configures build"| CORE
    CONFIG -->|"configures build"| HASH
    M4MAC -->|"macros for"| ARCAPI
    M4MAC -->|"macros for"| CORE
    M4MAC -->|"macros for"| HASH

    %% Click Events
    click ARCAPI "https://github.com/naver/arcus-c-client/tree/master/arcus/"
    click CORE "https://github.com/naver/arcus-c-client/tree/master/libmemcached/"
    click HASH "https://github.com/naver/arcus-c-client/tree/master/libhashkit/"
    click PROT "https://github.com/naver/arcus-c-client/tree/master/libmemcached/protocol/"
    click LMUTIL "https://github.com/naver/arcus-c-client/tree/master/libmemcached/util/"
    click UTIL "https://github.com/naver/arcus-c-client/tree/master/util/"
    click CLI "https://github.com/naver/arcus-c-client/tree/master/clients/"
    click EX "https://github.com/naver/arcus-c-client/tree/master/example/"
    click TESTS "https://github.com/naver/arcus-c-client/tree/master/tests/"
    click CONFIG "https://github.com/naver/arcus-c-client/tree/master/config/"
    click M4MAC "https://github.com/naver/arcus-c-client/tree/master/m4/"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef external fill:#90EE90,stroke:#000,stroke-width:1px
    classDef cli fill:#FFFF99,stroke:#000,stroke-width:1px
    classDef test fill:#FFCC99,stroke:#000,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#000,stroke-width:1px
```
