# tekumara/fakesnow architecture

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

- Interactive diagram: https://gitdiagram.com/tekumara/fakesnow
- Repository: https://github.com/tekumara/fakesnow

## Overview

##### Main Components

a) Core Components:
- Connection Handler (conn.py)
- Cursor Implementation (cursor.py)
- SQL Parser & Executor (transforms.py, transforms_merge.py)
- Type System (types.py)
- Information Schema Handler (info_schema.py)
- Pandas Integration (pandas_tools.py)

b) Supporting Components:
- CLI Interface (cli.py)
- Server Implementation (server.py)
- Expression Handling (expr.py)
- Mocking System (fakes.py)
- Testing Infrastructure (fixtures.py)

**┌─ Application Layer ─────────────────┐**
- CLI Interface │ Testing Fixtures    │
- ┴────────────────────┘
**┌─ Interface Layer ──────────────────┐**
- Connection Handler                 │
- Patching System                    │
- ┘
**┌─ Core Processing Layer ───────────┐**
- SQL Parser │ Expression Handler   │
- Executor   │ Type System         │
- ┘
**┌─ Storage Layer ──────────────────┐**
- In-Memory DB │ Persistent Store  │
- ┘
**┌─ Integration Layer ───────────────┐**
- ┘

##### Key Relationships

- How the patching system intercepts Snowflake connector calls
- Flow from connection → cursor → SQL processing
- Demonstrate how the mock system interfaces with different storage options
- Testing infrastructure's relationship to the core system

##### Implementation Details

- SQL transformation pipeline
- Connection pooling and management
- Mock database structure
- Information schema implementation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef integration fill:#90EE90,stroke:#333,stroke-width:2px
    classDef testing fill:#FFB366,stroke:#333,stroke-width:2px
    classDef storage fill:#E6E6E6,stroke:#333,stroke-width:2px
    classDef interface fill:#FFE5CC,stroke:#333,stroke-width:2px

    subgraph Application
        CLI["CLI Interface"]:::interface
        Testing["Testing Infrastructure"]:::testing
    end

    subgraph Interface
        ConnHandler["Connection Handler"]:::core
        PatchSystem["Patching System"]:::core
        SysChecks["System Checks"]:::core
    end

    subgraph CoreProcessing
        SQLParser["SQL Parser"]:::core
        Executor["SQL Executor"]:::core
        ExprHandler["Expression Handler"]:::core
        TypeSystem["Type System"]:::core
        VarHandler["Variable Handler"]:::core
    end

    subgraph Storage
        InMemDB["In-Memory DB"]:::storage
        PersistStore["Persistent Store"]:::storage
        InstMgmt["Instance Management"]:::core
    end

    subgraph Integration
        ArrowInt["Arrow Integration"]:::integration
        PandasInt["Pandas Integration"]:::integration
        InfoSchema["Information Schema"]:::integration
    end

    %% Relationships
    CLI --> ConnHandler
    Testing --> PatchSystem
    ConnHandler --> SQLParser
    ConnHandler --> Executor
    PatchSystem --> ConnHandler
    SQLParser --> Executor
    Executor --> ExprHandler
    Executor --> TypeSystem
    Executor --> VarHandler
    ExprHandler --> TypeSystem
    Executor --> InMemDB
    Executor --> PersistStore
    InstMgmt --> InMemDB
    InstMgmt --> PersistStore
    Executor --> ArrowInt
    Executor --> PandasInt
    Executor --> InfoSchema
    SysChecks --> ConnHandler

    %% Click Events
    click CLI "https://github.com/tekumara/fakesnow/blob/main/fakesnow/cli.py"
    click Testing "https://github.com/tekumara/fakesnow/tree/main/tests/"
    click ConnHandler "https://github.com/tekumara/fakesnow/blob/main/fakesnow/conn.py"
    click SQLParser "https://github.com/tekumara/fakesnow/blob/main/fakesnow/transforms.py"
    click ExprHandler "https://github.com/tekumara/fakesnow/blob/main/fakesnow/expr.py"
    click TypeSystem "https://github.com/tekumara/fakesnow/blob/main/fakesnow/types.py"
    click VarHandler "https://github.com/tekumara/fakesnow/blob/main/fakesnow/variables.py"
    click InstMgmt "https://github.com/tekumara/fakesnow/blob/main/fakesnow/instance.py"
    click ArrowInt "https://github.com/tekumara/fakesnow/blob/main/fakesnow/arrow.py"
    click PandasInt "https://github.com/tekumara/fakesnow/blob/main/fakesnow/pandas_tools.py"
    click InfoSchema "https://github.com/tekumara/fakesnow/blob/main/fakesnow/info_schema.py"
    click SysChecks "https://github.com/tekumara/fakesnow/blob/main/fakesnow/checks.py"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Integration Point"]:::integration
        L3["Testing Component"]:::testing
        L4["Storage Component"]:::storage
        L5["Interface Component"]:::interface
    end
```
