# swordx-khalid/prisma-query-parser architecture

> Architecture diagram of the GitHub repository swordx-khalid/prisma-query-parser, 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/swordx-khalid/prisma-query-parser
- Repository: https://github.com/swordx-khalid/prisma-query-parser

## Overview

Key Components to Include:

##### Core System Components
- Query Engines Layer
- Regex-based Engine
- Interpreter Engine (mixed regex/loops)
- Indexing Layer
- Binary Indexer (for comparison operations)
- Hash Indexer (for exact matches)
- Parser Layer
- Query Interpreter
- Regex Parser
- Database Layer
- Data Storage
- CSV Import Handler

##### Data Flow Architecture

**Input Layer (REPL/Direct Import)**
- ↓
**Parser Layer (Query Processing)**
- ↓
**Query Engine Layer (Execution)**
- ↓
**Indexing Layer (Optimization)**
- ↓
**Database Layer (Storage)**

##### Component Relationships

- Parser Layer ↔ Query Engines (showing query translation flow)
- Query Engines ↔ Indexing Layer (showing optimization path)
- Indexing Layer ↔ Database Layer (showing data access patterns)

##### Implementation Details

A separate section showing:
- Supported Operators: <, <=, >, >=, =
- Data Types: Current + Planned
- Query Flow Examples

##### Technical Notes

Callouts for:
- Memory Management (dataset reference optimization)
- Indexing Strategies
- Query Engine Selection Logic

##### The extensibility points for future improvements

Key Architectural Patterns to Highlight:

##### Factory Pattern: Illustrate query engine selection

Remember to:

- Keep components loosely coupled
- Clear boundaries between layers
- Extension points for future features

For future scalability, indicate potential integration points for:
- Additional indexing engines
- New data types
- Compound filters
- Query caching
- AST implementation

This will give viewers a clear understanding of both the current system and its planned evolution path.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        REPL["REPL Interface"]:::input
        CSV["CSV Import Handler"]:::input
    end

    subgraph Parser
        QI["Query Interpreter"]:::parser
        RP["Regex Parser"]:::parser
        PI["Parser Interface"]:::parser
    end

    subgraph "Query Engines"
        RE["Regex Engine"]:::engine
        IE["Interpreter Engine"]:::engine
    end

    subgraph "Indexing Layer"
        BI["Binary Indexer O(log n)"]:::indexer
        HI["Hash Indexer O(1)"]:::indexer
        II["Indexing Interface"]:::indexer
    end

    subgraph "Database Layer"
        DS["Data Storage"]:::database
        CIH["CSV Import Handler"]:::database
    end

    %% Relationships
    REPL --> PI
    CSV --> CIH
    PI --> QI & RP
    QI --> RE & IE
    RP --> RE
    RE & IE --> II
    II --> BI & HI
    BI & HI --> DS
    CIH --> DS

    %% Click Events
    click REPL "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/repl.ts"
    click RE "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/parser/regex.ts"
    click IE "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/parser/interpreter.ts"
    click PI "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/parser/index.ts"
    click BI "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/indexes/binary.ts"
    click HI "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/indexes/hash.ts"
    click II "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/indexes/index.ts"
    click DS "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/src/database/index.ts"
    click CSV "https://github.com/SwordX-Khalid/prisma-query-parser/blob/main/tests/_samples/fake_users_sample.csv"

    %% Styles
    classDef input fill:#3498db,stroke:#2980b9,color:white
    classDef parser fill:#2ecc71,stroke:#27ae60,color:white
    classDef engine fill:#2ecc71,stroke:#27ae60,color:white
    classDef indexer fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Processing Components"]:::parser
        L3["Optimization Components"]:::indexer
        L4["Storage Components"]:::database
    end
```
