# ganeshkukkala7615/lightweightbms-engine architecture

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

- Interactive diagram: https://gitdiagram.com/ganeshkukkala7615/lightweightbms-engine
- Repository: https://github.com/ganeshkukkala7615/lightweightbms-engine

## Overview

Lightweight-DBMS-Engine is a menu-driven relational database that stores table data on disk and indexes primary keys with a per-table B+ tree. Its documented workflow covers table creation, insertion, display and search, table listing, and dropping; display supports selected columns and a WHERE clause. The tree also contains a separate Hyrise SQL-parser library, but the sampled entry point does not connect it to the database workflow. Parser relationships reflect source-index references and excerpts; unsampled implementation details are not inferred.

Main entry points: [`src/main.cpp`](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/main.cpp) (Database menu), [`src/file_handler.cpp`](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/file_handler.cpp) (File handling), [`src/insert.cpp`](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/insert.cpp) (Insert records), [`sql-parser/src/parser/bison_parser.cpp`](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/parser/bison_parser.cpp) (SQL grammar)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Database interface"]
  node_cli["Database menu<br/>[main.cpp]"]
end

subgraph group_operations["Table operations"]
  node_query["Query input<br/>[parser.cpp]"]
  node_create["Create tables<br/>[create.cpp]"]
  node_insert["Insert records<br/>[insert.cpp]"]
  node_display["Display rows<br/>[display.cpp]"]
  node_search["Search records<br/>[search.cpp]"]
  node_where["WHERE filtering<br/>[where.cpp]"]
  node_drop["Drop tables<br/>[drop.h]"]
end

subgraph group_storage["Storage and indexing"]
  node_meta["Table metadata<br/>[declaration.h]"]
  node_files["File handling<br/>[file_handler.cpp]"]
  node_blocks[("Table data files<br/>[file_handler.cpp]")]
  node_btree[("B+ tree index<br/>[BPtree.cpp]")]
  node_aes["Record storage<br/>[aes.cpp]"]
end

subgraph group_sqlparser["SQL parser library"]
  node_sqlapi["Parser API<br/>[SQLParser.cpp]"]
  node_lexer["SQL lexer<br/>[flex_lexer.cpp]"]
  node_grammar["SQL grammar<br/>[bison_parser.cpp]"]
  node_ast["Statement types<br/>[SelectStatement.h]"]
  node_result["Parse result<br/>[SQLParserResult.h]"]
  node_expressions["SQL expressions<br/>[Expr.h]"]
end

node_user(("User"))

node_user -->|"selects operation"| node_cli
node_cli -->|"calls create"| node_create
node_cli -->|"calls insert"| node_insert
node_cli -->|"offers drop"| node_drop
node_cli -->|"routes display"| node_display
node_cli -->|"calls search"| node_search
node_cli -->|"requests query"| node_query
node_query -->|"parses display query"| node_display
node_create -->|"uses file handling"| node_files
node_insert -->|"uses file handling"| node_files
node_insert -->|"updates index"| node_btree
node_insert -->|"stores records"| node_aes
node_display -->|"reads table files"| node_files
node_display -->|"applies filters"| node_where
node_search -->|"reads table files"| node_files
node_search -->|"looks up keys"| node_btree
node_files -.->|"accesses table data"| node_blocks
node_sqlapi -->|"uses lexer"| node_lexer
node_sqlapi -->|"invokes parser"| node_grammar
node_grammar -->|"builds statements"| node_ast
node_grammar -->|"creates results"| node_result
node_grammar -->|"builds expressions"| node_expressions
node_result -->|"holds statements"| node_ast

click node_cli "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/main.cpp"
click node_query "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/parser.cpp"
click node_create "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/create.cpp"
click node_insert "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/insert.cpp"
click node_display "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/display.cpp"
click node_search "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/search.cpp"
click node_where "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/where.cpp"
click node_drop "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/include/drop.h"
click node_meta "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/include/declaration.h"
click node_files "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/file_handler.cpp"
click node_blocks "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/file_handler.cpp"
click node_btree "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/BPtree.cpp"
click node_aes "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/aes.cpp"
click node_sqlapi "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/SQLParser.cpp"
click node_lexer "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/parser/flex_lexer.cpp"
click node_grammar "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/parser/bison_parser.cpp"
click node_ast "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/sql/SelectStatement.h"
click node_result "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/SQLParserResult.h"
click node_expressions "https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/sql/Expr.h"

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_user toneBlue
class node_query,node_create,node_insert,node_display,node_search,node_where,node_drop toneAmber
class node_meta,node_files,node_blocks,node_btree,node_aes toneMint
class node_sqlapi,node_lexer,node_grammar,node_ast,node_result,node_expressions toneRose
```

## Components

### Database interface

- [Database menu](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/main.cpp): `src/main.cpp`

### Table operations

- [Query input](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/parser.cpp): `src/parser.cpp`
- [Create tables](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/create.cpp): `src/create.cpp`
- [Insert records](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/insert.cpp): `src/insert.cpp`
- [Display rows](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/display.cpp): `src/display.cpp`
- [Search records](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/search.cpp): `src/search.cpp`
- [WHERE filtering](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/where.cpp): `src/where.cpp`
- [Drop tables](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/include/drop.h): `include/drop.h`

### Storage and indexing

- [Table metadata](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/include/declaration.h): `include/declaration.h`
- [File handling](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/file_handler.cpp): `src/file_handler.cpp`
- [Table data files](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/file_handler.cpp): `src/file_handler.cpp`
- [B+ tree index](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/BPtree.cpp): `src/BPtree.cpp`
- [Record storage](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/src/aes.cpp): `src/aes.cpp`

### SQL parser library

- [Parser API](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/SQLParser.cpp): `sql-parser/src/SQLParser.cpp`
- [SQL lexer](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/parser/flex_lexer.cpp): `sql-parser/src/parser/flex_lexer.cpp`
- [SQL grammar](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/parser/bison_parser.cpp): `sql-parser/src/parser/bison_parser.cpp`
- [Statement types](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/sql/SelectStatement.h): `sql-parser/src/sql/SelectStatement.h`
- [Parse result](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/SQLParserResult.h): `sql-parser/src/SQLParserResult.h`
- [SQL expressions](https://github.com/ganeshkukkala7615/lightweightbms-engine/blob/main/sql-parser/src/sql/Expr.h): `sql-parser/src/sql/Expr.h`

### Other components

- **User**

## Connections

- User → Database menu: selects operation (evidence: `src/main.cpp`)
- Database menu → Create tables: calls create (evidence: `src/main.cpp`)
- Database menu → Insert records: calls insert (evidence: `src/main.cpp`)
- Database menu → Drop tables: offers drop (evidence: `src/main.cpp`)
- Database menu → Display rows: routes display (evidence: `src/main.cpp`)
- Database menu → Search records: calls search (evidence: `src/main.cpp`)
- Database menu → Query input: requests query (evidence: `src/main.cpp`)
- Query input → Display rows: parses display query (evidence: `src/parser.cpp`)
- Create tables → File handling: uses file handling (evidence: `src/create.cpp`)
- Insert records → File handling: uses file handling (evidence: `src/insert.cpp`)
- Insert records → B+ tree index: updates index (evidence: `src/insert.cpp`)
- Insert records → Record storage: stores records (evidence: `src/insert.cpp`)
- Display rows → File handling: reads table files (evidence: `src/display.cpp`)
- Display rows → WHERE filtering: applies filters (evidence: `src/display.cpp`)
- Search records → File handling: reads table files (evidence: `src/search.cpp`)
- Search records → B+ tree index: looks up keys (evidence: `src/search.cpp`)
- File handling → Table data files: accesses table data (evidence: `src/file_handler.cpp`)
- Parser API → SQL lexer: uses lexer (evidence: `sql-parser/src/SQLParser.cpp`)
- Parser API → SQL grammar: invokes parser (evidence: `sql-parser/src/SQLParser.cpp`)
- SQL grammar → Statement types: builds statements (evidence: `sql-parser/src/parser/bison_parser.cpp`)
- SQL grammar → Parse result: creates results (evidence: `sql-parser/src/parser/bison_parser.cpp`)
- SQL grammar → SQL expressions: builds expressions (evidence: `sql-parser/src/parser/bison_parser.cpp`)
- Parse result → Statement types: holds statements (evidence: `sql-parser/src/SQLParserResult.h`)
