# Intelligent Figma Sync Architecture > Deep research synthesis from Figmagic, Design Tokens plugin, Figma MCP patterns, and Gemini 3 Pro analysis. ## Executive Summary DSS intelligent Figma sync should implement a **4-layer pipeline** architecture with hybrid token extraction, W3C token format compliance, intelligent caching, and strict design contract enforcement. ## Architecture Overview ``` ┌─────────────────────────────────────────────────────────────┐ │ FIGMA API LAYER │ ├─────────────────────────────────────────────────────────────┤ │ GET /files/{key} → File metadata, lastModified │ │ GET /files/{key}/variables → Variables + collections │ │ GET /files/{key}/styles → Color, text, effect styles │ │ GET /files/{key}/nodes → Component structure │ │ GET /images/{key} → Component thumbnails │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ VALIDATION LAYER (NEW) │ ├─────────────────────────────────────────────────────────────┤ │ DesignLinter: │ │ - Reject components without proper variant props │ │ - Enforce naming conventions (no "Property 1", "Frame X")│ │ - Mark non-compliant as "Raw" (skip code gen) │ │ - Generate lint report for designers │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ EXTRACTION LAYER │ ├─────────────────────────────────────────────────────────────┤ │ VariableExtractor → semantic tokens (color, spacing) │ │ StyleExtractor → typography, effects, grids │ │ ComponentExtractor → component sets, variants, props │ │ AssetExtractor → icons, images (optional) │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ TRANSLATION LAYER │ ├─────────────────────────────────────────────────────────────┤ │ FigmaToDSSTranslator: │ │ - Maps Figma naming → DSS canonical names │ │ - Preserves variable REFERENCES (not resolved values) │ │ - Normalizes units (px → rem where appropriate) │ │ - Applies merge strategies (PREFER_FIGMA, LAST, etc) │ │ - Outputs W3C Design Token format │ │ - Separates Visual Props from Interaction States │ └─────────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────────┐ │ OUTPUT LAYER │ ├─────────────────────────────────────────────────────────────┤ │ TokenWriter → .dss/data/_system/tokens/figma-tokens.json│ │ ComponentWriter→ .dss/components/figma-registry.json │ │ StoryGenerator → admin-ui/src/stories/Components/*.stories │ │ CSSGenerator → .dss/themes/figma.css │ └─────────────────────────────────────────────────────────────┘ ``` ## Key Architectural Decisions ### 1. Hybrid Token Extraction Strategy | Source | Token Types | Priority | |--------|-------------|----------| | Variables | Semantic colors, spacing, breakpoints | Primary | | Styles | Typography, effects, grids | Secondary | | Components | UI registry, variants | Tertiary | **Rationale**: Variables provide modern theming with modes (light/dark), while Styles capture typography which isn't fully available in Variables yet. ### 2. W3C Design Token Format ```json { "$schema": "https://design-tokens.org/schema.json", "color": { "primary": { "$value": "{color.blue.600}", "$type": "color", "$extensions": { "figma": {"styleId": "S:abc123", "source": "variables"} } } } } ``` **Critical**: Preserve token **references** (`{color.blue.600}`), not resolved values (`#0066cc`). This enables: - Multi-theme switching (Skins) - Style Dictionary transformation - Proper CSS variable generation ### 3. Component Variant Classification ```python VARIANT_CLASSIFICATION = { # Visual Props → React props / Storybook args "visual_props": ["Size", "Variant", "Roundness", "Type", "Icon"], # Interaction States → CSS pseudo-classes (NOT React props) "interaction_states": ["State", "Hover", "Focused", "Pressed", "Disabled"], # Boolean toggles → React boolean props "boolean_props": ["Checked?", "Selected", "Open", "Expanded"] } ``` **Example Mapping**: - Figma: `Button / Primary / Hover / Large` - Code: `