# strikestrike/datadocs architecture

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

- Interactive diagram: https://gitdiagram.com/strikestrike/datadocs
- Repository: https://github.com/strikestrike/datadocs

## Overview

##### Project type and purpose
- This is a large monorepo hosting a front‑end only web application called “Datadocs,” plus supporting libraries.
- Datadocs is a Svelte/TypeScript SPA for loading, viewing, and manipulating large columnar data sets from multiple sources.
- There is no production backend here—only a `mock-api-server` for local development.

##### File structure
- Top‐level “packages” folder contains all sub‑projects:
- `datadocs`: the main Svelte web app
- `canvas-datagrid-ng`: the reusable grid component library
- `datasource-duckdb`, `duckdb-utils`, `duckdb-wasm`: DuckDB‑related data layers
- `local-storage`: IndexedDB/OPFS persistence adapters
- `mock-api-server`: local mock HTTP API
- Other utility sub‑modules and templates (e.g., windi‑plugins, submodule‑template).
- CI/CD manifests in `.github/workflows` and deploy scripts in `/deploy`.
- Build configurations: Yarn (monorepo via Lerna), Vite (front‑end), Rollup (library bundling), TypeScript, ESLint, Husky, etc.

##### README
- Confirms monorepo structure with UI only, mock API server, no real backend.
- Points to grid‑component docs, panels layout, and usage of various “data sources” (CSV, Firestore, DuckDB).

a. Main components
- Browser Client (Datadocs SPA)
- Grid Component Library (`canvas‑datagrid‑ng`)
- Data‑Source Layer
- DuckDB WASM (`duckdb-wasm` + `datasource-duckdb`)
- Firestore connector (via `datadocs/src/api/firestore`)
- Local storage (IndexedDB/OPFS)
- CSV/XML parsers
- Mock API Server (`mock-api-server`)
- CI/CD & Deploy Pipeline (GitHub Actions + deploy scripts)
- External Services (e.g., Firestore, real backend under NDA)
b. Relationships & interactions
- The SPA imports and renders grid components from `canvas‑datagrid‑ng`.
- Grid component issues data‑fetch requests via a generic data‑source interface.
- At runtime, data source implementations are chosen (DuckDB WASM in‑browser, Firestore via HTTP, local persistence).
- The SPA also calls the mock‑API server for metadata, authentication flows, and file listings.
- Local‑storage package provides offline persistence; integrated with DuckDB or as fallback.
- CI pipeline runs build & tests on each package; deploy script pushes static assets to hosting.
c. Architectural patterns & principles
- Monorepo with clearly separated packages (library vs. application).
- Component‑based UI (Svelte) + unidirectional data flow (stores, actions).
- Plug‑in data‑source abstraction (Strategy Pattern): grid core is agnostic to underlying data.
- Library bundling via Rollup; application bundling via Vite.
- Mock server for development (Test Double pattern).
d. Key technologies & frameworks
- UI: Svelte, TypeScript, Yarn, Vite
- Grid Library: canvas and Web‑Component (custom elements), Rollup
- Data Layer: DuckDB‑WASM, IndexedDB/OPFS, Firestore REST API, CSV parsers
- CI/CD: GitHub Actions, Husky, Lerna
- Styling: WindiCSS, Tailwind, CSS modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Monorepo"
        subgraph "UI Layer" 
            A["Datadocs SPA"]:::ui
        end
        subgraph "Presentation Component"
            B["Grid Component Library"]:::presentation
        end
        subgraph "Data-Source Layer"
            C1["DuckDB-WASM (DuckDB.ts)"]:::datasource
            C2["datasource-duckdb"]:::datasource
            C3["duckdb-utils"]:::datasource
            C4["Firestore Connector"]:::datasource
            C5["Local Storage (IndexedDB/OPFS)"]:::datasource
            C6["CSV/XML Parsers"]:::datasource
        end
        subgraph "Dev Tools & Mock Server"
            D1["Mock API Server"]:::dev
            D2["CI/CD Workflows"]:::dev
            D3["Deploy Scripts"]:::dev
            D4["Monorepo Management"]:::dev
        end
    end

    User(("User")):::external
    CloudFirestore(("Cloud Firestore")):::external

    User -->|interacts with| A
    A -->|imports & renders| B
    B -->|uses strategy| C2
    A -->|initializes WASM| C1
    A -->|uses utils| C3
    A -->|fetches via HTTP| C4
    A -->|persists via API| C5
    B -->|parses CSV/XML| C6
    C4 -->|REST API| CloudFirestore
    A <-->|metadata/auth| D1

    D2 -->|"build & test"| A
    D2 -->|"bundle libraries"| B
    D2 -->|"validate data sources"| C2
    D3 -->|"deploy static assets"| A
    D4 -->|manages workspaces| D2

    classDef ui fill:#cfe2ff,stroke:#0284c7,stroke-width:2px
    classDef presentation fill:#d1fae5,stroke:#047857,stroke-width:2px
    classDef datasource fill:#fde68a,stroke:#b45309,stroke-width:2px
    classDef dev fill:#e5e7eb,stroke:#374151,stroke-width:2px
    classDef external fill:#f0f9ff,stroke:#1e3a8a,stroke-width:2px,stroke-dasharray: 5 5

    click A "https://github.com/strikestrike/datadocs/tree/main/packages/datadocs"
    click B "https://github.com/strikestrike/datadocs/tree/main/packages/canvas-datagrid-ng"
    click C1 "https://github.com/strikestrike/datadocs/blob/main/packages/datadocs/src/lib/DuckDB.ts"
    click C2 "https://github.com/strikestrike/datadocs/tree/main/packages/datasource-duckdb"
    click C3 "https://github.com/strikestrike/datadocs/tree/main/packages/duckdb-utils"
    click C4 "https://github.com/strikestrike/datadocs/tree/main/packages/datadocs/src/api/firestore"
    click C5 "https://github.com/strikestrike/datadocs/tree/main/packages/local-storage"
    click C6 "https://github.com/strikestrike/datadocs/tree/main/packages/canvas-datagrid-ng/lib/data/csv"
    click D1 "https://github.com/strikestrike/datadocs/tree/main/packages/mock-api-server"
    click D2 "https://github.com/strikestrike/datadocs/tree/main/.github/workflows"
    click D3 "https://github.com/strikestrike/datadocs/tree/main/deploy"
    click D4 "https://github.com/strikestrike/datadocs/blob/main/lerna.json"
```
