# nullism/bqb architecture

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

## Overview

##### Main Components

a) Core Components:
- Query Builder Core (central component)
- Parameter Processing System
- SQL Dialect Handlers (MySQL/PostgreSQL/SQLite)
- Type System

b) Integration Points:
- database/sql Interface
- External DB Drivers (pq, pgx, sqlx)

##### Component Relationships

**┌─────────────────────────────────────────────────────────────┐**
- BQB Query Builder                       │
- ┤

- ┌─────────────┐        ┌──────────────┐                   │
- Query Builder│◄─────►│Parameter      │                   │
- Core         │        │Processor      │                   │
- ┘        └──────────────┘                   │
- ▲                      ▲                           │

- ▼                      ▼                           │
- ┌─────────────┐        ┌──────────────┐                   │
- Type System  │◄─────►│SQL Dialect    │                   │
- Handler      │        │Handlers       │                   │
- ┘        └──────────────┘                   │
- ▲                      ▲                           │

- ┼──────────────────────┼───────────────────────────┘

- ┌─────┴──────┐        ┌─────┴──────┐
- database/sql│        │External DB  │
- Interface   │        │Drivers      │
- ┘        └────────────┘

##### Important Details

a) Core Features:
- Query building methods (Space, And, Or, Comma)
- Parameter substitution (?/$ handling)
- Type conversion system
- JSON support

b) Integration Points:
- Database driver compatibility
- SQL dialect support
- Value embedding system

##### Data Flow Indicators

Following flows:
- Query building process
- Parameter processing
- Type conversion
- SQL dialect transformation

##### The clear separation between query building and parameter processing

Keep the abstraction level focused on the core architectural components while showing enough detail to understand the query building and processing flow. This will help developers understand how to integrate and extend the library effectively.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph BQB["Basic Query Builder (BQB)"]
        direction TB
        QB["Query Builder Core"]
        PP["Parameter Processor"]
        TS["Type System Handler"]
        SDL["SQL Dialect Handlers"]
        
        QB <--> PP
        QB <--> TS
        QB <--> SDL
        PP <--> TS
        PP <--> SDL
        TS <--> SDL
    end
    
    subgraph EXT["External Integration"]
        direction TB
        DBI["database/sql Interface"]
        DBD["External DB Drivers<br/>(pq, pgx, sqlx)"]
        
        DBI <--> DBD
    end
    
    BQB <--> EXT
    
    %% Component click events
    click QB "https://github.com/nullism/bqb/blob/main/query.go"
    click TS "https://github.com/nullism/bqb/blob/main/types.go"
    click SDL "https://github.com/nullism/bqb/blob/main/utils.go"
    click PP "https://github.com/nullism/bqb/blob/main/utils.go"
    
    %% Styling
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef integration fill:#57a773,stroke:#57a773,color:#fff
    classDef external fill:#7d7d7d,stroke:#7d7d7d,color:#fff
    
    class QB,PP,TS,SDL core
    class DBI,DBD external
    
    %% Legend
    subgraph Legend
        C1["Core Components"]:::core
        I1["External Integration"]:::external
    end
```
