Spaces:
Runtime error
Runtime error
| title: Design System Automation | |
| emoji: π¨ | |
| colorFrom: purple | |
| colorTo: blue | |
| sdk: docker | |
| pinned: false | |
| license: mit | |
| # Design System Automation | |
| > Extract, analyze, and improve any website's design system β then drop it into Figma as a visual spec. In 15 minutes, not 5 days. | |
|     | |
| ## What It Does | |
| Point it at any live website. The system: | |
| 1. **Extracts** every design token (colors, typography, spacing, shadows, radius) from 8 sources | |
| 2. **Classifies** colors deterministically using CSS evidence (815 lines, no AI) | |
| 3. **Audits** accessibility (WCAG AA/AAA), type scale consistency, spacing grid alignment | |
| 4. **Analyzes** with 4 specialized AI agents β brand identification, industry benchmarking, best practices, synthesis | |
| 5. **Exports** W3C DTCG-compliant JSON | |
| 6. **Generates** a full Figma visual spec via custom plugin | |
| **Cost:** ~$0.003 per analysis. The free rule-based layers do 90% of the work. | |
| ## Architecture: Three Layers | |
| ``` | |
| Layer 1 β Extraction + Normalization (Free, ~90s) | |
| Playwright visits site at 2 viewports, extracts from 8 CSS sources | |
| Normalizer: dedup colors, parse radius/shadows, name with numeric shades | |
| Layer 2 β Classification + Rule Engine (Free, <1s) | |
| Color Classifier: CSS evidence -> category -> token name (deterministic) | |
| Rule Engine: WCAG contrast, type scale ratio, spacing grid, color stats | |
| Layer 3 β 4 AI Agents (~$0.003) | |
| AURORA: Brand color advisor (Qwen 72B) | |
| ATLAS: Industry benchmark advisor (Llama 3.3 70B) | |
| SENTINEL: Best practices auditor (Qwen 72B) | |
| NEXUS: Head synthesizer (Llama 3.3 70B) | |
| ``` | |
| AI agents are **advisory only** β a strict naming authority chain ensures deterministic, reproducible output: | |
| 1. Color Classifier (primary) β 2. AURORA LLM (secondary, semantic roles only) β 3. Normalizer (fallback) | |
| ## Quick Start | |
| ### Run the App | |
| ```bash | |
| git clone https://github.com/hiriazmo/design-system-automation.git | |
| cd design-system-automation | |
| python -m venv venv | |
| source venv/bin/activate | |
| pip install -r requirements.txt | |
| playwright install chromium | |
| cp config/.env.example config/.env | |
| # Add your HF_TOKEN in .env | |
| python app.py | |
| ``` | |
| Open `http://localhost:7860` | |
| ### Or Use the Hosted Version | |
| **[Live Demo on HuggingFace Spaces](https://huggingface.co/spaces/riazmo/Design-System-Automation)** | |
| ### Import to Figma | |
| 1. Extract tokens from any website using the app | |
| 2. Download the DTCG JSON | |
| 3. Load the [Figma plugin](./figma-plugin/) into Figma | |
| 4. Upload JSON β get Variables, Styles, and a Visual Spec page | |
| See the [Figma Plugin README](./figma-plugin/README.md) for setup instructions. | |
| ## The Workflow | |
| ``` | |
| Enter URL β Extract AS-IS β Download JSON β Import to Figma (Visual Spec) | |
| β | |
| Review AS-IS spec | |
| β | |
| Run AI Analysis β Accept/Reject suggestions | |
| β | |
| Export TO-BE JSON β Import to Figma | |
| β | |
| Compare AS-IS vs TO-BE side by side | |
| ``` | |
| ## Output Format (W3C DTCG v1) | |
| ```json | |
| { | |
| "color": { | |
| "brand": { | |
| "primary": { | |
| "$type": "color", | |
| "$value": "#005aa3", | |
| "$description": "[classifier] brand: primary_action", | |
| "$extensions": { | |
| "com.design-system-automation": { | |
| "frequency": 47, | |
| "confidence": "high", | |
| "category": "brand" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "radius": { | |
| "md": { "$type": "dimension", "$value": "8px" } | |
| }, | |
| "shadow": { | |
| "sm": { | |
| "$type": "shadow", | |
| "$value": { | |
| "offsetX": "0px", | |
| "offsetY": "2px", | |
| "blur": "8px", | |
| "spread": "0px", | |
| "color": "#00000026" | |
| } | |
| } | |
| } | |
| } | |
| ``` | |
| Compatible with Tokens Studio, Style Dictionary v4, and any DTCG-compliant tool. | |
| ## Project Structure | |
| ``` | |
| design-system-automation/ | |
| βββ app.py # Main Gradio application (~5000 lines) | |
| βββ figma-plugin/ # Figma plugin for token import + visual spec | |
| β βββ manifest.json | |
| β βββ src/code.js # Plugin logic (v7) | |
| β βββ ui/ui.html # Plugin UI | |
| βββ agents/ | |
| β βββ crawler.py # Page discovery | |
| β βββ extractor.py # 8-source CSS extraction (Playwright) | |
| β βββ firecrawl_extractor.py # Deep CSS extraction (Firecrawl) | |
| β βββ normalizer.py # Token dedup, naming, normalization | |
| β βββ llm_agents.py # AURORA, ATLAS, SENTINEL, NEXUS | |
| β βββ ... | |
| βββ core/ | |
| β βββ color_classifier.py # Deterministic color classification (815 lines) | |
| β βββ rule_engine.py # WCAG, type scale, spacing grid analysis | |
| β βββ color_utils.py # Color math, contrast, ramp generation | |
| β βββ token_schema.py # Pydantic models (DTCG compliant) | |
| β βββ ... | |
| βββ config/ | |
| β βββ .env.example # Environment template | |
| β βββ settings.py # Configuration | |
| β βββ agents.yaml # Agent configurations | |
| βββ tests/ # 148 tests (82 deterministic + 27 agent + 35 live + 4 pipeline) | |
| βββ docs/ # Medium article, LinkedIn post, image guide | |
| ``` | |
| ## Tech Stack | |
| | Component | Technology | | |
| |-----------|-----------| | |
| | UI | Gradio | | |
| | Extraction | Playwright + Firecrawl | | |
| | Classification | Custom rule-based (Python) | | |
| | AI Agents | Qwen 72B + Llama 3.3 70B via HuggingFace Inference API | | |
| | Hosting | HuggingFace Spaces (Docker) | | |
| | Figma | Custom plugin (Variables API + Styles API) | | |
| | Token Format | W3C DTCG v1 (October 2025) | | |
| | Tests | pytest β 148 passing | | |
| ## Tests | |
| ```bash | |
| python -m pytest tests/ -q | |
| ``` | |
| ## License | |
| MIT | |
| --- | |
| Built by [Riaz](https://medium.com/@designwithriaz) β a UX Design Manager automating design systems with AI. | |