# glromeo/sleek-grid architecture

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

- Interactive diagram: https://gitdiagram.com/glromeo/sleek-grid
- Repository: https://github.com/glromeo/sleek-grid

## Overview

1. **Project shape**
   This is a browser-first, dependency-free JavaScript grid library. The core library lives under `lib/` and is packaged as ESM plus an IIFE build for direct browser use. The rest of the repo is supporting material: demos, docs, benchmarks, and browser-based specs.

2. **Primary entry points**
   `lib/index.mjs` and `lib/sleek-grid.mjs` are the main library entry points. `lib/sleek-grid.d.ts` provides the TypeScript surface area. The `iife/` bundle is the distributable format for `<script>`-style consumption.

3. **Core architecture**
   The grid is split into a small set of controllers and renderable components:
   - `row-controller.mjs` manages row state and row lifecycle.
   - `column-controller.mjs` manages column definitions, sizing, and ordering.
   - `components/` contains the DOM-facing pieces: `root`, `grid-area`, `header-row`, and `grid-row`.
   This separation suggests the controllers own state and the components focus on rendering and interaction.

4. **Rendering model**
   The library is explicitly virtualized, so it does not render all rows at once. The `grid-area` and `grid-row` components likely form the scrollable viewport and row renderer, while `header-row` handles column headers. This is the central performance boundary: data can be large, but DOM work stays bounded by visible content.

5. **Feature layer**
   `lib/features/` contains interaction behaviors that sit on top of the core rendering model:
   - `column-dnd.mjs` and `row-dnd.mjs` for drag-and-drop reordering.
   - `column-resize.mjs`, `row-resize.mjs`, and `header-resize.mjs` for resizing.
   - `highlight.mjs` for selection/focus/hover-style feedback.
   These look like modular add-ons rather than baked-in logic, which makes the interaction layer a distinct subsystem.

6. **API and utilities boundary**
   `lib/utils/grid-api.mjs` is likely the imperative/public API boundary used by consumers and internal modules to manipulate grid state. `lib/utils/nano-memoize.mjs` and `lib/utils/index.mjs` support internal performance and helper logic. This is where programmatic access meets the render/controller layer.

7. **Styling and iconography**
   `lib/styles/sleek.mjs` and `lib/styles/static.mjs` separate dynamic grid styling from more static presentation rules. `lib/icons.mjs` indicates the grid ships its own UI affordances rather than depending on external icon sets. The presence of `construct-style-sheets-polyfill.js` in demo/public files suggests the library may use constructable stylesheets when available, with a fallback for older browsers.

8. **Consumer-facing samples**
   `public/` contains runnable examples such as `index.html`, `vanilla.html`, and `react.html`, plus `mock-data.json`. `docs/demo.html` and the `docs/demo/` assets mirror the demo experience for published documentation. This repo is not only the source of the library, but also its integration showcase.

9. **Documentation and publishing**
   `docs/` appears to be GitHub Pages / static docs content, driven by `_config.yml` and `index.md`. `.github/workflows/npm-publish.yml` indicates automated packaging/publishing to npm. So the release flow is: source in `lib/` → bundle outputs in `iife/` and probably npm package artifacts → docs/demo published separately.

10. **Testing architecture**
   `spec/` contains browser-based Jasmine tests (`spec/support/jasmine-browser.json`, `spec/runner.html`) plus a small local test harness in `spec/lib/`. The tests run in the browser, which fits a DOM-heavy library where interaction and layout behavior matter more than pure unit execution.

11. **Benchmarking and performance validation**
   `benchmark/` includes comparison pages such as `ag-grid.html` and scripts like `benchmark.js`. This indicates performance is a first-class concern, and the benchmark layer is used to validate the virtualization and rendering strategy against alternative approaches.

12. **Likely runtime boundary**
   The grid runs in the browser DOM, not on a server. External dependencies are intentionally absent, so all state management, rendering, and interactions are implemented in-repo. The main architectural boundary is between consumer-provided data/configuration and internal DOM virtualization/rendering.

13. **How to draw the diagram**
   A good architecture diagram should center on:
   - Consumer app / demo pages on the outside
   - Public grid API and entry module
   - Controllers for rows and columns
   - Virtualized root/grid-area/grid-row/header-row rendering components
   - Feature modules layered onto the core
   - Styles and icons as supporting assets
   - Separate docs, tests, and benchmark pipelines around the core library

14. **Overall picture**
   In short, this is a modular, high-performance grid engine for the browser: a thin public API feeds state into row/column controllers, which drive a virtualized DOM component tree, with interaction features attached as separate modules and browser demos/tests/benchmarks validating the result.

Main entry points: [`lib/index.mjs`](https://github.com/glromeo/sleek-grid/blob/main/lib/index.mjs) (Entry), [`lib/column-controller.mjs`](https://github.com/glromeo/sleek-grid/blob/main/lib/column-controller.mjs) (Columns), [`lib/components/grid-area.mjs`](https://github.com/glromeo/sleek-grid/blob/main/lib/components/grid-area.mjs) (Grid area), [`lib/row-controller.mjs`](https://github.com/glromeo/sleek-grid/blob/main/lib/row-controller.mjs) (Rows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core library"]
  node_entry["Entry<br/>[index.mjs]"]
  node_bundle["Bundle<br/>[sleek-grid.mjs]"]
  node_types["Types<br/>dts api<br/>[sleek-grid.d.ts]"]
  node_rowctl["Rows<br/>row controller<br/>[row-controller.mjs]"]
  node_colctl["Columns<br/>column controller"]
  node_root["Root<br/>shell component<br/>[root.mjs]"]
  node_area["Grid area<br/>viewport component<br/>[grid-area.mjs]"]
  node_header["Header row<br/>header component<br/>[header-row.mjs]"]
  node_row["Grid row<br/>row component<br/>[grid-row.mjs]"]
  node_colresize["Col resize<br/>feature<br/>[column-resize.mjs]"]
  node_rowresize["Row resize<br/>feature<br/>[row-resize.mjs]"]
  node_headresize["Header resize<br/>feature<br/>[header-resize.mjs]"]
  node_coldnd["Col drag<br/>feature<br/>[column-dnd.mjs]"]
  node_rowdnd["Row drag<br/>feature<br/>[row-dnd.mjs]"]
  node_highlight["Highlight<br/>feature<br/>[highlight.mjs]"]
  node_api["Grid API<br/>public api<br/>[grid-api.mjs]"]
  node_styles["Styles<br/>style modules<br/>[sleek.mjs]"]
  node_icons["Icons<br/>ui assets<br/>[icons.mjs]"]
end

subgraph group_delivery["Delivery"]
  node_iife["IIFE build<br/>browser bundle<br/>[sleek-grid.js]"]
end

subgraph group_experience["Examples"]
  node_docs["Docs site<br/>static docs<br/>[index.md]"]
  node_demo["Demo app<br/>browser demos<br/>[index.html]"]
end

subgraph group_validation["Validation"]
  node_spec["Browser specs<br/>jasmine suite<br/>[runner.html]"]
  node_bench["Benchmarks<br/>perf pages<br/>[index.html]"]
end

node_entry -->|"re-exports"| node_bundle
node_entry -->|"uses"| node_rowctl
node_entry -->|"uses"| node_colctl
node_entry -->|"mounts"| node_root
node_root -->|"contains"| node_area
node_area -->|"positions"| node_header
node_area -->|"renders"| node_row
node_rowctl -->|"drives"| node_row
node_colctl -->|"drives"| node_header
node_colctl -->|"sizes"| node_row
node_header -->|"enables"| node_colresize
node_header -->|"enables"| node_headresize
node_row -->|"enables"| node_rowresize
node_colctl -->|"supports"| node_coldnd
node_rowctl -->|"supports"| node_rowdnd
node_area -->|"overlays"| node_highlight
node_entry -->|"exposes"| node_api
node_api -->|"controls"| node_rowctl
node_api -->|"controls"| node_colctl
node_entry -->|"applies"| node_styles
node_entry -->|"uses"| node_icons
node_iife -->|"packages"| node_entry
node_docs -->|"consumes"| node_iife
node_demo -->|"consumes"| node_entry
node_spec -->|"verifies"| node_entry
node_bench -->|"measures"| node_area

click node_entry "https://github.com/glromeo/sleek-grid/blob/main/lib/index.mjs"
click node_bundle "https://github.com/glromeo/sleek-grid/blob/main/lib/sleek-grid.mjs"
click node_types "https://github.com/glromeo/sleek-grid/blob/main/lib/sleek-grid.d.ts"
click node_rowctl "https://github.com/glromeo/sleek-grid/blob/main/lib/row-controller.mjs"
click node_colctl "https://github.com/glromeo/sleek-grid/blob/main/lib/column-controller.mjs"
click node_root "https://github.com/glromeo/sleek-grid/blob/main/lib/components/root.mjs"
click node_area "https://github.com/glromeo/sleek-grid/blob/main/lib/components/grid-area.mjs"
click node_header "https://github.com/glromeo/sleek-grid/blob/main/lib/components/header-row.mjs"
click node_row "https://github.com/glromeo/sleek-grid/blob/main/lib/components/grid-row.mjs"
click node_colresize "https://github.com/glromeo/sleek-grid/blob/main/lib/features/column-resize.mjs"
click node_rowresize "https://github.com/glromeo/sleek-grid/blob/main/lib/features/row-resize.mjs"
click node_headresize "https://github.com/glromeo/sleek-grid/blob/main/lib/features/header-resize.mjs"
click node_coldnd "https://github.com/glromeo/sleek-grid/blob/main/lib/features/column-dnd.mjs"
click node_rowdnd "https://github.com/glromeo/sleek-grid/blob/main/lib/features/row-dnd.mjs"
click node_highlight "https://github.com/glromeo/sleek-grid/blob/main/lib/features/highlight.mjs"
click node_api "https://github.com/glromeo/sleek-grid/blob/main/lib/utils/grid-api.mjs"
click node_styles "https://github.com/glromeo/sleek-grid/blob/main/lib/styles/sleek.mjs"
click node_icons "https://github.com/glromeo/sleek-grid/blob/main/lib/icons.mjs"
click node_iife "https://github.com/glromeo/sleek-grid/blob/main/iife/sleek-grid.js"
click node_docs "https://github.com/glromeo/sleek-grid/blob/main/docs/index.md"
click node_demo "https://github.com/glromeo/sleek-grid/blob/main/public/index.html"
click node_spec "https://github.com/glromeo/sleek-grid/blob/main/spec/runner.html"
click node_bench "https://github.com/glromeo/sleek-grid/blob/main/benchmark/index.html"

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_entry,node_bundle,node_types,node_rowctl,node_colctl,node_root,node_area,node_header,node_row,node_colresize,node_rowresize,node_headresize,node_coldnd,node_rowdnd,node_highlight,node_api,node_styles,node_icons toneBlue
class node_iife toneAmber
class node_docs,node_demo toneMint
class node_spec,node_bench toneRose
```

## Components

### Core library

Main ESM grid engine, rendering components, features, and styling.

- [Entry](https://github.com/glromeo/sleek-grid/blob/main/lib/index.mjs): esm entry · Primary library entry module. · `lib/index.mjs`
- [Bundle](https://github.com/glromeo/sleek-grid/blob/main/lib/sleek-grid.mjs): esm bundle · Main distributable module surface. · `lib/sleek-grid.mjs`
- [Types](https://github.com/glromeo/sleek-grid/blob/main/lib/sleek-grid.d.ts): dts api · TypeScript declarations for consumers. · `lib/sleek-grid.d.ts`
- [Rows](https://github.com/glromeo/sleek-grid/blob/main/lib/row-controller.mjs): row controller · Owns row state, lifecycle, and virtualization-driven row management. · `lib/row-controller.mjs`
- [Columns](https://github.com/glromeo/sleek-grid/blob/main/lib/column-controller.mjs): column controller · Manages column definitions, sizing, and ordering. · `lib/column-controller.mjs`
- [Root](https://github.com/glromeo/sleek-grid/blob/main/lib/components/root.mjs): shell component · Top-level DOM shell for the grid. · `lib/components/root.mjs`
- [Grid area](https://github.com/glromeo/sleek-grid/blob/main/lib/components/grid-area.mjs): viewport component · Scrollable viewport and virtualization boundary. · `lib/components/grid-area.mjs`
- [Header row](https://github.com/glromeo/sleek-grid/blob/main/lib/components/header-row.mjs): header component · Renders column headers and header interactions. · `lib/components/header-row.mjs`
- [Grid row](https://github.com/glromeo/sleek-grid/blob/main/lib/components/grid-row.mjs): row component · Renderable row view for visible data. · `lib/components/grid-row.mjs`
- [Col resize](https://github.com/glromeo/sleek-grid/blob/main/lib/features/column-resize.mjs): feature · Column drag handles and width changes. · `lib/features/column-resize.mjs`
- [Row resize](https://github.com/glromeo/sleek-grid/blob/main/lib/features/row-resize.mjs): feature · Row resizing interactions. · `lib/features/row-resize.mjs`
- [Header resize](https://github.com/glromeo/sleek-grid/blob/main/lib/features/header-resize.mjs): feature · Header-specific resize behavior. · `lib/features/header-resize.mjs`
- [Col drag](https://github.com/glromeo/sleek-grid/blob/main/lib/features/column-dnd.mjs): feature · Column reorder by drag-and-drop. · `lib/features/column-dnd.mjs`
- [Row drag](https://github.com/glromeo/sleek-grid/blob/main/lib/features/row-dnd.mjs): feature · Row reorder by drag-and-drop. · `lib/features/row-dnd.mjs`
- [Highlight](https://github.com/glromeo/sleek-grid/blob/main/lib/features/highlight.mjs): feature · Selection, focus, and hover feedback. · `lib/features/highlight.mjs`
- [Grid API](https://github.com/glromeo/sleek-grid/blob/main/lib/utils/grid-api.mjs): public api · Imperative boundary for consumers and internal modules. · `lib/utils/grid-api.mjs`
- [Styles](https://github.com/glromeo/sleek-grid/blob/main/lib/styles/sleek.mjs): style modules · Dynamic and static grid styling. · `lib/styles/sleek.mjs`
- [Icons](https://github.com/glromeo/sleek-grid/blob/main/lib/icons.mjs): ui assets · Built-in iconography for grid affordances. · `lib/icons.mjs`

### Delivery

Browser package outputs and publishable bundles.

- [IIFE build](https://github.com/glromeo/sleek-grid/blob/main/iife/sleek-grid.js): browser bundle · Script-tag distributable build. · `iife/sleek-grid.js`

### Examples

Runnable demos, docs, and browser-facing sample pages.

- [Docs site](https://github.com/glromeo/sleek-grid/blob/main/docs/index.md): static docs · Published documentation and demo bundle. · `docs/index.md`
- [Demo app](https://github.com/glromeo/sleek-grid/blob/main/public/index.html): browser demos · Runnable examples and sample data for the grid. · `public/index.html`

### Validation

Browser specs and performance benchmarks.

- [Browser specs](https://github.com/glromeo/sleek-grid/blob/main/spec/runner.html): jasmine suite · Browser-based behavioral tests and runner. · `spec/runner.html`
- [Benchmarks](https://github.com/glromeo/sleek-grid/blob/main/benchmark/index.html): perf pages · Performance comparison and workload validation pages. · `benchmark/index.html`

## Connections

- Entry → Bundle: re-exports · Primary module surface is exposed through the packaged bundle.
- Entry → Rows: uses · Entry wiring connects row state management into the grid.
- Entry → Columns: uses · Entry wiring connects column state management into the grid.
- Entry → Root: mounts · Creates the top-level shell component.
- Root → Grid area: contains · Root composes the scrollable viewport.
- Grid area → Header row: positions · Viewport coordinates header rendering with visible content.
- Grid area → Grid row: renders · Viewport renders only visible rows.
- Rows → Grid row: drives · Row controller feeds visible row state to row components.
- Columns → Header row: drives · Column state determines header structure and ordering.
- Columns → Grid row: sizes · Column sizing affects row cell layout.
- Header row → Col resize: enables · Header wires column resize behavior.
- Header row → Header resize: enables · Header-specific resizing behavior sits on the header layer.
- Grid row → Row resize: enables · Row rendering layer supports resizing interactions.
- Columns → Col drag: supports · Column ordering changes are handled as a feature on top of column state.
- Rows → Row drag: supports · Row ordering changes are handled as a feature on top of row state.
- Grid area → Highlight: overlays · Highlight feedback is layered onto the virtualized viewport.
- Entry → Grid API: exposes · Public imperative API boundary.
- Grid API → Rows: controls · API operations manipulate row state.
- Grid API → Columns: controls · API operations manipulate column state.
- Entry → Styles: applies · Core library attaches grid styling.
- Entry → Icons: uses · Core library ships internal icon assets.
- IIFE build → Entry: packages · Browser bundle packages the main library surface.
- Docs site → IIFE build: consumes · Documentation demo loads the distributable build.
- Demo app → Entry: consumes · Sample pages exercise the library in the browser.
- Browser specs → Entry: verifies · Browser specs exercise the library entry surface.
- Benchmarks → Grid area: measures · Benchmarks stress the virtualization and rendering boundary.
