Project Structure
Sparkle is organized as a TypeScript monorepo with focused packages and clear separation of concerns.
Overview
Section titled βOverviewβsparkle/βββ π¦ packages/ # Core Sparkle packagesβ βββ π¨ ui/ # React component libraryβ βββ π theme/ # Design tokens and providersβ βββ π types/ # TypeScript definitionsβ βββ π§ utils/ # Utility functionsβ βββ π§ͺ error-testing/ # Testing frameworkβ βββ βοΈ config/ # Shared configurationsβββ π± apps/ # Example applicationsβ βββ fro-jive/ # Expo mobile appβββ π docs/ # Documentation site (you're here!)βββ π¨ scripts/ # Build and utility scriptsβββ ποΈ infrastructure files # Package configs, CI/CD, etc.Package Architecture
Section titled βPackage ArchitectureβDependency Graph
Section titled βDependency GraphβUnderstanding how packages relate to each other:
@sparkle/ui β Main component libraryβββ @sparkle/theme # β Design tokens & themingβββ @sparkle/types # β TypeScript definitionsβββ @sparkle/utils # β Shared utilities
@sparkle/theme β Design system foundationβββ @sparkle/types # β Core type definitions
@sparkle/utils β React hooks & utilitiesβββ @sparkle/types # β Type safety everywhere
@sparkle/error-testing β Development toolsβββ @sparkle/types # β Consistent type usageThis bottom-up architecture means:
- β No circular dependencies - Clean, predictable imports
- β Incremental adoption - Use just what you need
- β Independent versioning - Packages can evolve separately
- β Clear boundaries - Each package has distinct responsibilities
Package Deep Dive
Section titled βPackage Deep Diveβπ¨ @sparkle/ui
Section titled βπ¨ @sparkle/uiβThe main component library containing all React components:
packages/ui/βββ src/β βββ components/ # Individual componentsβ β βββ Button/ # Button component + storiesβ β βββ Form/ # Form componentsβ β βββ ... # Other componentsβ βββ hooks/ # Component-specific hooksβ βββ utils/ # UI utilitiesβ βββ index.ts # Public API exportsβββ dist/ # Built JavaScript + CSSβββ styles.css # Component stylesβββ package.jsonKey Features:
- π― Accessible by default - WCAG 2.1 AA compliant
- π§ Highly customizable - CSS custom properties + Tailwind
- π Storybook integration - Interactive component playground
- π§ͺ Comprehensive testing - Unit, integration, and visual regression
π @sparkle/theme
Section titled βπ @sparkle/themeβDesign token management and theme providers:
packages/theme/βββ src/β βββ tokens/ # Design token definitionsβ β βββ base.ts # Core tokens (colors, spacing, etc.)β β βββ light.ts # Light theme overridesβ β βββ dark.ts # Dark theme overridesβ βββ providers/ # Theme context providersβ β βββ ThemeProvider.tsx # Web theme providerβ β βββ NativeThemeProvider.tsx # React Native providerβ βββ utils/ # Token transformation utilitiesβ βββ index.ts # Public exportsβββ styles.css # Generated CSS custom propertiesβββ package.jsonKey Features:
- π Cross-platform tokens - Web CSS + React Native StyleSheet
- π¨ Dynamic theming - Runtime theme switching
- π§ Token transformation - Automatic format conversion
- π± Mobile support - React Native compatible
π @sparkle/types
Section titled βπ @sparkle/typesβShared TypeScript definitions used across all packages:
packages/types/βββ src/β βββ components/ # Component prop typesβ βββ theme/ # Theme-related typesβ βββ utils/ # Utility typesβ βββ index.ts # Re-exportsβββ package.jsonπ§ @sparkle/utils
Section titled βπ§ @sparkle/utilsβUtility functions and React hooks:
packages/utils/βββ src/β βββ hooks/ # React hooksβ β βββ useDebounce.tsβ β βββ useClickOutside.tsβ β βββ useAsync.tsβ βββ functions/ # Pure utility functionsβ βββ index.tsβββ package.jsonπ§ͺ @sparkle/error-testing
Section titled βπ§ͺ @sparkle/error-testingβError testing framework for development:
packages/error-testing/βββ src/β βββ builders/ # Test scenario buildersβ βββ fixtures/ # Test data fixturesβ βββ utils/ # Testing utilitiesβ βββ index.tsβββ package.jsonBuild System
Section titled βBuild SystemβSparkle uses modern tooling for efficient development:
ποΈ Turborepo
Section titled βποΈ TurborepoβOrchestrates builds across packages with intelligent caching:
# Build all packages (with dependency order)pnpm build
# Build only changed packagespnpm build --filter=...[HEAD~1]
# Parallel development modepnpm devπ¦ pnpm Workspaces
Section titled βπ¦ pnpm WorkspacesβManages dependencies with workspace linking:
# Install dependency in specific packagepnpm add --filter @sparkle/ui react
# Install dev dependency globallypnpm add -Dw typescript
# Run command in all packagespnpm -r buildβ‘ tsdown
Section titled ββ‘ tsdownβFast TypeScript compilation for packages:
export default defineConfig({ entry: ['./src/index.ts'], outDir: 'dist', dts: true, // Generate .d.ts files clean: true, // Clean dist/ before build})Development Workflow
Section titled βDevelopment Workflowβπ Hot Reload Development
Section titled βπ Hot Reload DevelopmentβStart all development servers:
# Terminal 1: Type checking in watch modepnpm build:types:watch
# Terminal 2: All development serverspnpm devThis starts:
- π Storybook at
http://localhost:6006 - π Documentation at
http://localhost:4321 - π± Mobile app via Expo CLI
- π§ Package builds in watch mode
π§ͺ Testing Strategy
Section titled βπ§ͺ Testing StrategyβComprehensive testing at multiple levels:
# Unit tests with Vitestpnpm test
# Visual regression tests with Playwrightpnpm test:visual
# Type checkingpnpm check:types
# Full quality checkpnpm checkπ¦ Release Management
Section titled βπ¦ Release ManagementβUsing Changesets for coordinated releases:
# Create changeset for your changespnpm changeset
# Version packages based on changesetspnpm changeset version
# Publish to npm (CI only)pnpm changeset publishConfiguration Files
Section titled βConfiguration FilesβKey configuration files and their purposes:
| File | Purpose |
|---|---|
turbo.json | Task orchestration and caching |
pnpm-workspace.yaml | Workspace package definitions |
tsconfig.json | Root TypeScript configuration |
eslint.config.ts | ESLint rules for all packages |
.changeset/config.json | Release configuration |
Next Steps
Section titled βNext StepsβNow that you understand the structure:
- Explore Components - Browse the component library
- Learn Theming - Understand design tokens
- Development Guide - Contribute to Sparkle
- Quick Start - Build your first component