# duckdb/duckdb-node-neo architecture

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

## Overview

##### Middle Layer Detail (DuckDB Node Integration)
Split this into two parallel components:

Left Side - API Layer (@duckdb/node-api):
- Connection Management (DuckDBConnection)
- Query Execution (DuckDBResult, DuckDBPendingResult)
- Data Types (DuckDBLogicalType, DuckDBValue)
- Data Manipulation (DuckDBAppender, DuckDBDataChunk)
- Type Conversions (conversion/)

Right Side - Native Bindings (@duckdb/node-bindings):
- Darwin (ARM64/x64)
- Linux (ARM64/x64)
- Windows (x64)
- To a central binding interface

##### Connection Flows
- Blue: Data flow
- Green: API calls
- Orange: Native binding calls

##### Specific Elements

**┌─────────────────────────────────────┐**
- Node.js Application           │
- ┬─────────────────┬─┘
- ↓                 ↓
**┌─────────────────────┐    ┌──────────────────┐**
- @duckdb/node-api   │←───│Native Bindings   │
- ┌───────────────┐  │    │  ┌────────────┐ │
- Connection Mgmt│  │    │  │Platform    │ │
- Query Execution│  │    │  │Specific    │ │
- Data Types     │  │    │  │Modules     │ │
- Type Conversion│  │    │  │            │ │
- ┘  │    │  └────────────┘ │
- ┘    └──────────────────┘
- ↓                        ↓
**┌─────────────────────────────────────────┐**
- DuckDB C API                 │
- ┘

##### Additional Details

a) Component Descriptions:
- Labels for key classes and their relationships
- Version information
- Public API endpoints

b) Cross-cutting Concerns:
- Error handling flows
- Type conversion paths
- Platform-specific considerations

##### Technical Specifications
- DuckDB version compatibility
- Node.js version requirements
- Platform support matrix
- Key dependencies

##### Implementation Notes
- Rectangles: Major modules
- Rounded rectangles: APIs
- Hexagons: Native bindings

##### Testing & Benchmarking
- A sidebar showing:
- Test coverage
- Benchmark metrics
- Performance critical paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Application
        App[Node.js Application]
    end

    subgraph Integration
        subgraph API
            ConnMgmt[Connection Management]
            QueryExec[Query Execution]
            DataTypes[Data Types]
            DataManip[Data Manipulation]
            TypeConv[Type Conversions]
            Values[Data Value Types]
        end

        subgraph Bindings
            NativeCore[Native Bindings Core]
            
            subgraph PlatformBindings
                DarwinARM[Darwin ARM64]
                DarwinX64[Darwin x64]
                LinuxARM[Linux ARM64]
                LinuxX64[Linux x64]
                WinX64[Windows x64]
            end
        end
    end

    subgraph Core
        CAPI[DuckDB C API]
    end

    %% Connections
    App --> ConnMgmt
    App --> QueryExec
    
    ConnMgmt --> NativeCore
    QueryExec --> NativeCore
    DataTypes --> NativeCore
    DataManip --> NativeCore
    TypeConv --> NativeCore
    Values --> NativeCore

    NativeCore --> DarwinARM & DarwinX64 & LinuxARM & LinuxX64 & WinX64
    DarwinARM & DarwinX64 & LinuxARM & LinuxX64 & WinX64 --> CAPI

    %% Click events
    click ConnMgmt "https://github.com/duckdb/duckdb-node-neo/blob/main/api/src/DuckDBConnection.ts"
    click QueryExec "https://github.com/duckdb/duckdb-node-neo/blob/main/api/src/DuckDBResult.ts"
    click DataTypes "https://github.com/duckdb/duckdb-node-neo/blob/main/api/src/DuckDBLogicalType.ts"
    click DataManip "https://github.com/duckdb/duckdb-node-neo/blob/main/api/src/DuckDBAppender.ts"
    click TypeConv "https://github.com/duckdb/duckdb-node-neo/tree/main/api/src/conversion/"
    click Values "https://github.com/duckdb/duckdb-node-neo/tree/main/api/src/values/"
    click NativeCore "https://github.com/duckdb/duckdb-node-neo/blob/main/bindings/src/duckdb_node_bindings.cpp"
    click DarwinARM "https://github.com/duckdb/duckdb-node-neo/tree/main/bindings/pkgs/@duckdb/node-bindings-darwin-arm64"
    click DarwinX64 "https://github.com/duckdb/duckdb-node-neo/tree/main/bindings/pkgs/@duckdb/node-bindings-darwin-x64"
    click LinuxARM "https://github.com/duckdb/duckdb-node-neo/tree/main/bindings/pkgs/@duckdb/node-bindings-linux-arm64"
    click LinuxX64 "https://github.com/duckdb/duckdb-node-neo/tree/main/bindings/pkgs/@duckdb/node-bindings-linux-x64"
    click WinX64 "https://github.com/duckdb/duckdb-node-neo/tree/main/bindings/pkgs/@duckdb/node-bindings-win32-x64"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef api fill:#d4e6f1,stroke:#2874a6
    classDef binding fill:#d5f5e3,stroke:#196f3d
    classDef core fill:#fadbd8,stroke:#943126
    
    class ConnMgmt,QueryExec,DataTypes,DataManip,TypeConv,Values api
    class NativeCore,DarwinARM,DarwinX64,LinuxARM,LinuxX64,WinX64 binding
    class CAPI core
```
