# abaktiar/datagrid-shadcn architecture

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

- Interactive diagram: https://gitdiagram.com/abaktiar/datagrid-shadcn
- Repository: https://github.com/abaktiar/datagrid-shadcn

## Overview

##### Project Type and Purpose
- This is a front-end UI component library (shadcn/ui DataGrid) plus a demo application and a static registry.
- Its purpose is to provide a highly-customizable, performant React DataGrid component (built on TanStack Table, TanStack Virtual, shadcn/ui, Tailwind CSS) that can be consumed via the shadcn CLI or manually.

##### High-Level Architecture Components
a. Developer Environment
- Git repo containing source code, README, configs.
- Vite dev server (vite.config.js) for local development.
b. DataGrid Component Library (src/components/data-grid)
- Core: DataGrid.tsx
- Subcomponents: Header, Body, Filters, Pagination, Action Dock, Context Menu.
- Context & Types (context.tsx, types.ts).
c. UI Primitives (src/components/ui)
- Button, Checkbox, Input, Select, Table, Pagination, ContextMenu, DropdownMenu.
d. Utilities & Data
- src/lib/utils.ts
- src/data/sample-data.ts
- src/examples (usage examples).
e. Registry Service
- Static JSON files in public/r/data-grid.json & registry.json.
- Registry build script (`npm run registry:build`).
- Hosted on Netlify/Vercel under `/r/data-grid.json`.
f. Demo Application
- Entry: src/main.jsx → App.tsx → Imports DataGrid + sample data.
g. External Dependencies
- TanStack Table v8, TanStack Virtual, shadcn/ui core, Tailwind CSS v4, lucide-react, clsx, class-variance-authority, tailwind-merge, React 19, TypeScript.
h. Consumption Paths
- shadcn CLI (npx shadcn add <registry-url>)
- Manual copy + npm install dependencies

##### Relationships and Data Flows
- Developer invokes `npm run dev` → Vite serves the Demo App.
- Demo App imports DataGrid library modules → uses React + TanStack Table + Tailwind CSS.
- Core DataGrid orchestrates subcomponents via context.
- DataGrid uses TanStack Virtual for row virtualization, React.memo/useMemo for performance.
- On build (`npm run registry:build`), registry JSON is generated from components.json → placed in public/r.
- shadcn CLI fetches registry from static host to inject components into a target project.

##### Architectural Patterns & Principles
- Composable, modular component design (each feature in its own file).
- Separation of concerns: UI primitives vs. DataGrid logic vs. demo vs. registry.
- Headless logic via TanStack Table (state management separated from rendering).
- Performance optimizations: memoization, virtualization, debounced filtering.
- Static site generation of registry (ensures reproducible component distribution).

##### Essential Elements to Capture
- Core subcomponents and context
- Build pipeline (Vite dev vs. registry build)
- Static registry hosting and CLI consumption
- Demo App as a real-world consumer
- Major external libraries and their role (e.g., TanStack Table for state, Virtual for performance, Tailwind for styling)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Developer Environment
    subgraph "Developer Environment"
        DEV_GIT["Git Repository"]:::external
        VITE["Vite Dev Server\n(vite.config.js)"]:::build
    end

    %% Demo Application
    subgraph "Demo Application"
        DEMO_ENTRY["src/main.jsx"]:::core
        DEMO_APP["src/App.tsx"]:::core
        HTML["index.html"]:::core
        CSS["src/index.css"]:::core
    end

    %% DataGrid Component Library
    subgraph "DataGrid Component Library" 
        DG_INDEX["index.ts"]:::core
        DG_CORE["data-grid.tsx"]:::core
        DG_HEADER["data-grid-header.tsx"]:::core
        DG_BODY["data-grid-body.tsx"]:::core
        DG_FILTERS["data-grid-filters.tsx"]:::core
        DG_PAGINATION["data-grid-pagination.tsx"]:::core
        DG_ACTION["data-grid-action-dock.tsx"]:::core
        DG_CONTEXTMENU["data-grid-context-menu.tsx"]:::core
        DG_EDITABLE["data-grid-editable-cell.tsx"]:::core
        DG_CONTEXT["context.tsx"]:::core
        DG_TYPES["types.ts"]:::core
        DG_UTILS["context-menu-utils.tsx"]:::core
        DG_GUIDE1["CONTEXT_MENU_GUIDE.md"]:::core
        DG_GUIDE2["SERVER_SIDE_GUIDE.md"]:::core
    end

    %% UI Primitives
    subgraph "UI Primitives"
        UI_BUTTON["button.tsx"]:::ui
        UI_CHECKBOX["checkbox.tsx"]:::ui
        UI_INPUT["input.tsx"]:::ui
        UI_SELECT["select.tsx"]:::ui
        UI_TABLE["table.tsx"]:::ui
        UI_PAG["pagination.tsx"]:::ui
        UI_CTX_MENU["context-menu.tsx"]:::ui
        UI_DROPDOWN["dropdown-menu.tsx"]:::ui
    end

    %% Utilities & Sample Data
    subgraph "Utilities & Sample Data"
        UTIL["src/lib/utils.ts"]:::core
        SAMPLE["src/data/sample-data.ts"]:::core
        EX1["basic-usage.tsx"]:::core
        EX2["editable-data-grid-example.tsx"]:::core
    end

    %% Registry Service
    subgraph "Registry Service"
        REG_JSON["data-grid.json"]:::build
        MANIFEST["registry.json"]:::build
        COMP_DEF["components.json"]:::build
    end

    %% External Dependencies
    subgraph "External Dependencies"
        EXT_TS8["TanStack Table v8"]:::external
        EXT_VIRT["TanStack Virtual"]:::external
        EXT_SHAD_CN["shadcn/ui core"]:::external
        EXT_TW["Tailwind CSS v4"]:::external
        EXT_LUCIDE["lucide-react"]:::external
        EXT_CLSX["clsx"]:::external
        EXT_CVA["class-variance-authority"]:::external
        EXT_MERGE["tailwind-merge"]:::external
        EXT_REACT["React v19"]:::external
        EXT_TS["TypeScript"]:::external
    end

    %% Consumption Paths
    subgraph "Consumption Paths"
        CLI["shadcn CLI"]:::external
        MANUAL["Manual Copy + npm install"]:::external
    end

    %% Connections
    DEV_GIT --> VITE
    VITE -->|"serve Demo App"| DEMO_ENTRY
    DEMO_ENTRY -->|"import"| DEMO_APP
    DEMO_APP -->|"imports"| DG_INDEX
    DG_INDEX --> DG_CORE
    DG_CORE --> DG_HEADER
    DG_CORE --> DG_BODY
    DG_CORE --> DG_FILTERS
    DG_CORE --> DG_PAGINATION
    DG_CORE --> DG_ACTION
    DG_CORE --> DG_CONTEXTMENU
    DG_CORE --> DG_EDITABLE
    DG_CORE --> DG_CONTEXT
    DG_CORE --> DG_TYPES
    DG_CORE --> UTIL
    DG_CORE -->|"uses UI primitives"| UI_BUTTON
    DG_CORE --> UI_CHECKBOX
    DG_CORE --> UI_INPUT
    DG_CORE --> UI_SELECT
    DG_CORE --> UI_TABLE
    DG_CORE --> UI_PAG
    DG_CORE --> UI_CTX_MENU
    DG_CORE --> UI_DROPDOWN
    DG_CORE --> EXT_TS8
    DG_CORE --> EXT_VIRT
    DG_CORE --> EXT_SHAD_CN
    DG_CORE --> EXT_TW
    DG_CORE --> EXT_REACT
    DG_CORE --> EXT_TS
    DEMO_APP --> SAMPLE
    DEMO_APP --> EXT_TW
    UTIL --> EX1
    UTIL --> EX2
    REG_JSON --> CLI
    REG_JSON --> MANUAL
    COMP_DEF --> REG_JSON
    MANIFEST --> REG_JSON

    %% Click Events
    click VITE "https://github.com/abaktiar/datagrid-shadcn/blob/main/vite.config.js"
    click DG_INDEX "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/index.ts"
    click DG_CORE "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid.tsx"
    click DG_HEADER "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-header.tsx"
    click DG_BODY "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-body.tsx"
    click DG_FILTERS "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-filters.tsx"
    click DG_PAGINATION "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-pagination.tsx"
    click DG_ACTION "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-action-dock.tsx"
    click DG_CONTEXTMENU "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-context-menu.tsx"
    click DG_EDITABLE "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/data-grid-editable-cell.tsx"
    click DG_CONTEXT "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/context.tsx"
    click DG_TYPES "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/types.ts"
    click DG_UTILS "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/context-menu-utils.tsx"
    click DG_GUIDE1 "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/CONTEXT_MENU_GUIDE.md"
    click DG_GUIDE2 "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/data-grid/SERVER_SIDE_GUIDE.md"
    click UI_BUTTON "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/button.tsx"
    click UI_CHECKBOX "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/checkbox.tsx"
    click UI_INPUT "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/input.tsx"
    click UI_SELECT "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/select.tsx"
    click UI_TABLE "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/table.tsx"
    click UI_PAG "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/pagination.tsx"
    click UI_CTX_MENU "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/context-menu.tsx"
    click UI_DROPDOWN "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/components/ui/dropdown-menu.tsx"
    click UTIL "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/lib/utils.ts"
    click SAMPLE "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/data/sample-data.ts"
    click EX1 "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/examples/basic-usage.tsx"
    click EX2 "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/examples/editable-data-grid-example.tsx"
    click REG_JSON "https://github.com/abaktiar/datagrid-shadcn/blob/main/public/r/data-grid.json"
    click MANIFEST "https://github.com/abaktiar/datagrid-shadcn/blob/main/registry.json"
    click COMP_DEF "https://github.com/abaktiar/datagrid-shadcn/blob/main/components.json"
    click DEMO_ENTRY "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/main.jsx"
    click DEMO_APP "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/App.tsx"
    click HTML "https://github.com/abaktiar/datagrid-shadcn/blob/main/index.html"
    click CSS "https://github.com/abaktiar/datagrid-shadcn/blob/main/src/index.css"

    %% Styles
    classDef core fill:#cffafe,stroke:#0c4a6e,stroke-width:1px
    classDef ui fill:#dcfce7,stroke:#166534,stroke-width:1px
    classDef build fill:#ffedd5,stroke:#c2410c,stroke-width:1px
    classDef external fill:#e5e7eb,stroke:#4b5563,stroke-width:1px
```
