riazmo's picture
docs: rewrite README for v3.2 + add Figma plugin to repo
d69ae21
---
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.
![Version](https://img.shields.io/badge/version-3.2-blue) ![Tests](https://img.shields.io/badge/tests-148%20passing-brightgreen) ![Cost](https://img.shields.io/badge/cost-%240.003%2Frun-orange) ![License](https://img.shields.io/badge/license-MIT-green)
## 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.