# ankitkr-04/strata-db architecture

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

- Interactive diagram: https://gitdiagram.com/ankitkr-04/strata-db
- Repository: https://github.com/ankitkr-04/strata-db

## Overview

StrataDB is an embedded C++ key-value engine whose implemented path centers on configuration and concurrency-safe memory foundations, a concurrent SkipList memtable, and write-ahead logging. The WAL accepts batches, stages blocks through a hardware-selected queue pipeline, and persists them in rotating segments; its reader and validators support crash recovery. Configuration, allocation, platform probing, and POSIX I/O are supporting layers. The README also describes memtable flush integration and BlockPool, but sampled excerpts do not expose all caller relationships. Planned SSTables, compaction, and interfaces are omitted as unimplemented.

Main entry points: [`src/wal/manager.cpp`](https://github.com/ankitkr-04/strata-db/blob/main/src/wal/manager.cpp) (WAL manager), [`include/stratadb/wal/pipeline_variant.hpp`](https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline_variant.hpp) (Hardware pipeline variants), [`src/wal/reader/reader.cpp`](https://github.com/ankitkr-04/strata-db/blob/main/src/wal/reader/reader.cpp) (WAL recovery reader), [`include/stratadb/wal/pipeline.hpp`](https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline.hpp) (WAL staging pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Configuration"]
  node_config_mgr["Config manager<br/>[config_manager.cpp]"]
  node_config_resolver["Config resolver"]
end

subgraph group_memory["Memory and concurrency"]
  node_epoch["Epoch manager<br/>[epoch_manager.cpp]"]
  node_arena["Arena allocator<br/>[arena.cpp]"]
  node_virtual_region["Virtual region<br/>[virtual_region.cpp]"]
  node_tlab["Thread-local buffers<br/>[tlab.cpp]"]
  node_block_pool["Block pool<br/>[block_pool.cpp]"]
end

subgraph group_memtable["Key-value staging"]
  node_skiplist["SkipList memtable"]
  node_skipnode["SkipList node layout<br/>[skiplist_node.cpp]"]
end

subgraph group_wal["Durability and recovery"]
  node_wal_manager["WAL manager<br/>[manager.cpp]"]
  node_pipeline["WAL staging pipeline<br/>[pipeline.hpp]"]
  node_pipeline_variants["Hardware pipeline variants"]
  node_wal_blocks["WAL block formats"]
  node_queues["Handoff queues"]
  node_segment_pool[("WAL segment pool<br/>[segment_pool.cpp]")]
  node_wal_reader["WAL recovery reader<br/>[reader.cpp]"]
  node_validator["Block validator<br/>[validator.hpp]"]
end

subgraph group_platform["Platform services"]
  node_io_engine["POSIX I/O engine"]
  node_os_services["OS file services<br/>[os.cpp]"]
  node_hardware_probe["Hardware probe<br/>[hardware_probe.cpp]"]
  node_identity["Database identity<br/>[identity.cpp]"]
end

node_client(("Database caller"))

node_client -.->|"updates and reads"| node_skiplist
node_client -.->|"writes batches"| node_wal_manager
node_config_resolver -.->|"provides configuration"| node_config_mgr
node_config_mgr -->|"pins snapshots"| node_epoch
node_tlab -.->|"refills from"| node_arena
node_arena -.->|"uses regions"| node_virtual_region
node_skiplist -.->|"uses nodes"| node_skipnode
node_wal_manager -->|"selects pipeline"| node_pipeline_variants
node_pipeline_variants -->|"instantiates"| node_pipeline
node_pipeline_variants -->|"selects format"| node_wal_blocks
node_pipeline_variants -->|"selects queue"| node_queues
node_pipeline -->|"acquires blocks"| node_block_pool
node_pipeline -.->|"dispatches blocks"| node_queues
node_wal_manager -->|"constructs pool"| node_segment_pool
node_wal_manager -.->|"writes WAL"| node_io_engine
node_wal_manager -->|"reads mutable config"| node_config_mgr
node_wal_manager -->|"registers flusher"| node_epoch
node_wal_manager -.->|"uses capabilities"| node_hardware_probe
node_wal_manager -.->|"uses database identity"| node_identity
node_wal_reader -->|"scans snapshots"| node_segment_pool
node_wal_reader -.->|"validates blocks"| node_validator
node_wal_reader -->|"reads WAL files"| node_os_services
node_segment_pool -->|"manages segment files"| node_os_services
node_io_engine -.->|"uses POSIX calls"| node_os_services

click node_config_mgr "https://github.com/ankitkr-04/strata-db/blob/main/src/config/config_manager.cpp"
click node_config_resolver "https://github.com/ankitkr-04/strata-db/blob/main/src/config/config_resolver.cpp"
click node_epoch "https://github.com/ankitkr-04/strata-db/blob/main/src/memory/epoch_manager.cpp"
click node_arena "https://github.com/ankitkr-04/strata-db/blob/main/src/memory/arena.cpp"
click node_virtual_region "https://github.com/ankitkr-04/strata-db/blob/main/src/memory/virtual_region.cpp"
click node_tlab "https://github.com/ankitkr-04/strata-db/blob/main/src/memory/tlab.cpp"
click node_block_pool "https://github.com/ankitkr-04/strata-db/blob/main/src/memory/block_pool.cpp"
click node_skiplist "https://github.com/ankitkr-04/strata-db/blob/main/src/memtable/skiplist_memtable.cpp"
click node_skipnode "https://github.com/ankitkr-04/strata-db/blob/main/src/memtable/skiplist_node.cpp"
click node_wal_manager "https://github.com/ankitkr-04/strata-db/blob/main/src/wal/manager.cpp"
click node_pipeline "https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline.hpp"
click node_pipeline_variants "https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline_variant.hpp"
click node_wal_blocks "https://github.com/ankitkr-04/strata-db/tree/main/include/stratadb/wal/block"
click node_queues "https://github.com/ankitkr-04/strata-db/tree/main/include/stratadb/wal/queue"
click node_segment_pool "https://github.com/ankitkr-04/strata-db/blob/main/src/wal/pool/segment_pool.cpp"
click node_wal_reader "https://github.com/ankitkr-04/strata-db/blob/main/src/wal/reader/reader.cpp"
click node_validator "https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/reader/validator.hpp"
click node_io_engine "https://github.com/ankitkr-04/strata-db/blob/main/src/io/posix_io_engine.cpp"
click node_os_services "https://github.com/ankitkr-04/strata-db/blob/main/src/utils/os.cpp"
click node_hardware_probe "https://github.com/ankitkr-04/strata-db/blob/main/src/platform/hardware_probe.cpp"
click node_identity "https://github.com/ankitkr-04/strata-db/blob/main/src/platform/identity.cpp"

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_config_mgr,node_config_resolver toneBlue
class node_epoch,node_arena,node_virtual_region,node_tlab,node_block_pool,node_client toneAmber
class node_skiplist,node_skipnode toneMint
class node_wal_manager,node_pipeline,node_pipeline_variants,node_wal_blocks,node_queues,node_segment_pool,node_wal_reader,node_validator toneRose
class node_io_engine,node_os_services,node_hardware_probe,node_identity toneIndigo
```

## Components

### Configuration

- [Config manager](https://github.com/ankitkr-04/strata-db/blob/main/src/config/config_manager.cpp): `src/config/config_manager.cpp`
- [Config resolver](https://github.com/ankitkr-04/strata-db/blob/main/src/config/config_resolver.cpp): `src/config/config_resolver.cpp`

### Memory and concurrency

- [Epoch manager](https://github.com/ankitkr-04/strata-db/blob/main/src/memory/epoch_manager.cpp): `src/memory/epoch_manager.cpp`
- [Arena allocator](https://github.com/ankitkr-04/strata-db/blob/main/src/memory/arena.cpp): `src/memory/arena.cpp`
- [Virtual region](https://github.com/ankitkr-04/strata-db/blob/main/src/memory/virtual_region.cpp): `src/memory/virtual_region.cpp`
- [Thread-local buffers](https://github.com/ankitkr-04/strata-db/blob/main/src/memory/tlab.cpp): `src/memory/tlab.cpp`
- [Block pool](https://github.com/ankitkr-04/strata-db/blob/main/src/memory/block_pool.cpp): `src/memory/block_pool.cpp`

### Key-value staging

- [SkipList memtable](https://github.com/ankitkr-04/strata-db/blob/main/src/memtable/skiplist_memtable.cpp): `src/memtable/skiplist_memtable.cpp`
- [SkipList node layout](https://github.com/ankitkr-04/strata-db/blob/main/src/memtable/skiplist_node.cpp): `src/memtable/skiplist_node.cpp`

### Durability and recovery

- [WAL manager](https://github.com/ankitkr-04/strata-db/blob/main/src/wal/manager.cpp): `src/wal/manager.cpp`
- [WAL staging pipeline](https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline.hpp): `include/stratadb/wal/pipeline.hpp`
- [Hardware pipeline variants](https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/pipeline_variant.hpp): `include/stratadb/wal/pipeline_variant.hpp`
- [WAL block formats](https://github.com/ankitkr-04/strata-db/tree/main/include/stratadb/wal/block): `include/stratadb/wal/block`
- [Handoff queues](https://github.com/ankitkr-04/strata-db/tree/main/include/stratadb/wal/queue): `include/stratadb/wal/queue`
- [WAL segment pool](https://github.com/ankitkr-04/strata-db/blob/main/src/wal/pool/segment_pool.cpp): `src/wal/pool/segment_pool.cpp`
- [WAL recovery reader](https://github.com/ankitkr-04/strata-db/blob/main/src/wal/reader/reader.cpp): `src/wal/reader/reader.cpp`
- [Block validator](https://github.com/ankitkr-04/strata-db/blob/main/include/stratadb/wal/reader/validator.hpp): `include/stratadb/wal/reader/validator.hpp`

### Platform services

- [POSIX I/O engine](https://github.com/ankitkr-04/strata-db/blob/main/src/io/posix_io_engine.cpp): `src/io/posix_io_engine.cpp`
- [OS file services](https://github.com/ankitkr-04/strata-db/blob/main/src/utils/os.cpp): `src/utils/os.cpp`
- [Hardware probe](https://github.com/ankitkr-04/strata-db/blob/main/src/platform/hardware_probe.cpp): `src/platform/hardware_probe.cpp`
- [Database identity](https://github.com/ankitkr-04/strata-db/blob/main/src/platform/identity.cpp): `src/platform/identity.cpp`

### Other components

- **Database caller**

## Connections

- Database caller → SkipList memtable: updates and reads
- Database caller → WAL manager: writes batches
- Config resolver → Config manager: provides configuration
- Config manager → Epoch manager: pins snapshots
- Thread-local buffers → Arena allocator: refills from
- Arena allocator → Virtual region: uses regions
- SkipList memtable → SkipList node layout: uses nodes
- WAL manager → Hardware pipeline variants: selects pipeline (evidence: `src/wal/manager.cpp`)
- Hardware pipeline variants → WAL staging pipeline: instantiates (evidence: `include/stratadb/wal/pipeline_variant.hpp`)
- Hardware pipeline variants → WAL block formats: selects format (evidence: `include/stratadb/wal/pipeline_variant.hpp`)
- Hardware pipeline variants → Handoff queues: selects queue (evidence: `include/stratadb/wal/pipeline_variant.hpp`)
- WAL staging pipeline → Block pool: acquires blocks (evidence: `include/stratadb/wal/pipeline.hpp`)
- WAL staging pipeline → Handoff queues: dispatches blocks
- WAL manager → WAL segment pool: constructs pool (evidence: `src/wal/manager.cpp`)
- WAL manager → POSIX I/O engine: writes WAL
- WAL manager → Config manager: reads mutable config (evidence: `src/wal/manager.cpp`)
- WAL manager → Epoch manager: registers flusher (evidence: `src/wal/manager.cpp`)
- WAL manager → Hardware probe: uses capabilities
- WAL manager → Database identity: uses database identity
- WAL recovery reader → WAL segment pool: scans snapshots (evidence: `src/wal/reader/reader.cpp`)
- WAL recovery reader → Block validator: validates blocks
- WAL recovery reader → OS file services: reads WAL files (evidence: `src/wal/reader/reader.cpp`)
- WAL segment pool → OS file services: manages segment files (evidence: `src/wal/pool/segment_pool.cpp`)
- POSIX I/O engine → OS file services: uses POSIX calls
