# fillddak/gridclip architecture

> Architecture diagram of the GitHub repository fillddak/gridclip, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fillddak/gridclip
- Repository: https://github.com/fillddak/gridclip

## Overview

gridclip is a dependency-free clipboard-format library for spreadsheet-like web apps and server-side parsing. Its principal workflow reads clipboard text and HTML, reconciles TSV cell values with HTML table merges, and returns a grid; the reverse workflow serializes grid data into TSV and HTML for clipboard use. It also provides grid slicing and spreadsheet-style paste placement. The graph reflects sampled source and README-described capabilities; edges for unsampled implementation details are omitted.

Main entry points: [`src/clipboard.ts`](https://github.com/fillddak/gridclip/blob/main/src/clipboard.ts) (Clipboard orchestration), [`src/index.ts`](https://github.com/fillddak/gridclip/blob/main/src/index.ts) (Public exports), [`src/html/table.ts`](https://github.com/fillddak/gridclip/blob/main/src/html/table.ts) (HTML table parser), [`src/util.ts`](https://github.com/fillddak/gridclip/blob/main/src/util.ts) (Validation utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clipboard["Clipboard workflows"]
  node_clipboard["Clipboard orchestration<br/>[clipboard.ts]"]
  node_api["Public exports<br/>[index.ts]"]
end

subgraph group_formats["Cell formats"]
  node_tsv["TSV codec<br/>[tsv.ts]"]
  node_htmltable["HTML table parser<br/>[table.ts]"]
  node_htmlstring["HTML table writer<br/>[stringify.ts]"]
end

subgraph group_grid["Grid operations"]
  node_gridops["Grid operations<br/>[grid.ts]"]
end

subgraph group_internals["Shared parsing internals"]
  node_tokenizer["HTML tokenizer<br/>[tokenizer.ts]"]
  node_text["HTML text builder<br/>[text.ts]"]
  node_decode["Entity decoder<br/>[decode.ts]"]
  node_entities["Entity definitions<br/>[entities.ts]"]
  node_util["Validation utilities<br/>[util.ts]"]
  node_types["Grid types<br/>[types.ts]"]
end

node_user(("Grid application"))
node_browser["Browser clipboard"]

node_user -->|"reads or writes"| node_clipboard
node_clipboard -->|"uses clipboard APIs"| node_browser
node_clipboard -->|"parses and serializes"| node_tsv
node_clipboard -->|"scans HTML"| node_htmltable
node_clipboard -->|"serializes HTML"| node_htmlstring
node_clipboard -->|"validates inputs"| node_util
node_htmltable -->|"tokenizes markup"| node_tokenizer
node_htmltable -->|"builds cell text"| node_text
node_tokenizer -->|"decodes references"| node_decode
node_decode -->|"looks up entities"| node_entities
node_tsv -->|"validates grids"| node_util
node_htmltable -->|"validates options"| node_util
node_htmlstring -->|"validates grids"| node_util
node_gridops -->|"validates grids"| node_util
node_clipboard -.->|"offers paste placement"| node_gridops
node_api -->|"exports"| node_clipboard
node_api -->|"exports"| node_tsv
node_api -->|"exports"| node_htmltable
node_api -->|"exports"| node_htmlstring
node_api -->|"exports"| node_gridops

click node_clipboard "https://github.com/fillddak/gridclip/blob/main/src/clipboard.ts"
click node_tsv "https://github.com/fillddak/gridclip/blob/main/src/tsv.ts"
click node_htmltable "https://github.com/fillddak/gridclip/blob/main/src/html/table.ts"
click node_htmlstring "https://github.com/fillddak/gridclip/blob/main/src/html/stringify.ts"
click node_gridops "https://github.com/fillddak/gridclip/blob/main/src/grid.ts"
click node_tokenizer "https://github.com/fillddak/gridclip/blob/main/src/html/tokenizer.ts"
click node_text "https://github.com/fillddak/gridclip/blob/main/src/html/text.ts"
click node_decode "https://github.com/fillddak/gridclip/blob/main/src/html/decode.ts"
click node_entities "https://github.com/fillddak/gridclip/blob/main/src/html/entities.ts"
click node_util "https://github.com/fillddak/gridclip/blob/main/src/util.ts"
click node_types "https://github.com/fillddak/gridclip/blob/main/src/types.ts"
click node_api "https://github.com/fillddak/gridclip/blob/main/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_clipboard,node_api,node_browser toneBlue
class node_tsv,node_htmltable,node_htmlstring toneAmber
class node_gridops toneMint
class node_tokenizer,node_text,node_decode,node_entities,node_util,node_types toneRose
class node_user toneIndigo
```

## Components

### Clipboard workflows

- [Clipboard orchestration](https://github.com/fillddak/gridclip/blob/main/src/clipboard.ts): `src/clipboard.ts`
- [Public exports](https://github.com/fillddak/gridclip/blob/main/src/index.ts): `src/index.ts`

### Cell formats

- [TSV codec](https://github.com/fillddak/gridclip/blob/main/src/tsv.ts): `src/tsv.ts`
- [HTML table parser](https://github.com/fillddak/gridclip/blob/main/src/html/table.ts): `src/html/table.ts`
- [HTML table writer](https://github.com/fillddak/gridclip/blob/main/src/html/stringify.ts): `src/html/stringify.ts`

### Grid operations

- [Grid operations](https://github.com/fillddak/gridclip/blob/main/src/grid.ts): `src/grid.ts`

### Shared parsing internals

- [HTML tokenizer](https://github.com/fillddak/gridclip/blob/main/src/html/tokenizer.ts): `src/html/tokenizer.ts`
- [HTML text builder](https://github.com/fillddak/gridclip/blob/main/src/html/text.ts): `src/html/text.ts`
- [Entity decoder](https://github.com/fillddak/gridclip/blob/main/src/html/decode.ts): `src/html/decode.ts`
- [Entity definitions](https://github.com/fillddak/gridclip/blob/main/src/html/entities.ts): `src/html/entities.ts`
- [Validation utilities](https://github.com/fillddak/gridclip/blob/main/src/util.ts): `src/util.ts`
- [Grid types](https://github.com/fillddak/gridclip/blob/main/src/types.ts): `src/types.ts`

### Other components

- **Grid application**
- **Browser clipboard**

## Connections

- Grid application → Clipboard orchestration: reads or writes (evidence: `README.md`)
- Clipboard orchestration → Browser clipboard: uses clipboard APIs (evidence: `src/clipboard.ts`)
- Clipboard orchestration → TSV codec: parses and serializes (evidence: `src/clipboard.ts`)
- Clipboard orchestration → HTML table parser: scans HTML (evidence: `src/clipboard.ts`)
- Clipboard orchestration → HTML table writer: serializes HTML (evidence: `src/clipboard.ts`)
- Clipboard orchestration → Validation utilities: validates inputs (evidence: `src/clipboard.ts`)
- HTML table parser → HTML tokenizer: tokenizes markup (evidence: `src/html/table.ts`)
- HTML table parser → HTML text builder: builds cell text (evidence: `src/html/table.ts`)
- HTML tokenizer → Entity decoder: decodes references (evidence: `src/html/tokenizer.ts`)
- Entity decoder → Entity definitions: looks up entities (evidence: `src/html/decode.ts`)
- TSV codec → Validation utilities: validates grids (evidence: `src/tsv.ts`)
- HTML table parser → Validation utilities: validates options (evidence: `src/html/table.ts`)
- HTML table writer → Validation utilities: validates grids (evidence: `src/html/stringify.ts`)
- Grid operations → Validation utilities: validates grids (evidence: `src/grid.ts`)
- Clipboard orchestration → Grid operations: offers paste placement (evidence: `README.md`)
- Public exports → Clipboard orchestration: exports (evidence: `src/index.ts`)
- Public exports → TSV codec: exports (evidence: `src/index.ts`)
- Public exports → HTML table parser: exports (evidence: `src/index.ts`)
- Public exports → HTML table writer: exports (evidence: `src/index.ts`)
- Public exports → Grid operations: exports (evidence: `src/index.ts`)
