# sahilb315/atomixdb architecture

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

- Interactive diagram: https://gitdiagram.com/sahilb315/atomixdb
- Repository: https://github.com/sahilb315/atomixdb

## Overview

- Main Execution/Entry Point: Represent “main.go” as the starting point where the service is launched.
- Command Interface: Indicate the component that accepts and processes supported commands (CREATE, INSERT, GET, UPDATE, DELETE, BEGIN, COMMIT, ABORT) from a user or application.
- Database Core Engine: Represent the central part of the system that ties together several modules.
- Data Persistence Layer: Include modules related to file persistence (persist.go, mmap_{mac, unix, windows}.go) – highlighting how AtomixDB abstracts persistence for different operating systems.
- Free List Manager: Show the component that manages reusable nodes (free_list.go) to optimize storage and reduce fragmentation.
- Transaction Manager: Represent the transaction-handling module which ensures atomic operations and data consistency (transactions.go). This module should also show how concurrent reads are supported.
- Testing and Validation: Though not a runtime component, note that tests (such as commands_test.go) help enforce correctness.

##### Establish Relationships and Interactions
- The Core Engine routes data queries and updates through the B+ Tree Storage Engine.

##### Architectural Patterns and Design Principles
- That the system uses modular design principles where specialized components (like the free list module and OS-specific persistence with mmap) can be updated or replaced independently.
- Concurrency – for instance, note concurrent read operations within the Transaction Manager and Storage Engine.

##### Technologies and External Dependencies
- Mention that the entire system is implemented in Go.
- Optionally, add notes on platform-specific code paths (mmap on Unix/MacOS vs. Windows).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Main Execution"]:::main
    B["Command Interface"]:::command
    C["Database Core Engine"]:::core
    subgraph "B+ Tree Storage Engine"
        D1["B+ Tree Engine"]:::storage
        D2["Indexes Module"]:::storage
    end
    subgraph "Data Persistence Layer"
        E1["File Persistence"]:::persist
        E2["mmap (mac)"]:::persist
        E3["mmap (unix)"]:::persist
        E4["mmap (windows)"]:::persist
    end
    F["Free List Manager"]:::free
    G["Transaction Manager"]:::txn
    H["Helper Utilities"]:::helper
    I["Testing and Validation"]:::test

    A -->|"starts"| B
    B -->|"sendsCommands"| C
    C -->|"queriesUpdates"| D1
    D1 -->|"integrates"| D2
    D1 -->|"readWriteOps"| E1
    C -->|"nodeReuse"| F
    B -->|"transactionControl"| G
    G -->|"coordinates"| D1
    H -->|"supports"| C
    I ---|"testsCommands"| B
    I ---|"testsCore"| C

    click A "https://github.com/sahilb315/atomixdb/blob/main/main.go"
    click B "https://github.com/sahilb315/atomixdb/blob/main/database/commands.go"
    click C "https://github.com/sahilb315/atomixdb/blob/main/database/database_impl.go"
    click D1 "https://github.com/sahilb315/atomixdb/blob/main/database/b_tree.go"
    click D2 "https://github.com/sahilb315/atomixdb/blob/main/database/indexes.go"
    click E1 "https://github.com/sahilb315/atomixdb/blob/main/database/persist.go"
    click E2 "https://github.com/sahilb315/atomixdb/blob/main/database/mmap_mac.go"
    click E3 "https://github.com/sahilb315/atomixdb/blob/main/database/mmap_unix.go"
    click E4 "https://github.com/sahilb315/atomixdb/blob/main/database/mmap_windows.go"
    click F "https://github.com/sahilb315/atomixdb/blob/main/database/free_list.go"
    click G "https://github.com/sahilb315/atomixdb/blob/main/database/transactions.go"
    click H "https://github.com/sahilb315/atomixdb/blob/main/database/helper/helper.go"
    click I "https://github.com/sahilb315/atomixdb/blob/main/database/commands_test.go"

classDef main fill:#FFCDD2,stroke:#C62828,stroke-width:2px
classDef command fill:#BBDEFB,stroke:#1976D2,stroke-width:2px
classDef core fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
classDef storage fill:#FFE0B2,stroke:#F57C00,stroke-width:2px
classDef persist fill:#E1BEE7,stroke:#7B1FA2,stroke-width:2px
classDef free fill:#B2EBF2,stroke:#0097A7,stroke-width:2px
classDef txn fill:#F0F4C3,stroke:#9E9D24,stroke-width:2px
classDef helper fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px
classDef test fill:#CFD8DC,stroke:#607D8B,stroke-width:2px,stroke-dasharray: 5,5
```
