How mr-harishv/carbon-labs works
1. This is a monorepo for Carbon Labs: a set of independently published UI packages, not a single application. The core architectural idea is “many small component packages” with their own source, tests, docs, Storybook stories, and package metadata.
2. The repo is split by runtime and delivery model:
- packages/react for React component packages
- packages/web-components for custom elements / web components
- packages/primitives for headless/shared logic used by components
- packages/utilities for cross-package helper functions
- packages/vscode-snippets and packages/vscode-snippets-extension for editor tooling
- tools/create and repo-level tools/* for scaffolding and repo maintenance
3. The React side is organized as one package per component under packages/react/src/components/<ComponentName>. Each component typically contains its implementation, styles, Storybook stories/MDX docs, tests, telemetry metadata, and a package entry point. Larger composites like UIShell, PlaneStack3D, and MDXComponents have internal subcomponent trees and shared helpers, but still publish as single packages.
4. The Web Components side follows a similar “one package per component” model under packages/web-components/src/components/<name>, but with a web-component-specific structure: source files, template files, SCSS, generated/custom-element entrypoints, and sometimes service/adaptor layers. This package also contains component-level React wrappers for some components, showing a bridge boundary for React consumers.
5. packages/primitives contains non-visual logic and state machines, most clearly the date-picker primitive. This package is the headless layer: state transitions, keyboard handling, click-outside handling, and date/temporal utilities live here so UI packages can reuse behavior without reimplementing it.
6. packages/utilities is the smallest shared boundary: generic helpers such as prefixing/settings utilities that are imported by multiple packages. It exists to keep common runtime behavior out of individual components and avoid duplication across the monorepo.
7. The repo includes multiple consumer/demo surfaces in examples/react and examples/web-components. These are separate Vite apps for validating components in realistic app contexts; they act as integration examples rather than production applications. They also reflect the two supported consumption models: React import and browser-native custom elements.
8. Storybook is a major architectural layer, not just documentation. There is root Storybook configuration plus per-package Storybook configs, templates, and welcome screens. Stories and MDX docs are part of the source tree and are used to visualize component states, edge cases, and usage guidance before publishing.
9. Testing is layered per package:
- unit/snapshot tests alongside each component
- web-component browser tests using web-test-runner
- some UI-level/browser automation configuration at the repo root via Playwright
This keeps verification close to each package boundary while still supporting end-to-end checks where needed.
10. The repo is built and released through package-specific build tasks and GitHub Actions. Workflows cover CI, PR checks, releases, canary/CDN publishing, Storybook publishing, and automerge. netlify.toml and the Storybook publish workflow show that the docs/demo surface is deployed separately from package artifacts.
11. There are two significant “composite system” areas worth diagramming specially:
- UIShell / global-header, which combine many internal subcomponents, runtime scripts, context providers, and accessibility/keyboard helpers
- ThemeSettings / StylePicker, which manage shared theme state and expose UI controls that affect global appearance
These are more like feature subsystems than single widgets.
12. The repo also has a generation/scaffolding pipeline. tools/create and packages/*/tasks/generate create new component packages from templates, inject metadata, and standardize structure. That means new components enter the architecture through a controlled scaffold, not ad hoc folder creation.
13. A notable cross-cutting concern is telemetry and governance: many components include telemetry.yml, and the repo carries contribution, release, and license automation. That makes package metadata, docs, and compliance part of the architecture rather than afterthoughts.
14. For a diagram, the key flow is: scaffold/template → component package source → stories/tests/docs → package build → publish to npm/CDN and Storybook → consume from examples or downstream apps. The main boundaries are React vs Web Components, visual components vs shared primitives/utilities, and source/runtime vs documentation/release infrastructure.
Main entry points: react React UI · web-components Web components · workflows CI & release · .storybook Storybook
Components 20
React packages
React-delivered UI components and composites.
- React UI · One-package-per-component React delivery surface.
packages/react - UIShell · Large shell system with header, side nav, popovers, profiles, and keyboard/accessibility helpers.
packages/react/src/components/UIShell - ThemeSettings · Shared theme state and controls affecting global appearance.
packages/react/src/components/ThemeSettings - Other React comps · Published component packages such as Calendar, Processing, Resizer, TagInput, TextHighlighter, WhatsNew, and more.
packages/react/src/components - MDX Components · Reusable documentation/rendering components for Storybook and MDX content.
packages/react/src/components/MDXComponents - PlaneStack3D · Complex visualization package with layered subcomponents, layout, a11y, and theme context.
packages/react/src/components/PlaneStack3D
Web components
Custom elements and their React bridge wrappers.
- Web components · Custom elements with templates, SCSS, generated entrypoints, and optional React bridges.
packages/web-components - Chat · Multi-part chat system with elements plus service/adaptor layers.
packages/web-components/src/components/chat - GlobalHeader · Large header system with contexts, auth, scripts, side nav, and React wrapper boundary.
packages/web-components/src/components/global-header - StylePicker · Theme and style selection system with grouped options, context, and rendering utilities.
packages/web-components/src/components/style-picker - DatePicker · Web-component date picker built around adapters and reusable internal component logic.
packages/web-components/src/v12/components/date-picker
Shared layers
Headless logic and cross-package helpers.
- Primitives · Shared state machines and non-visual behavior, especially date-picker logic.
packages/primitives - Utilities · Cross-package helper functions and generic runtime helpers.
packages/utilities
Tooling
Scaffolding, build tasks, Storybook, CI, and release automation.
- React generator · Task pipeline and templates for creating new React component packages.
packages/react/tasks/generate - Web generator · Task pipeline and templates for creating new web-component packages.
packages/web-components/tasks/generate - Storybook · Root and package-level Storybook configuration, stories, docs, and welcome surfaces.
.storybook - CI & release · GitHub Actions, publish workflows, Netlify config, and release automation.
.github/workflows
Examples
Integration/demo surfaces for the supported consumption models.
- React examples · Integration demos validating React consumption in realistic app contexts.
examples/react - Web examples · Integration demos for browser-native custom elements and CDN usage.
examples/web-components
Other components
- Carbon Labs · Independently published UI packages organized by runtime and delivery model.
Connections 32
- Carbon Labs → React UI: contains · Monorepo delivers React package family.
- Carbon Labs → Web components: contains · Monorepo delivers web-component family.
- Carbon Labs → Primitives: contains · Shared headless behavior lives here.
- Carbon Labs → Utilities: contains · Cross-package helpers live here.
- Carbon Labs → Storybook: docs layer · Repository-wide Storybook setup and welcome content.
- Carbon Labs → CI & release: automation · CI, release, and publish workflows.
- Carbon Labs → React examples: contains · React integration demos.
- Carbon Labs → Web examples: contains · Web-component integration demos.
- React UI → UIShell: includes · Major composite React subsystem.
- React UI → ThemeSettings: includes · Theme state and controls subsystem.
- React UI → PlaneStack3D: includes · Complex visualization package.
- React UI → MDX Components: includes · Documentation rendering components.
- React UI → Other React comps: includes · Other published React components.
- React generator → React UI: scaffolds · Creates standardized React component packages.
- Web components → Chat: includes · Large multi-element chat suite.
- Web components → GlobalHeader: includes · Large header and auth/context subsystem.
- Web components → StylePicker: includes · Theme/style selection subsystem.
- Web components → DatePicker: includes · V12 date-picker bridge and implementation.
- Web generator → Web components: scaffolds · Creates standardized web-component packages.
- PlaneStack3D → Primitives: reuses · Shares headless behavior and utilities where needed.
- UIShell → Utilities: reuses · Uses common helpers such as prefixing and settings utilities.
- ThemeSettings → Utilities: reuses · Shares settings/prefix helpers.
- GlobalHeader → Utilities: reuses · Uses shared runtime helpers where applicable.
- DatePicker → Primitives: adapts · Builds on headless date-picker behavior.
- StylePicker → ThemeSettings: mirrors · Corresponding theme control boundary across runtimes.
- Storybook → React UI: documents · Stories and MDX for React packages.
- Storybook → Web components: documents · Stories and MDX for web-component packages.
- CI & release → Storybook: publishes · Storybook is deployed separately from package artifacts.
- CI & release → React UI: releases · Package builds and publishes React artifacts.
- CI & release → Web components: releases · Package builds and publishes web-component artifacts.
- React examples → React UI: consumes · Validates React packages in app contexts.
- Web examples → Web components: consumes · Validates custom elements in browser contexts.