# aerospike/aerospike-server architecture

> Architecture diagram of the GitHub repository aerospike/aerospike-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aerospike/aerospike-server
- Repository: https://github.com/aerospike/aerospike-server

## Overview

##### Main Components

a. Core Server Components:
- Base System (/as/src/base)
- Fabric Layer (/as/src/fabric)
- Storage Engine (/as/src/storage)
- Transaction Processing (/as/src/transaction)
- Query Engine (/as/src/query)
- Secondary Index (/as/src/sindex)
- Geospatial Processing (/as/src/geospatial)

b. Supporting Infrastructure:
- Common Foundation (cf/) - Contains core utilities
- External Dependencies (modules/)
- Configuration Management
- Security Layer

**┌─────────────────────────────────────────────┐**
- Client Interface               │
- ┤
- Query & Transaction Layer         │
- ┤
- Distribution Layer             │
- (Clustering, Fabric, Partition Balance)    │
- ┤
- Storage Engine                 │
- (Memory, SSD, Index Management)         │
- ┤
- Common Foundation (CF)            │
- ┘

##### Specific Elements to Highlight

a. Distribution Mechanism:
- Clustering system
- Fabric communication
- Partition management
- Migration handling

b. Storage Options:
- Memory-based storage
- SSD storage
- Index management
- Flat storage

c. Transaction Processing:
- Read/Write paths
- Delete operations
- UDF execution
- Duplicate resolution

##### Additional Details

Callouts for:
- Security features
- Configuration management
- Monitoring and health checks
- Backup and recovery paths

##### Integration Points

Connections to:
- External modules (Lua, S2 Geometry, etc.)
- Client libraries
- Management interfaces

##### Performance Critical Paths

- Main read path
- Main write path
- Query execution flow
- Index update flow

##### Scaling Aspects

Annotations for:
- Cluster expansion points
- Data distribution mechanisms
- Load balancing components
- Replication paths

This design should reflect Aerospike's key objectives of high performance, reliability (ACID properties), and operational efficiency, while showing how the various components work together to achieve these goals.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef storage fill:#4CAF50,stroke:#388E3B,color:white
    classDef distribution fill:#FFC107,stroke:#FFA000,color:black
    classDef query fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef infrastructure fill:#757575,stroke:#616161,color:white

    %% Client Interface Layer
    subgraph ClientInterface
        CI["Client Interface"]
    end

    %% Query & Transaction Layer
    subgraph QueryTransactionLayer
        QE["Query Engine"]:::query
        TP["Transaction Processing"]:::query
        SI["Secondary Index"]:::query
        GP["Geospatial Processing"]:::query
    end

    %% Distribution Layer
    subgraph DistributionLayer
        FL["Fabric Layer"]:::distribution
        CL["Clustering"]:::distribution
        PM["Partition Management"]:::distribution
    end

    %% Storage Layer
    subgraph StorageLayer
        SE["Storage Engine"]:::storage
        MD["Memory Driver"]:::storage
        SD["SSD Driver"]:::storage
    end

    %% Common Foundation Layer
    subgraph CommonFoundation
        CF["Common Foundation"]:::infrastructure
        SEC["Security Layer"]:::infrastructure
        CM["Configuration Management"]:::infrastructure
    end

    %% External Dependencies
    subgraph ExternalDeps
        LUA["Lua Integration"]:::infrastructure
        S2["S2 Geometry"]:::infrastructure
        JEM["JEMalloc"]:::infrastructure
    end

    %% Relationships
    CI --> QE
    CI --> TP
    QE --> SI
    QE --> GP
    TP --> SE
    SI --> SE
    FL --> CL
    FL --> PM
    SE --> MD
    SE --> SD
    CF --> SEC
    CF --> CM

    %% Click events for component mapping
    click QE "https://github.com/aerospike/aerospike-server/blob/master/as/src/query/query.c"
    click TP "https://github.com/aerospike/aerospike-server/tree/master/as/src/transaction"
    click SI "https://github.com/aerospike/aerospike-server/tree/master/as/src/sindex"
    click GP "https://github.com/aerospike/aerospike-server/tree/master/as/src/geospatial"
    click FL "https://github.com/aerospike/aerospike-server/tree/master/as/src/fabric"
    click CL "https://github.com/aerospike/aerospike-server/blob/master/as/src/fabric/clustering.c"
    click PM "https://github.com/aerospike/aerospike-server/blob/master/as/src/fabric/partition.c"
    click SE "https://github.com/aerospike/aerospike-server/tree/master/as/src/storage"
    click MD "https://github.com/aerospike/aerospike-server/blob/master/as/src/storage/drv_mem.c"
    click SD "https://github.com/aerospike/aerospike-server/blob/master/as/src/storage/drv_ssd.c"
    click CF "https://github.com/aerospike/aerospike-server/tree/master/cf"
    click SEC "https://github.com/aerospike/aerospike-server/blob/master/as/src/base/security_ce.c"
    click CM "https://github.com/aerospike/aerospike-server/tree/master/as/etc"
    click LUA "https://github.com/aerospike/aerospike-server/tree/master/modules/lua"
    click S2 "https://github.com/aerospike/aerospike-server/tree/master/modules/s2geometry"
    click JEM "https://github.com/aerospike/aerospike-server/tree/master/modules/jemalloc"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Storage Components"]:::storage
        L3["Distribution Components"]:::distribution
        L4["Query Components"]:::query
        L5["Infrastructure"]:::infrastructure
    end
```
