# vwh/sqlite-viewer architecture

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

## Overview

##### Component Relationships

- User Interface → Store Management (data flow)
- Store Management → WebAssembly Layer (query execution)
- WebAssembly Layer → Store Management (results)
- Hooks → UI Components (data and state management)

##### Key Technical Elements to Highlight

Create distinct sections for:
- File Handling System (src/lib/file.ts)
- SQLite Type Checking (src/lib/sqlite-type-check.ts)
- Theme Management (src/hooks/useTheme.ts)
- Local Storage Integration (src/hooks/useLocalStorageState.ts)

##### Special Features to Emphasize

- Offline Capability
- PWA Support
- URL Database Loading
- Theme Switching
- Client-side Processing

##### Data Flow Visualization

Complete flow:

##### Technical Details

Annotations for:
- WebAssembly Integration
- React Components Structure
- State Management Flow
- File Processing Pipeline

##### Client-Side Architecture
- How all processing happens in the browser
- Security aspect of no server involvement

##### Component Modularity
- Demonstrate the clear separation between UI, business logic, and data processing
- How components are organized by feature

##### State Flow
- How the SQLite store manages application state
- How hooks connect the store to UI components

Remember to:
- Use consistent symbols and notation
- Version information
- Document any external dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        direction TB
        Landing["Landing Components"]
        Database["Database Components"]
        Settings["Settings Components"]

        subgraph LandingComponents["Landing Section"]
            direction TB
            Hero["Hero Section"]
            DropZone["File Drop Zone"]
            URLFetch["URL Database Fetch"]
        end

        subgraph DatabaseComponents["Database Section"]
            direction TB
            QueryInterface["Query Interface"]
            DataDisplay["Data Display"]
            TableOps["Table Operations"]
        end

        subgraph SettingsComponents["Settings Section"]
            direction TB
            SchemaViewer["Schema Viewer"]
            ThemeToggle["Theme Toggle"]
            ExportFuncs["Export Functions"]
        end
    end

    subgraph Core["Application Core"]
        direction TB
        Store["SQLite Store"]
        Hooks["Core Hooks"]
        Utils["Utility Libraries"]

        subgraph HookLayer["Hooks Layer"]
            direction TB
            ThemeHook["Theme Management"]
            StorageHook["Local Storage"]
            QueryHook["Query Data"]
            PaginationHook["Pagination"]
        end

        subgraph UtilsLayer["Utilities"]
            direction TB
            FileHandler["File Handling"]
            TypeChecker["SQLite Type Checking"]
            SQLiteCore["SQLite Core"]
            DateFormat["Date Formatting"]
        end
    end

    subgraph WASM["WebAssembly Layer"]
        direction TB
        SQLiteWASM["SQLite WASM Binary"]
        SQLiteIntegration["SQLite Integration"]
    end

    %% Relationships
    Landing --> Store
    Database --> Store
    Settings --> Store
    Store --> WASM
    WASM --> Store
    Hooks --> Frontend
    Utils --> Store

    %% Styling
    classDef frontend fill:#a5d8ff,stroke:#0077cc
    classDef core fill:#b2f2bb,stroke:#087f5b
    classDef wasm fill:#ffe066,stroke:#f08c00
    classDef utils fill:#e599f7,stroke:#9c36b5

    class Landing,Database,Settings,LandingComponents,DatabaseComponents,SettingsComponents frontend
    class Core,Store,Hooks,HookLayer,Utils,UtilsLayer core
    class WASM,SQLiteWASM,SQLiteIntegration wasm
    class FileHandler,TypeChecker,SQLiteCore,DateFormat utils

    %% Click Events
    click Landing "https://github.com/vwh/sqlite-viewer/tree/main//src/components/landing/"
    click Hero "https://github.com/vwh/sqlite-viewer/blob/main//src/components/landing/hero.tsx"
    click DropZone "https://github.com/vwh/sqlite-viewer/blob/main//src/components/landing/dropzone.tsx"
    click URLFetch "https://github.com/vwh/sqlite-viewer/blob/main//src/components/landing/url-fetch.tsx"
    click Database "https://github.com/vwh/sqlite-viewer/tree/main//src/components/database/"
    click QueryInterface "https://github.com/vwh/sqlite-viewer/blob/main//src/components/database/query-textarea.tsx"
    click DataDisplay "https://github.com/vwh/sqlite-viewer/blob/main//src/components/database/table-data.tsx"
    click TableOps "https://github.com/vwh/sqlite-viewer/blob/main//src/components/database/table-operations.tsx"
    click Settings "https://github.com/vwh/sqlite-viewer/tree/main//src/components/settings/"
    click SchemaViewer "https://github.com/vwh/sqlite-viewer/blob/main//src/components/settings/database-schema-drawer.tsx"
    click ThemeToggle "https://github.com/vwh/sqlite-viewer/blob/main//src/components/settings/theme-mode-toggle.tsx"
    click ExportFuncs "https://github.com/vwh/sqlite-viewer/blob/main//src/components/settings/export-buttons.tsx"
    click Store "https://github.com/vwh/sqlite-viewer/blob/main//src/store/useSQLiteStore.ts"
    click ThemeHook "https://github.com/vwh/sqlite-viewer/blob/main//src/hooks/useTheme.ts"
    click StorageHook "https://github.com/vwh/sqlite-viewer/blob/main//src/hooks/useLocalStorageState.ts"
    click QueryHook "https://github.com/vwh/sqlite-viewer/blob/main//src/hooks/useQueryData.ts"
    click PaginationHook "https://github.com/vwh/sqlite-viewer/blob/main//src/hooks/usePagination.ts"
    click FileHandler "https://github.com/vwh/sqlite-viewer/blob/main//src/lib/file.ts"
    click TypeChecker "https://github.com/vwh/sqlite-viewer/blob/main//src/lib/sqlite-type-check.ts"
    click SQLiteCore "https://github.com/vwh/sqlite-viewer/blob/main//src/lib/sqlite.ts"
    click DateFormat "https://github.com/vwh/sqlite-viewer/blob/main//src/lib/date-format.ts"
    click SQLiteWASM "https://github.com/vwh/sqlite-viewer/blob/main//public/sql.wasm"
    click SQLiteIntegration "https://github.com/vwh/sqlite-viewer/blob/main//src/lib/sqlite.ts"
```
