How evilmartians/oklch-picker works
Project Type and Purpose
• It is entirely client-side, served as static assets (HTML/CSS/JS) and deployed (via Firebase Hosting) to a CDN. Build and CI/CD are managed with Vite, pnpm, and GitHub Actions.
High-Level Components
A. Client-side Runtime (Browser)
1. Entry Point
• index.html / index.ts
• Loads the SPA bundle, injects root component, sets up global stores.
2. UI Layer
• view/… folder: Pug templates, TS components, CSS/PostCSS files
• Components (button, chart, field, etc.) implement the interactive UI.
3. State Management
• Acts as the single source of truth for the UI.
4. Domain Logic
5. Web Workers
• view/chart/worker.ts and lib/workers.ts: offload heavy computations (e.g., chart path generation) to worker threads to keep UI responsive.
6. Assets & Manifests
• public/*.webmanifest: PWA metadata
B. Build & Toolchain
1. Build Configuration
• vite.config.js, config.js: define entry points, plugins (Pug, PostCSS), build targets
• tsconfig.json: TypeScript compiler settings
2. Linting & Formatting
• eslint.config.js, .stylelintrc, .prettierrc, .editorconfig: enforce code style across JS/TS/CSS/Pug
3. Testing & Quality
• .github/workflows/ci.yml: runs lint, tests, size-limit, builds on each PR
C. CI/CD & Deployment
1. Source Control & CI
• GitHub Actions (ci.yml): installs dependencies (pnpm), runs tests, lint, size-limit, then builds.
2. Hosting
• firebase.json: Firebase Hosting configuration, redirects, PWA caching.
3. Releases
• package.json / pnpm-lock.yaml: versioning and dependencies published to npm if needed.
Relationships & Data Flows
• Build-time: Source (view/, lib/, stores/, index.ts) → Vite → optimized JS/CSS/HTML bundle → deploy to Firebase.
• Web worker offload: Components dispatch heavy jobs to worker threads via lib/workers → worker returns results → main thread updates canvas/DOM.
Architectural Patterns & Principles
• Modular separation: UI (view/) vs State (stores/) vs Domain Logic (lib/).
• Reactive data flow: updates in stores automatically propagate to subscribed components.
• PWA best practices: webmanifest, static asset caching.
• Performance optimization: Web Workers for heavy computations; tree-shaking via Vite.