Design System Architecture
Purpose
Design a token-based design system architecture, including primitive → semantic → component token hierarchy, theming strategy (dark/light mode), and cross-platform implementation plan.
Inputs
- Existing styling approach (Tailwind, CSS modules, styled-components, etc.)
- Target platforms (web, iOS, Android, cross-platform)
- Brand guidelines or existing color palette
- Current component inventory
- Theming requirements (dark mode, high contrast, brand variations)
Process
Step 1: Audit Current State
Review the existing styling approach:
- How are colors, spacing, and typography defined today?
- Are there hardcoded values scattered across components?
- Is there an existing design system or component library?
- What CSS methodology is used (utility-first, BEM, CSS-in-JS)?
Step 2: Define Primitive Tokens
Establish the raw values that form the foundation:
- Color primitives: Named palette (blue-50 through blue-900, gray scale, semantic colors)
- Spacing scale: 4px base unit → 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64
- Type scale: Size ramp with corresponding line heights and letter spacing
- Border radius: Small (4px), medium (8px), large (16px), full (9999px)
- Shadow/elevation: Subtle, medium, prominent
- Duration: Fast (100ms), normal (200ms), slow (300ms)
Step 3: Define Semantic Tokens
Map primitives to semantic meaning:
- Surface: surface-primary, surface-secondary, surface-elevated
- Text: text-primary, text-secondary, text-muted, text-inverse
- Border: border-default, border-strong, border-focus
- Interactive: interactive-primary, interactive-hover, interactive-pressed
- Status: status-success, status-warning, status-error, status-info
- Spacing: space-xs, space-sm, space-md, space-lg, space-xl
Step 4: Define Component Tokens
Map semantic tokens to component-specific values:
- Button: button-bg, button-text, button-border, button-radius
- Input: input-bg, input-border, input-focus-ring, input-text
- Card: card-bg, card-border, card-shadow, card-radius, card-padding
Step 5: Design Theme Architecture
Define how themes override token values:
- Light theme: Default token assignments
- Dark theme: Which semantic tokens change, which stay the same
- High contrast: Increased border widths, higher contrast ratios
- Implementation: CSS custom properties, Tailwind config, or platform-specific theming
Step 6: Cross-Platform Strategy
If multiple platforms:
- Token format: Use Style Dictionary or similar to generate platform-specific output
- Web: CSS custom properties or Tailwind theme config
- iOS: Swift color/spacing constants or asset catalogs
- Android: XML resources or Compose theme
- Shared source of truth: JSON or YAML token definitions
Output Format
# Design System Architecture
## Token Hierarchy
### Primitive Tokens
| Category | Token | Value |
|----------|-------|-------|
| Color | blue-500 | #3B82F6 |
| Spacing | space-4 | 16px |
| Type | text-base | 16px/24px |
### Semantic Tokens
| Token | Light | Dark | Usage |
|-------|-------|------|-------|
| surface-primary | white | gray-900 | Main background |
| text-primary | gray-900 | gray-50 | Body text |
| interactive-primary | blue-500 | blue-400 | Buttons, links |
### Component Tokens
| Component | Token | Maps To |
|-----------|-------|---------|
| Button (primary) | button-bg | interactive-primary |
| Button (primary) | button-text | text-inverse |
## Theme Switching
[Implementation approach — CSS class, media query, user preference]
## File Structure
tokens/
primitives.json
semantic-light.json
semantic-dark.json
components.json
## Migration Plan
[Steps to migrate from current approach to token-based system]
Quality Checks
Evolution Notes
1---2name: design-system-architecture3department: "artisan"4description: "Token hierarchy, theming strategy, and cross-platform consistency"5version: 16triggers:7 - "design system"8 - "design tokens"9 - "theme"10 - "dark mode"11 - "CSS variables"12 - "Figma"13 - "Storybook"14 - "component library"15 - "style guide"16---1718# Design System Architecture1920## Purpose2122Design a token-based design system architecture, including primitive → semantic → component token hierarchy, theming strategy (dark/light mode), and cross-platform implementation plan.2324## Inputs2526- Existing styling approach (Tailwind, CSS modules, styled-components, etc.)27- Target platforms (web, iOS, Android, cross-platform)28- Brand guidelines or existing color palette29- Current component inventory30- Theming requirements (dark mode, high contrast, brand variations)3132## Process3334### Step 1: Audit Current State3536Review the existing styling approach:37- How are colors, spacing, and typography defined today?38- Are there hardcoded values scattered across components?39- Is there an existing design system or component library?40- What CSS methodology is used (utility-first, BEM, CSS-in-JS)?4142### Step 2: Define Primitive Tokens4344Establish the raw values that form the foundation:45- **Color primitives:** Named palette (blue-50 through blue-900, gray scale, semantic colors)46- **Spacing scale:** 4px base unit → 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 6447- **Type scale:** Size ramp with corresponding line heights and letter spacing48- **Border radius:** Small (4px), medium (8px), large (16px), full (9999px)49- **Shadow/elevation:** Subtle, medium, prominent50- **Duration:** Fast (100ms), normal (200ms), slow (300ms)5152### Step 3: Define Semantic Tokens5354Map primitives to semantic meaning:55- **Surface:** surface-primary, surface-secondary, surface-elevated56- **Text:** text-primary, text-secondary, text-muted, text-inverse57- **Border:** border-default, border-strong, border-focus58- **Interactive:** interactive-primary, interactive-hover, interactive-pressed59- **Status:** status-success, status-warning, status-error, status-info60- **Spacing:** space-xs, space-sm, space-md, space-lg, space-xl6162### Step 4: Define Component Tokens6364Map semantic tokens to component-specific values:65- **Button:** button-bg, button-text, button-border, button-radius66- **Input:** input-bg, input-border, input-focus-ring, input-text67- **Card:** card-bg, card-border, card-shadow, card-radius, card-padding6869### Step 5: Design Theme Architecture7071Define how themes override token values:72- **Light theme:** Default token assignments73- **Dark theme:** Which semantic tokens change, which stay the same74- **High contrast:** Increased border widths, higher contrast ratios75- **Implementation:** CSS custom properties, Tailwind config, or platform-specific theming7677### Step 6: Cross-Platform Strategy7879If multiple platforms:80- **Token format:** Use Style Dictionary or similar to generate platform-specific output81- **Web:** CSS custom properties or Tailwind theme config82- **iOS:** Swift color/spacing constants or asset catalogs83- **Android:** XML resources or Compose theme84- **Shared source of truth:** JSON or YAML token definitions8586## Output Format8788```markdown89# Design System Architecture9091## Token Hierarchy9293### Primitive Tokens94| Category | Token | Value |95|----------|-------|-------|96| Color | blue-500 | #3B82F6 |97| Spacing | space-4 | 16px |98| Type | text-base | 16px/24px |99100### Semantic Tokens101| Token | Light | Dark | Usage |102|-------|-------|------|-------|103| surface-primary | white | gray-900 | Main background |104| text-primary | gray-900 | gray-50 | Body text |105| interactive-primary | blue-500 | blue-400 | Buttons, links |106107### Component Tokens108| Component | Token | Maps To |109|-----------|-------|---------|110| Button (primary) | button-bg | interactive-primary |111| Button (primary) | button-text | text-inverse |112113## Theme Switching114[Implementation approach — CSS class, media query, user preference]115116## File Structure117```118tokens/119 primitives.json120 semantic-light.json121 semantic-dark.json122 components.json123```124125## Migration Plan126[Steps to migrate from current approach to token-based system]127```128129## Quality Checks130131- [ ] All existing hardcoded values can be mapped to tokens132- [ ] Semantic tokens cover all current UI needs without gaps133- [ ] Dark mode token overrides maintain WCAG AA contrast134- [ ] Token naming is consistent and predictable135- [ ] The migration path doesn't require a big-bang rewrite136- [ ] Cross-platform strategy has a single source of truth137138## Evolution Notes139<!-- Observations appended after each use -->