How davidhdev/react-haiku works
Project Type and Purpose
• This is an open-source React library (“Haiku”) providing a suite of reusable hooks and utility components.
• It includes:
– A source code directory (TypeScript hooks + utilities)
– A compiled output (“lib”) for npm distribution
– A Docusaurus-based documentation/demo site (“docs”)
– Unit tests (Jest + React Testing Library)
– CI/CD configuration implicitly via .github folder and standard npm scripts
Main Components
A. Core Library
• lib/hooks – individual React hook implementations
• lib/utils – lightweight utility components (If, For, Show, etc.)
• lib/helpers – shared helper functions (cookie, event)
• lib/index.ts – entry point that exports all hooks & utilities
B. Build & Packaging
• tsconfig.json – TypeScript compiler settings
• snapshotResolver.ts, jest.config.ts, jest.setup.ts – test configuration
• package.json – build, test, lint, publish scripts and dependencies
• npmignore/.npmignore – files excluded/included in published package
C. Documentation & Demo Site
• docs/src – React components & pages for demos
• docs/docs – Markdown/MDX docs (auto-generated sidebar)
• docs/docusaurus.config.js, sidebars.js – site configuration
• docs/static – site assets (images, CSS)
• docs/package.json – local dependencies for site, build scripts
D. Testing & CI
• lib/tests – unit tests for hooks and utilities
• .github/ISSUE_TEMPLATE – contribution templates
• CONTRIBUTING.md, LICENSE.md – contribution and licensing guidelines
E. External Services
• GitHub – source code hosting, issue tracking
• npm registry – package distribution
• Documentation hosting (e.g., Netlify, Vercel) – serves built “docs” site
Relationships and Data Flow
• Developer writes TS source under lib/
↓
• Build pipeline (ts-compiler) outputs JS in lib/ folder
↓
• npm publish pushes package to npm registry
↓
• Consumer apps install react-haiku and import hooks/utilities
• docs/ source code builds site, published to a static-site host
• Tests run against lib/ output in CI (GitHub Actions)
Architectural Patterns & Design Principles
• Modular: each hook / utility in its own file for tree-shaking
• Single entry point for exports (lib/index.ts)
• Documentation generation using Docusaurus (MDX + React demos)
• Automated testing with Jest + RTL to ensure API contracts
• CI/CD via GitHub workflows (implied) for lint, test, and publish