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-architecture3description: Token hierarchy, theming strategy, and cross-platform consistency4---56# Design System Architecture78## Purpose910Design a token-based design system architecture, including primitive → semantic → component token hierarchy, theming strategy (dark/light mode), and cross-platform implementation plan.1112## Inputs1314- Existing styling approach (Tailwind, CSS modules, styled-components, etc.)15- Target platforms (web, iOS, Android, cross-platform)16- Brand guidelines or existing color palette17- Current component inventory18- Theming requirements (dark mode, high contrast, brand variations)1920## Process2122### Step 1: Audit Current State2324Review the existing styling approach:25- How are colors, spacing, and typography defined today?26- Are there hardcoded values scattered across components?27- Is there an existing design system or component library?28- What CSS methodology is used (utility-first, BEM, CSS-in-JS)?2930### Step 2: Define Primitive Tokens3132Establish the raw values that form the foundation:33- **Color primitives:** Named palette (blue-50 through blue-900, gray scale, semantic colors)34- **Spacing scale:** 4px base unit → 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 6435- **Type scale:** Size ramp with corresponding line heights and letter spacing36- **Border radius:** Small (4px), medium (8px), large (16px), full (9999px)37- **Shadow/elevation:** Subtle, medium, prominent38- **Duration:** Fast (100ms), normal (200ms), slow (300ms)3940### Step 3: Define Semantic Tokens4142Map primitives to semantic meaning:43- **Surface:** surface-primary, surface-secondary, surface-elevated44- **Text:** text-primary, text-secondary, text-muted, text-inverse45- **Border:** border-default, border-strong, border-focus46- **Interactive:** interactive-primary, interactive-hover, interactive-pressed47- **Status:** status-success, status-warning, status-error, status-info48- **Spacing:** space-xs, space-sm, space-md, space-lg, space-xl4950### Step 4: Define Component Tokens5152Map semantic tokens to component-specific values:53- **Button:** button-bg, button-text, button-border, button-radius54- **Input:** input-bg, input-border, input-focus-ring, input-text55- **Card:** card-bg, card-border, card-shadow, card-radius, card-padding5657### Step 5: Design Theme Architecture5859Define how themes override token values:60- **Light theme:** Default token assignments61- **Dark theme:** Which semantic tokens change, which stay the same62- **High contrast:** Increased border widths, higher contrast ratios63- **Implementation:** CSS custom properties, Tailwind config, or platform-specific theming6465### Step 6: Cross-Platform Strategy6667If multiple platforms:68- **Token format:** Use Style Dictionary or similar to generate platform-specific output69- **Web:** CSS custom properties or Tailwind theme config70- **iOS:** Swift color/spacing constants or asset catalogs71- **Android:** XML resources or Compose theme72- **Shared source of truth:** JSON or YAML token definitions7374## Output Format7576```markdown77# Design System Architecture7879## Token Hierarchy8081### Primitive Tokens82| Category | Token | Value |83|----------|-------|-------|84| Color | blue-500 | #3B82F6 |85| Spacing | space-4 | 16px |86| Type | text-base | 16px/24px |8788### Semantic Tokens89| Token | Light | Dark | Usage |90|-------|-------|------|-------|91| surface-primary | white | gray-900 | Main background |92| text-primary | gray-900 | gray-50 | Body text |93| interactive-primary | blue-500 | blue-400 | Buttons, links |9495### Component Tokens96| Component | Token | Maps To |97|-----------|-------|---------|98| Button (primary) | button-bg | interactive-primary |99| Button (primary) | button-text | text-inverse |100101## Theme Switching102[Implementation approach — CSS class, media query, user preference]103104## File Structure105```106tokens/107 primitives.json108 semantic-light.json109 semantic-dark.json110 components.json111```112113## Migration Plan114[Steps to migrate from current approach to token-based system]115```116117## Quality Checks118119- [ ] All existing hardcoded values can be mapped to tokens120- [ ] Semantic tokens cover all current UI needs without gaps121- [ ] Dark mode token overrides maintain WCAG AA contrast122- [ ] Token naming is consistent and predictable123- [ ] The migration path doesn't require a big-bang rewrite124- [ ] Cross-platform strategy has a single source of truth125126## Evolution Notes127<!-- Observations appended after each use -->