How abaktiar/datagrid-shadcn works
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)