# ajlrza/kojindb architecture

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

- Interactive diagram: https://gitdiagram.com/ajlrza/kojindb
- Repository: https://github.com/ajlrza/kojindb

## Overview

RailDB is a proof-of-concept hybrid graph/relational database. Its visible CLI accepts login or registration input and writes account-named files through the storage layer; the README describes the broader intended flow as account authentication, token-based query sessions, and query execution. The implementation also contains table/schema, memory, graph-routing, planning, and transaction modules, but several are skeletal or unsampled. Edges below are limited to relationships shown in excerpts or documented in the README; unsampled subsystems are included without guessed wiring.

Main entry points: [`src/storage_manager/storage.cpp`](https://github.com/ajlrza/kojindb/blob/main/src/storage_manager/storage.cpp) (Storage Manager), [`src/query_planner/query_planner.cpp`](https://github.com/ajlrza/kojindb/blob/main/src/query_planner/query_planner.cpp) (Query Planner), [`src/engine/cli_engine.cpp`](https://github.com/ajlrza/kojindb/blob/main/src/engine/cli_engine.cpp) (CLI Engine), [`src/engine/account_management.cpp`](https://github.com/ajlrza/kojindb/blob/main/src/engine/account_management.cpp) (Account Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_cli["CLI Engine<br/>[cli_engine.cpp]"]
  node_accounts["Account Management"]
end

subgraph group_query["Query Processing"]
  node_sessions["Query Sessions"]
  node_lexer["Query Lexer"]
  node_executor["Query Executor"]
  node_planner["Query Planner<br/>[query_planner.cpp]"]
  node_graphrouter["Graph Router"]
end

subgraph group_data["Data Management"]
  node_storage["Storage Manager<br/>[storage.cpp]"]
  node_filesystem[("Filesystem")]
  node_tables["Table Management"]
  node_types["Data Types"]
  node_graphmodel[("Property Graph<br/>[hexastore_router.h]")]
  node_btree[("B-Tree Mirrors<br/>[storage.h]")]
end

subgraph group_runtime["Runtime Infrastructure"]
  node_memory["Memory Management"]
  node_transactions["Transaction Manager"]
end

node_user(("Database User"))

node_user -->|"enters input"| node_cli
node_cli -->|"creates and writes"| node_storage
node_storage -->|"reads and writes"| node_filesystem
node_executor -->|"tokenizes query"| node_lexer
node_user -.->|"registers or logs in"| node_accounts
node_accounts -.->|"authenticates sessions"| node_sessions
node_sessions -.->|"executes queries"| node_executor
node_planner -.->|"plans graph queries"| node_graphrouter
node_planner -.->|"plans relational queries"| node_btree
node_graphrouter -.->|"routes graph traversal"| node_graphmodel
node_storage -->|"uses table definitions"| node_tables
node_storage -->|"imports data types"| node_types

click node_cli "https://github.com/ajlrza/kojindb/blob/main/src/engine/cli_engine.cpp"
click node_accounts "https://github.com/ajlrza/kojindb/blob/main/src/engine/account_management.cpp"
click node_sessions "https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp"
click node_lexer "https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp"
click node_executor "https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp"
click node_planner "https://github.com/ajlrza/kojindb/blob/main/src/query_planner/query_planner.cpp"
click node_graphrouter "https://github.com/ajlrza/kojindb/blob/main/src/query_planner/hexastore_router.cpp"
click node_storage "https://github.com/ajlrza/kojindb/blob/main/src/storage_manager/storage.cpp"
click node_tables "https://github.com/ajlrza/kojindb/blob/main/src/table_management/table_management.cpp"
click node_types "https://github.com/ajlrza/kojindb/blob/main/src/include/data_type_template.h"
click node_graphmodel "https://github.com/ajlrza/kojindb/blob/main/src/include/hexastore_router.h"
click node_btree "https://github.com/ajlrza/kojindb/blob/main/src/include/storage.h"
click node_memory "https://github.com/ajlrza/kojindb/blob/main/src/memory_manager/memory_management.cpp"
click node_transactions "https://github.com/ajlrza/kojindb/blob/main/src/transaction_manager/transaction_manager.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_cli,node_accounts toneBlue
class node_sessions,node_lexer,node_executor,node_planner,node_graphrouter,node_user toneAmber
class node_storage,node_filesystem,node_tables,node_types,node_graphmodel,node_btree toneMint
class node_memory,node_transactions toneRose
```

## Components

### User Interface

- [CLI Engine](https://github.com/ajlrza/kojindb/blob/main/src/engine/cli_engine.cpp): `src/engine/cli_engine.cpp`
- [Account Management](https://github.com/ajlrza/kojindb/blob/main/src/engine/account_management.cpp): `src/engine/account_management.cpp`

### Query Processing

- [Query Sessions](https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp): `src/query_processor/query_processor.cpp`
- [Query Lexer](https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp): `src/query_processor/query_processor.cpp`
- [Query Executor](https://github.com/ajlrza/kojindb/blob/main/src/query_processor/query_processor.cpp): `src/query_processor/query_processor.cpp`
- [Query Planner](https://github.com/ajlrza/kojindb/blob/main/src/query_planner/query_planner.cpp): `src/query_planner/query_planner.cpp`
- [Graph Router](https://github.com/ajlrza/kojindb/blob/main/src/query_planner/hexastore_router.cpp): `src/query_planner/hexastore_router.cpp`

### Data Management

- [Storage Manager](https://github.com/ajlrza/kojindb/blob/main/src/storage_manager/storage.cpp): `src/storage_manager/storage.cpp`
- **Filesystem**
- [Table Management](https://github.com/ajlrza/kojindb/blob/main/src/table_management/table_management.cpp): `src/table_management/table_management.cpp`
- [Data Types](https://github.com/ajlrza/kojindb/blob/main/src/include/data_type_template.h): `src/include/data_type_template.h`
- [Property Graph](https://github.com/ajlrza/kojindb/blob/main/src/include/hexastore_router.h): `src/include/hexastore_router.h`
- [B-Tree Mirrors](https://github.com/ajlrza/kojindb/blob/main/src/include/storage.h): `src/include/storage.h`

### Runtime Infrastructure

- [Memory Management](https://github.com/ajlrza/kojindb/blob/main/src/memory_manager/memory_management.cpp): `src/memory_manager/memory_management.cpp`
- [Transaction Manager](https://github.com/ajlrza/kojindb/blob/main/src/transaction_manager/transaction_manager.cpp): `src/transaction_manager/transaction_manager.cpp`

### Other components

- **Database User**

## Connections

- Database User → CLI Engine: enters input (evidence: `src/engine/cli_engine.cpp`)
- CLI Engine → Storage Manager: creates and writes (evidence: `src/engine/cli_engine.cpp`)
- Storage Manager → Filesystem: reads and writes (evidence: `src/storage_manager/storage.cpp`)
- Query Executor → Query Lexer: tokenizes query (evidence: `src/query_processor/query_processor.cpp`)
- Database User → Account Management: registers or logs in (evidence: `README.md`)
- Account Management → Query Sessions: authenticates sessions (evidence: `README.md`)
- Query Sessions → Query Executor: executes queries (evidence: `README.md`)
- Query Planner → Graph Router: plans graph queries
- Query Planner → B-Tree Mirrors: plans relational queries (evidence: `README.md`)
- Graph Router → Property Graph: routes graph traversal (evidence: `README.md`)
- Storage Manager → Table Management: uses table definitions (evidence: `src/storage_manager/storage.cpp`)
- Storage Manager → Data Types: imports data types (evidence: `src/storage_manager/storage.cpp`)
