# vovinsa/vovinquity architecture

> Architecture diagram of the GitHub repository vovinsa/vovinquity, 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/vovinsa/vovinquity
- Repository: https://github.com/vovinsa/vovinquity

## Overview

##### Main Components

The system should be represented as a layered architecture with the following main components from top to bottom:

a. Query Interface Layer
- Interactive SQL Console (entry point)

b. Query Processing Layer
- Parser (/src/parser)
- Planner (/src/planner)
- Executor (/src/executor)

c. Storage Layer
- Table Management (/src/storage/table)
- Index Management (/src/storage/index)
- Catalog Management (/src/catalog)

##### Component Relationships and Data Flow

**SQL Query Input**
- ↓
**Parser (SQL Parsing)**
- ↓
**Planner (Query Planning)**
- ↓
**Executor (Query Execution)**
- ↓
**Storage Layer (Data Access)**

##### Specific Component Details

For each major component, include these important elements:

Parser Component:
- Input: SQL string
- Output: Parse tree
- Files: parser.h/cpp

Planner Component:
- Input: Parse tree
- Output: Query plan nodes (nodes.h)
- Supported operations: CREATE TABLE, INSERT, SELECT, ORDER BY, GROUP BY, WHERE, Aggregates
- Files: planner.h/cpp

Executor Component:
- Input: Query plan
- Output: Query results
- Files: executor.h/cpp, executor_nodes.h

Storage Layer:
- B+ Tree Index implementation (bplus_tree.h/cpp)
- Table management (table.h/cpp)
- System tables (system_table.h/cpp)
- Schema definitions (schema.h)
- Tuple handling (tuple.h)

##### Important Architectural Patterns to Highlight

- Layered architecture pattern
- Pipeline pattern for query processing
- B+ Tree for indexing
- Separation of concerns between different layers

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef interface fill:#f9f,stroke:#333,stroke-width:2px
    classDef parser fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef planner fill:#99ccff,stroke:#333,stroke-width:2px
    classDef executor fill:#80b3ff,stroke:#333,stroke-width:2px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:2px
    classDef index fill:#98FB98,stroke:#333,stroke-width:2px
    classDef catalog fill:#FFD700,stroke:#333,stroke-width:2px

    %% Query Interface Layer
    Console["SQL Console"]:::interface
    click Console "https://github.com/Vovinsa/vovinquity/blob/main/main.cpp"

    %% Query Processing Layer
    subgraph QueryProcessing["Query Processing Layer"]
        Parser["Parser Component"]:::parser
        click Parser "https://github.com/Vovinsa/vovinquity/blob/main/src/parser/parser.h"
        
        Planner["Query Planner"]:::planner
        click Planner "https://github.com/Vovinsa/vovinquity/blob/main/src/planner/planner.h"
        
        PlanNodes["Plan Nodes"]:::planner
        click PlanNodes "https://github.com/Vovinsa/vovinquity/blob/main/src/planner/nodes.h"
        
        Executor["Query Executor"]:::executor
        click Executor "https://github.com/Vovinsa/vovinquity/blob/main/src/executor/executor.h"
        
        ExecNodes["Executor Nodes"]:::executor
        click ExecNodes "https://github.com/Vovinsa/vovinquity/blob/main/src/executor/executor_nodes.h"
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        TableMgmt["Table Management"]:::storage
        click TableMgmt "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/table/table.h"
        
        Schema["Schema Management"]:::storage
        click Schema "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/table/schema.h"
        
        Tuple["Tuple Handler"]:::storage
        click Tuple "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/table/tuple.h"
        
        IndexMgmt["Index Management"]:::index
        click IndexMgmt "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/index/bplus_index.h"
        
        BPlusTree["B+ Tree Implementation"]:::index
        click BPlusTree "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/index/bplus_tree.h"
        
        SysTables["System Tables"]:::storage
        click SysTables "https://github.com/Vovinsa/vovinquity/blob/main/src/storage/table/system/system_table.h"
    end

    %% Catalog Component
    Catalog["Catalog Manager"]:::catalog
    click Catalog "https://github.com/Vovinsa/vovinquity/blob/main/src/catalog/catalog.h"

    %% Relationships
    Console --> Parser
    Parser --> Planner
    Planner --> PlanNodes
    PlanNodes --> Executor
    Executor --> ExecNodes
    ExecNodes --> TableMgmt
    ExecNodes --> IndexMgmt
    
    TableMgmt --> Schema
    TableMgmt --> Tuple
    TableMgmt --> SysTables
    
    IndexMgmt --> BPlusTree
    
    Catalog -.-> TableMgmt
    Catalog -.-> IndexMgmt
    Catalog -.-> SysTables

    %% Legend
    subgraph Legend
        L1["Interface Layer"]:::interface
        L2["Query Processing"]:::parser
        L3["Storage Components"]:::storage
        L4["Index Components"]:::index
        L5["Catalog Components"]:::catalog
    end
```
