# nuvic/simpledb architecture

> Architecture diagram of the GitHub repository nuvic/simpledb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nuvic/simpledb
- Repository: https://github.com/nuvic/simpledb

## Overview

##### Main Components Identification

- File Management System (src/file/)
- Buffer Management System (src/buffer/)
- Logging System (src/log/)

##### Specific Implementation Details

Annotations showing:
- Page size and buffer pool size configurations
- File block addressing scheme
- Log record format
- Recovery mechanisms

##### Technical Details

Technical notes showing:
- Rust-specific implementation details
- Error handling flow (error.rs)
- Database interface (db.rs)
- Testing architecture (tests/db_tests.rs)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core_Components
        BM["Buffer Manager"]
        FM["File Manager"]
        LM["Log Manager"]
    end

    subgraph Buffer_Management
        BPM["Buffer Pool Management"]
        PM["Page Management"]
        BM --> BPM
        BM --> PM
    end

    subgraph File_Management
        BID["Block ID Management"]
        FO["File Operations"]
        PO["Page Operations"]
        FM --> BID
        FM --> FO
        FM --> PO
    end

    subgraph Log_Management
        LI["Log Iterator"]
        LO["Log Operations"]
        LM --> LI
        LM --> LO
    end

    subgraph Entry_Points
        DB["Database Interface"]
        EH["Error Handling"]
        LE["Library Entry"]
        AE["Application Entry"]
    end

    %% Core relationships
    BM --> FM
    BM <--> LM
    FM <--> LM

    %% Entry point relationships
    DB --> BM
    DB --> FM
    DB --> LM
    EH --> BM
    EH --> FM
    EH --> LM
    LE --> DB
    AE --> DB

    %% Click events for component mapping
    click BM "https://github.com/nuvic/simpledb/tree/main/src/buffer/"
    click FM "https://github.com/nuvic/simpledb/tree/main/src/file/"
    click LM "https://github.com/nuvic/simpledb/tree/main/src/log/"
    click BPM "https://github.com/nuvic/simpledb/blob/main/src/buffer/manager.rs"
    click PM "https://github.com/nuvic/simpledb/blob/main/src/buffer/page.rs"
    click BID "https://github.com/nuvic/simpledb/blob/main/src/file/block_id.rs"
    click FO "https://github.com/nuvic/simpledb/blob/main/src/file/manager.rs"
    click PO "https://github.com/nuvic/simpledb/blob/main/src/file/page.rs"
    click LI "https://github.com/nuvic/simpledb/blob/main/src/log/iterator.rs"
    click LO "https://github.com/nuvic/simpledb/blob/main/src/log/manager.rs"
    click DB "https://github.com/nuvic/simpledb/blob/main/src/db.rs"
    click EH "https://github.com/nuvic/simpledb/blob/main/src/error.rs"
    click LE "https://github.com/nuvic/simpledb/blob/main/src/lib.rs"
    click AE "https://github.com/nuvic/simpledb/blob/main/src/main.rs"

    classDef default fill:#f9f,stroke:#333,stroke-width:2px
    classDef core fill:#blue,stroke:#333,stroke-width:4px
    classDef management fill:#yellow,stroke:#333,stroke-width:2px
    classDef entry fill:#green,stroke:#333,stroke-width:2px

    class BM,FM,LM core
    class BPM,PM,BID,FO,PO,LI,LO management
    class DB,EH,LE,AE entry
```
