# couchbase/platform architecture

> Architecture diagram of the GitHub repository couchbase/platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/couchbase/platform
- Repository: https://github.com/couchbase/platform

## Overview

This repository is Couchbase’s cross-platform C++ utility library: it provides reusable building blocks rather than a standalone user-facing application. Callers use its facilities for cryptography and encrypted files, logging, cgroup inspection, histograms, memory allocation, JSON validation, compression, sockets, and general platform services. The tree and sampled sources show these as largely independent library capabilities, not a single execution pipeline. There is no README, and unsampled modules are represented only where their paths and roles are supported by the tree or SOURCE INDEX.

Main entry points: [`cbcrypto/file_writer.cc`](https://github.com/couchbase/platform/blob/master/cbcrypto/file_writer.cc) (Encrypted file writer), [`cgroup/cgroup.cc`](https://github.com/couchbase/platform/blob/master/cgroup/cgroup.cc) (Cgroup interface), [`cbcrypto/file_reader.cc`](https://github.com/couchbase/platform/blob/master/cbcrypto/file_reader.cc) (Encrypted file reader), [`cgroup/cgroup_private.cc`](https://github.com/couchbase/platform/blob/master/cgroup/cgroup_private.cc) (Cgroup discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_crypto_logging["Crypto and logging"]
  node_crypto_api["Crypto primitives<br/>[symmetric.cc]"]
  node_file_reader["Encrypted file reader<br/>[file_reader.cc]"]
  node_file_writer["Encrypted file writer<br/>[file_writer.cc]"]
  node_associated_data["File associated data"]
  node_digest["Digest functions<br/>[digest.cc]"]
  node_logger_sink["Rotating file sink"]
  node_logger_runtime["Logger runtime<br/>[spdlogger.cc]"]
end

subgraph group_system["System services"]
  node_cgroup_api["Cgroup interface<br/>[cgroup.cc]"]
  node_cgroup_private["Cgroup discovery<br/>[cgroup_private.cc]"]
  node_socket["Socket utilities<br/>[socket.cc]"]
  node_process_monitor["Process monitoring<br/>[process_monitor.cc]"]
end

subgraph group_data["Data utilities"]
  node_string_hex["Hex strings<br/>[string_hex.cc]"]
  node_sized_buffer["Sized buffers<br/>[sized_buffer.cc]"]
  node_histogram["HDR histogram<br/>[hdrhistogram.cc]"]
  node_histogram_iteration["Histogram iteration<br/>[iterator_range.h]"]
  node_json_api["JSON checker API<br/>[JSON_checker.h]"]
  node_json_validation["JSON validation<br/>[JSON_checker.cc]"]
  node_compression["Compression<br/>[compress.cc]"]
end

subgraph group_memory["Memory and concurrency"]
  node_arena_allocator["Arena allocator<br/>[je_arena_malloc.cc]"]
  node_relaxed_atomic["Relaxed atomics<br/>[relaxed_atomic.h]"]
  node_cgroup_client["Arena client config"]
end

node_callers(("Library callers"))

node_callers -->|"uses"| node_crypto_api
node_callers -->|"uses"| node_file_reader
node_callers -->|"uses"| node_file_writer
node_callers -->|"uses"| node_logger_runtime
node_callers -->|"uses"| node_cgroup_api
node_callers -->|"uses"| node_socket
node_callers -->|"uses"| node_process_monitor
node_callers -->|"uses"| node_histogram
node_callers -->|"uses"| node_json_validation
node_callers -->|"uses"| node_compression
node_file_reader -->|"references"| node_associated_data
node_file_writer -->|"references"| node_associated_data
node_logger_sink -->|"writes through"| node_file_writer
node_digest -->|"uses"| node_string_hex
node_string_hex -->|"uses"| node_sized_buffer
node_cgroup_api -->|"uses"| node_cgroup_private
node_cgroup_private -->|"implements"| node_cgroup_api
node_histogram -->|"uses"| node_histogram_iteration
node_json_validation -->|"implements"| node_json_api
node_arena_allocator -->|"uses"| node_relaxed_atomic
node_cgroup_client -->|"uses"| node_relaxed_atomic

click node_crypto_api "https://github.com/couchbase/platform/blob/master/cbcrypto/symmetric.cc"
click node_file_reader "https://github.com/couchbase/platform/blob/master/cbcrypto/file_reader.cc"
click node_file_writer "https://github.com/couchbase/platform/blob/master/cbcrypto/file_writer.cc"
click node_associated_data "https://github.com/couchbase/platform/blob/master/cbcrypto/encrypted_file_associated_data.h"
click node_digest "https://github.com/couchbase/platform/blob/master/cbcrypto/digest.cc"
click node_string_hex "https://github.com/couchbase/platform/blob/master/src/string_hex.cc"
click node_sized_buffer "https://github.com/couchbase/platform/blob/master/src/sized_buffer.cc"
click node_logger_sink "https://github.com/couchbase/platform/blob/master/cblogger/custom_rotating_file_sink.cc"
click node_logger_runtime "https://github.com/couchbase/platform/blob/master/cblogger/spdlogger.cc"
click node_cgroup_api "https://github.com/couchbase/platform/blob/master/cgroup/cgroup.cc"
click node_cgroup_private "https://github.com/couchbase/platform/blob/master/cgroup/cgroup_private.cc"
click node_socket "https://github.com/couchbase/platform/blob/master/cbsocket/socket.cc"
click node_process_monitor "https://github.com/couchbase/platform/blob/master/src/process_monitor.cc"
click node_histogram "https://github.com/couchbase/platform/blob/master/hdrhistogram/hdrhistogram.cc"
click node_histogram_iteration "https://github.com/couchbase/platform/blob/master/include/hdrhistogram/iterator_range.h"
click node_json_api "https://github.com/couchbase/platform/blob/master/include/JSON_checker.h"
click node_json_validation "https://github.com/couchbase/platform/blob/master/src/JSON_checker.cc"
click node_compression "https://github.com/couchbase/platform/blob/master/cbcompress/compress.cc"
click node_arena_allocator "https://github.com/couchbase/platform/blob/master/src/je_arena_malloc.cc"
click node_relaxed_atomic "https://github.com/couchbase/platform/blob/master/include/relaxed_atomic.h"
click node_cgroup_client "https://github.com/couchbase/platform/blob/master/include/platform/cb_arena_malloc_client.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_crypto_api,node_file_reader,node_file_writer,node_associated_data,node_digest,node_logger_sink,node_logger_runtime toneBlue
class node_cgroup_api,node_cgroup_private,node_socket,node_process_monitor toneAmber
class node_string_hex,node_sized_buffer,node_histogram,node_histogram_iteration,node_json_api,node_json_validation,node_compression toneMint
class node_arena_allocator,node_relaxed_atomic,node_cgroup_client toneRose
class node_callers toneIndigo
```

## Components

### Crypto and logging

- [Crypto primitives](https://github.com/couchbase/platform/blob/master/cbcrypto/symmetric.cc): `cbcrypto/symmetric.cc`
- [Encrypted file reader](https://github.com/couchbase/platform/blob/master/cbcrypto/file_reader.cc): `cbcrypto/file_reader.cc`
- [Encrypted file writer](https://github.com/couchbase/platform/blob/master/cbcrypto/file_writer.cc): `cbcrypto/file_writer.cc`
- [File associated data](https://github.com/couchbase/platform/blob/master/cbcrypto/encrypted_file_associated_data.h): `cbcrypto/encrypted_file_associated_data.h`
- [Digest functions](https://github.com/couchbase/platform/blob/master/cbcrypto/digest.cc): `cbcrypto/digest.cc`
- [Rotating file sink](https://github.com/couchbase/platform/blob/master/cblogger/custom_rotating_file_sink.cc): `cblogger/custom_rotating_file_sink.cc`
- [Logger runtime](https://github.com/couchbase/platform/blob/master/cblogger/spdlogger.cc): `cblogger/spdlogger.cc`

### System services

- [Cgroup interface](https://github.com/couchbase/platform/blob/master/cgroup/cgroup.cc): `cgroup/cgroup.cc`
- [Cgroup discovery](https://github.com/couchbase/platform/blob/master/cgroup/cgroup_private.cc): `cgroup/cgroup_private.cc`
- [Socket utilities](https://github.com/couchbase/platform/blob/master/cbsocket/socket.cc): `cbsocket/socket.cc`
- [Process monitoring](https://github.com/couchbase/platform/blob/master/src/process_monitor.cc): `src/process_monitor.cc`

### Data utilities

- [Hex strings](https://github.com/couchbase/platform/blob/master/src/string_hex.cc): `src/string_hex.cc`
- [Sized buffers](https://github.com/couchbase/platform/blob/master/src/sized_buffer.cc): `src/sized_buffer.cc`
- [HDR histogram](https://github.com/couchbase/platform/blob/master/hdrhistogram/hdrhistogram.cc): `hdrhistogram/hdrhistogram.cc`
- [Histogram iteration](https://github.com/couchbase/platform/blob/master/include/hdrhistogram/iterator_range.h): `include/hdrhistogram/iterator_range.h`
- [JSON checker API](https://github.com/couchbase/platform/blob/master/include/JSON_checker.h): `include/JSON_checker.h`
- [JSON validation](https://github.com/couchbase/platform/blob/master/src/JSON_checker.cc): `src/JSON_checker.cc`
- [Compression](https://github.com/couchbase/platform/blob/master/cbcompress/compress.cc): `cbcompress/compress.cc`

### Memory and concurrency

- [Arena allocator](https://github.com/couchbase/platform/blob/master/src/je_arena_malloc.cc): `src/je_arena_malloc.cc`
- [Relaxed atomics](https://github.com/couchbase/platform/blob/master/include/relaxed_atomic.h): `include/relaxed_atomic.h`
- [Arena client config](https://github.com/couchbase/platform/blob/master/include/platform/cb_arena_malloc_client.h): `include/platform/cb_arena_malloc_client.h`

### Other components

- **Library callers**

## Connections

- Library callers → Crypto primitives: uses
- Library callers → Encrypted file reader: uses
- Library callers → Encrypted file writer: uses
- Library callers → Logger runtime: uses
- Library callers → Cgroup interface: uses
- Library callers → Socket utilities: uses
- Library callers → Process monitoring: uses
- Library callers → HDR histogram: uses
- Library callers → JSON validation: uses
- Library callers → Compression: uses
- Encrypted file reader → File associated data: references (evidence: `cbcrypto/file_reader.cc`)
- Encrypted file writer → File associated data: references (evidence: `cbcrypto/file_writer.cc`)
- Rotating file sink → Encrypted file writer: writes through (evidence: `cblogger/custom_rotating_file_sink.cc`)
- Digest functions → Hex strings: uses (evidence: `cbcrypto/digest.cc`)
- Hex strings → Sized buffers: uses
- Cgroup interface → Cgroup discovery: uses (evidence: `cgroup/cgroup.cc`)
- Cgroup discovery → Cgroup interface: implements (evidence: `cgroup/cgroup_private.cc`)
- HDR histogram → Histogram iteration: uses
- JSON validation → JSON checker API: implements (evidence: `src/JSON_checker.cc`)
- Arena allocator → Relaxed atomics: uses (evidence: `src/je_arena_malloc.cc`)
- Arena client config → Relaxed atomics: uses (evidence: `include/platform/cb_arena_malloc_client.h`)
