# apache/geode-native architecture

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

- Interactive diagram: https://gitdiagram.com/apache/geode-native
- Repository: https://github.com/apache/geode-native

## Overview

##### Project type and purpose
- This is “Apache Geode Native”: a native‐client library implementation for Apache Geode providing C++ and .NET APIs that speak the Geode wire protocol without requiring Java.
- It ships two first‐class language bindings:
- cppcache – the C++ API layer and core protocol implementation
- clicache – the .NET (C#) CLI wrapper around the native C++ core

##### Top-level architecture components
A. Application Layer
- Consumer code (examples/, tests/, user applications) written in C++ or C#
B. Language Bindings / API Layer
1. cppcache
– Public headers in include/geode/
– Implementation in src/ (Cache, Region, Query, Pdx, Pool, etc.)
2. clicache
– Managed wrapper (C++/CLI) that exposes the native core to .NET
– Adapter classes in clicache/src/impl/ bridging managed ↔ unmanaged
C. Core Protocol & Transport
- TcrConnection, TcrDistributionManager, ThinClient* modules (in cppcache/src/)
- Message encoding/decoding under tools/gnmsg and in the core
- SSL/TCP sockets (TcpConn, TcpSslConn)
D. Serialization & PDX subsystem
- PdxReader/Writer, DataSerializable, TypeRegistry modules
E. Build & Packaging
- CMakeLists.txt at top and per-module (clicache/, cppcache/, tests/, examples/)
- ci/ and docker/ for CI pipelines and container images
- packer/ for VM build recipes
F. Documentation & Examples
- docs/ for static site, API references, user guides
- examples/ for code samples in C++, .NET, Java utilities
G. Test & Validation
- cppunit/gtest-based unit tests under cppcache/test/ and clicache/test/
- integration tests under cppcache/integration-test/ and clicache/integration-test/
- acceptance & performance benchmarks under acceptance-test/ and benchmark/

##### Relationships & interactions
- Build and CI components feed into packaging and publish artifacts

##### Architectural patterns & design principles
- Layered architecture: clear separation between public API, protocol core, and transport
- Adapter/Facade pattern: clicache wraps and adapts the native C++ core to .NET
- Modularity: each concern (serialization, networking, transaction, query) packaged into its own sub-directory and CMake target

##### Essential elements without over-splitting
- Small modules into logical blocks (e.g., “Networking”, “Serialization”, “PDX subsystem”)
- Language-binding modules side-by-side to reflect parity
- CI & Docker as “infrastructure” on the perimeter

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Layer"
        ExamplesCPP["C++ Examples & Tests"]:::example
        ExamplesDotNet[".NET Examples & Tests"]:::example
    end

    subgraph "Language Bindings / API Layer"
        cppcache["cppcache (C++ API Layer)"]:::frontend
        clicache["clicache (.NET CLI Wrapper)"]:::frontend
    end

    subgraph "Core Protocol & Transport"
        ProtocolCore["Protocol Core & Transport"]:::backend
    end

    subgraph "Serialization & PDX Subsystem"
        Serialization["Serialization & PDX"]:::backend
    end

    subgraph "Network"
        Network["TCP/SSL Sockets"]:::backend
    end

    subgraph "Geode Cluster"
        GeodeCluster["Geode Cluster\n(Locator, Servers)"]:::external
    end

    subgraph "Infrastructure"
        CI["CI Pipelines (ci/, docker/)"]:::infra
        Build["Build & Packaging (CMake)"]:::infra
        Docs["Documentation & Examples (docs/)"]:::infra
    end

    ExamplesCPP -->|"uses API"| cppcache
    ExamplesDotNet -->|"uses API"| clicache
    cppcache -->|"invokes wire protocol"| ProtocolCore
    clicache -->|"adapts calls"| ProtocolCore
    ProtocolCore -->|"encodes/decodes messages"| Serialization
    Serialization -->|"provides payloads"| ProtocolCore
    ProtocolCore -->|"sends/receives TCP/SSL"| Network
    Network -->|"TCP/SSL messages"| GeodeCluster

    CI -->|triggers| Build
    Build -->|builds modules| cppcache
    Build -->|builds modules| clicache
    Build -->|builds modules| ProtocolCore

    Docs -->|host API refs| ExamplesCPP
    Docs -->|host API refs| ExamplesDotNet
    Docs -->|host API refs| cppcache
    Docs -->|host API refs| clicache

    click ExamplesCPP "https://github.com/apache/geode-native/tree/develop/examples/cpp"
    click ExamplesDotNet "https://github.com/apache/geode-native/tree/develop/examples/dotnet"
    click cppcache "https://github.com/apache/geode-native/tree/develop/cppcache/src/"
    click cppcache "https://github.com/apache/geode-native/tree/develop/cppcache/include/geode/"
    click cppcache "https://github.com/apache/geode-native/blob/develop/cppcache/CMakeLists.txt"
    click clicache "https://github.com/apache/geode-native/tree/develop/clicache/src/"
    click clicache "https://github.com/apache/geode-native/tree/develop/clicache/src/impl/"
    click clicache "https://github.com/apache/geode-native/blob/develop/clicache/CMakeLists.txt"
    click ProtocolCore "https://github.com/apache/geode-native/tree/develop/cppcache/src/"
    click Serialization "https://github.com/apache/geode-native/tree/develop/cppcache/src/"
    click Network "https://github.com/apache/geode-native/tree/develop/cppcache/src/"
    click CI "https://github.com/apache/geode-native/tree/develop/ci/"
    click Build "https://github.com/apache/geode-native/blob/develop/CMakeLists.txt"
    click Docs "https://github.com/apache/geode-native/tree/develop/docs/"

    classDef example fill:#e7f3ff,stroke:#1f78b4;
    classDef frontend fill:#e0ffe0,stroke:#33a02c;
    classDef backend fill:#fff0b3,stroke:#ff7f00;
    classDef external fill:#f0f0f0,stroke:#636363,stroke-dasharray:2 2;
    classDef infra fill:#fce4ec,stroke:#d81b60;
```
