Spaces:
Runtime error
Runtime error
docs: rewrite README for v3.2 + add Figma plugin to repo
Browse files- Complete README rewrite: 3-layer architecture, DTCG output format,
workflow diagram, color classifier, AI agents, tech stack, tests
- Remove outdated references (Claude API, old agent names, legacy format)
- Add Figma plugin section with link to figma-plugin/ README
- Add badges: version, tests, cost, license
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title: Design System Automation
|
| 3 |
emoji: π¨
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
|
@@ -8,226 +8,188 @@ pinned: false
|
|
| 8 |
license: mit
|
| 9 |
---
|
| 10 |
|
| 11 |
-
# Design System Automation
|
| 12 |
|
| 13 |
-
>
|
| 14 |
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
2. **Extract** design tokens (colors, typography, spacing, shadows)
|
| 21 |
-
3. **Review** and validate extracted tokens with visual previews
|
| 22 |
-
4. **Upgrade** your system with modern best practices (optional)
|
| 23 |
-
5. **Export** production-ready JSON tokens for Figma/code
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
- **Every action is visible, reversible, and previewed**
|
| 31 |
-
- **No irreversible automation**
|
| 32 |
-
|
| 33 |
-
## ποΈ Architecture
|
| 34 |
|
| 35 |
```
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
| Agent | Persona | Job |
|
| 50 |
-
|-------|---------|-----|
|
| 51 |
-
| **Agent 1** | Design Archaeologist | Discover pages, extract raw tokens |
|
| 52 |
-
| **Agent 2** | Design System Librarian | Normalize, dedupe, structure tokens |
|
| 53 |
-
| **Agent 3** | Senior DS Architect | Recommend upgrades (type scales, spacing, a11y) |
|
| 54 |
-
| **Agent 4** | Automation Engineer | Generate final JSON for Figma/code |
|
| 55 |
-
|
| 56 |
-
## π Quick Start
|
| 57 |
|
| 58 |
-
##
|
| 59 |
|
| 60 |
-
|
| 61 |
-
- Node.js (for some dependencies)
|
| 62 |
-
|
| 63 |
-
### Installation
|
| 64 |
|
| 65 |
```bash
|
| 66 |
-
|
| 67 |
-
git clone <repo-url>
|
| 68 |
cd design-system-automation
|
| 69 |
|
| 70 |
-
# Create virtual environment
|
| 71 |
python -m venv venv
|
| 72 |
-
source venv/bin/activate
|
| 73 |
|
| 74 |
-
# Install dependencies
|
| 75 |
pip install -r requirements.txt
|
| 76 |
-
|
| 77 |
-
# Install Playwright browsers
|
| 78 |
playwright install chromium
|
| 79 |
|
| 80 |
-
# Copy environment file
|
| 81 |
cp config/.env.example config/.env
|
| 82 |
-
#
|
| 83 |
-
```
|
| 84 |
|
| 85 |
-
### Running
|
| 86 |
-
|
| 87 |
-
```bash
|
| 88 |
python app.py
|
| 89 |
```
|
| 90 |
|
| 91 |
-
Open `http://localhost:7860`
|
| 92 |
-
|
| 93 |
-
## π Usage Guide
|
| 94 |
|
| 95 |
-
###
|
| 96 |
|
| 97 |
-
|
| 98 |
-
2. Click "Discover Pages"
|
| 99 |
-
3. Review discovered pages and select which to extract from
|
| 100 |
-
4. Ensure you have a mix of page types (homepage, listing, detail, etc.)
|
| 101 |
|
| 102 |
-
###
|
| 103 |
|
| 104 |
-
1.
|
| 105 |
-
2.
|
| 106 |
-
3.
|
| 107 |
-
|
| 108 |
-
- **Typography**: Font families, sizes, weights
|
| 109 |
-
- **Spacing**: Values with 8px grid fit indicators
|
| 110 |
-
4. Accept or reject individual tokens
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
| 115 |
-
2. Export as JSON
|
| 116 |
-
3. Import into Figma via Tokens Studio or your plugin
|
| 117 |
-
|
| 118 |
-
## π Project Structure
|
| 119 |
|
| 120 |
```
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
β
|
| 131 |
-
βββ agents/
|
| 132 |
-
β βββ state.py # LangGraph state definitions
|
| 133 |
-
β βββ graph.py # Workflow orchestration
|
| 134 |
-
β βββ crawler.py # Agent 1: Page discovery
|
| 135 |
-
β βββ extractor.py # Agent 1: Token extraction
|
| 136 |
-
β βββ normalizer.py # Agent 2: Normalization
|
| 137 |
-
β βββ advisor.py # Agent 3: Best practices
|
| 138 |
-
β βββ generator.py # Agent 4: JSON generation
|
| 139 |
-
β
|
| 140 |
-
βββ core/
|
| 141 |
-
β βββ token_schema.py # Pydantic data models
|
| 142 |
-
β βββ color_utils.py # Color analysis utilities
|
| 143 |
-
β
|
| 144 |
-
βββ ui/
|
| 145 |
-
β βββ (Gradio components)
|
| 146 |
-
β
|
| 147 |
-
βββ docs/
|
| 148 |
-
βββ CONTEXT.md # Context file for AI assistance
|
| 149 |
```
|
| 150 |
|
| 151 |
-
##
|
| 152 |
-
|
| 153 |
-
### Environment Variables
|
| 154 |
-
|
| 155 |
-
```env
|
| 156 |
-
# Required
|
| 157 |
-
ANTHROPIC_API_KEY=your_key_here
|
| 158 |
-
|
| 159 |
-
# Optional
|
| 160 |
-
DEBUG=false
|
| 161 |
-
LOG_LEVEL=INFO
|
| 162 |
-
BROWSER_HEADLESS=true
|
| 163 |
-
```
|
| 164 |
-
|
| 165 |
-
### Agent Configuration
|
| 166 |
-
|
| 167 |
-
Agent personas and behavior are defined in `config/agents.yaml`. This includes:
|
| 168 |
-
|
| 169 |
-
- Extraction targets (colors, typography, spacing)
|
| 170 |
-
- Naming conventions
|
| 171 |
-
- Confidence thresholds
|
| 172 |
-
- Upgrade options
|
| 173 |
-
|
| 174 |
-
## π οΈ Development
|
| 175 |
-
|
| 176 |
-
### Running Tests
|
| 177 |
-
|
| 178 |
-
```bash
|
| 179 |
-
pytest tests/
|
| 180 |
-
```
|
| 181 |
-
|
| 182 |
-
### Adding New Features
|
| 183 |
-
|
| 184 |
-
1. Update token schema in `core/token_schema.py`
|
| 185 |
-
2. Add agent logic in `agents/`
|
| 186 |
-
3. Update UI in `app.py`
|
| 187 |
-
4. Update `docs/CONTEXT.md` for AI assistance
|
| 188 |
-
|
| 189 |
-
## π¦ Output Format
|
| 190 |
-
|
| 191 |
-
Tokens are exported in a platform-agnostic JSON format:
|
| 192 |
|
| 193 |
```json
|
| 194 |
{
|
| 195 |
-
"
|
| 196 |
-
"
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
}
|
| 206 |
},
|
| 207 |
-
"
|
| 208 |
-
"
|
| 209 |
-
"fontFamily": "Inter",
|
| 210 |
-
"fontSize": "24px",
|
| 211 |
-
"fontWeight": 700
|
| 212 |
-
}
|
| 213 |
},
|
| 214 |
-
"
|
| 215 |
-
"
|
| 216 |
-
"
|
| 217 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
}
|
| 219 |
}
|
| 220 |
}
|
| 221 |
```
|
| 222 |
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
|
|
|
|
|
|
|
| 226 |
|
| 227 |
-
##
|
| 228 |
|
| 229 |
MIT
|
| 230 |
|
| 231 |
---
|
| 232 |
|
| 233 |
-
Built
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Design System Automation
|
| 3 |
emoji: π¨
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
|
|
|
| 8 |
license: mit
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Design System Automation
|
| 12 |
|
| 13 |
+
> Extract, analyze, and improve any website's design system β then drop it into Figma as a visual spec. In 15 minutes, not 5 days.
|
| 14 |
|
| 15 |
+
   
|
| 16 |
|
| 17 |
+
## What It Does
|
| 18 |
|
| 19 |
+
Point it at any live website. The system:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
1. **Extracts** every design token (colors, typography, spacing, shadows, radius) from 8 sources
|
| 22 |
+
2. **Classifies** colors deterministically using CSS evidence (815 lines, no AI)
|
| 23 |
+
3. **Audits** accessibility (WCAG AA/AAA), type scale consistency, spacing grid alignment
|
| 24 |
+
4. **Analyzes** with 4 specialized AI agents β brand identification, industry benchmarking, best practices, synthesis
|
| 25 |
+
5. **Exports** W3C DTCG-compliant JSON
|
| 26 |
+
6. **Generates** a full Figma visual spec via custom plugin
|
| 27 |
|
| 28 |
+
**Cost:** ~$0.003 per analysis. The free rule-based layers do 90% of the work.
|
| 29 |
|
| 30 |
+
## Architecture: Three Layers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
```
|
| 33 |
+
Layer 1 β Extraction + Normalization (Free, ~90s)
|
| 34 |
+
Playwright visits site at 2 viewports, extracts from 8 CSS sources
|
| 35 |
+
Normalizer: dedup colors, parse radius/shadows, name with numeric shades
|
| 36 |
+
|
| 37 |
+
Layer 2 β Classification + Rule Engine (Free, <1s)
|
| 38 |
+
Color Classifier: CSS evidence -> category -> token name (deterministic)
|
| 39 |
+
Rule Engine: WCAG contrast, type scale ratio, spacing grid, color stats
|
| 40 |
+
|
| 41 |
+
Layer 3 β 4 AI Agents (~$0.003)
|
| 42 |
+
AURORA: Brand color advisor (Qwen 72B)
|
| 43 |
+
ATLAS: Industry benchmark advisor (Llama 3.3 70B)
|
| 44 |
+
SENTINEL: Best practices auditor (Qwen 72B)
|
| 45 |
+
NEXUS: Head synthesizer (Llama 3.3 70B)
|
| 46 |
```
|
| 47 |
|
| 48 |
+
AI agents are **advisory only** β a strict naming authority chain ensures deterministic, reproducible output:
|
| 49 |
+
1. Color Classifier (primary) β 2. AURORA LLM (secondary, semantic roles only) β 3. Normalizer (fallback)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
## Quick Start
|
| 52 |
|
| 53 |
+
### Run the App
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
```bash
|
| 56 |
+
git clone https://github.com/hiriazmo/design-system-automation.git
|
|
|
|
| 57 |
cd design-system-automation
|
| 58 |
|
|
|
|
| 59 |
python -m venv venv
|
| 60 |
+
source venv/bin/activate
|
| 61 |
|
|
|
|
| 62 |
pip install -r requirements.txt
|
|
|
|
|
|
|
| 63 |
playwright install chromium
|
| 64 |
|
|
|
|
| 65 |
cp config/.env.example config/.env
|
| 66 |
+
# Add your HF_TOKEN in .env
|
|
|
|
| 67 |
|
|
|
|
|
|
|
|
|
|
| 68 |
python app.py
|
| 69 |
```
|
| 70 |
|
| 71 |
+
Open `http://localhost:7860`
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
### Or Use the Hosted Version
|
| 74 |
|
| 75 |
+
**[Live Demo on HuggingFace Spaces](https://huggingface.co/spaces/riazmo/Design-System-Automation)**
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
### Import to Figma
|
| 78 |
|
| 79 |
+
1. Extract tokens from any website using the app
|
| 80 |
+
2. Download the DTCG JSON
|
| 81 |
+
3. Load the [Figma plugin](./figma-plugin/) into Figma
|
| 82 |
+
4. Upload JSON β get Variables, Styles, and a Visual Spec page
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
See the [Figma Plugin README](./figma-plugin/README.md) for setup instructions.
|
| 85 |
|
| 86 |
+
## The Workflow
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
```
|
| 89 |
+
Enter URL β Extract AS-IS β Download JSON β Import to Figma (Visual Spec)
|
| 90 |
+
β
|
| 91 |
+
Review AS-IS spec
|
| 92 |
+
β
|
| 93 |
+
Run AI Analysis β Accept/Reject suggestions
|
| 94 |
+
β
|
| 95 |
+
Export TO-BE JSON β Import to Figma
|
| 96 |
+
β
|
| 97 |
+
Compare AS-IS vs TO-BE side by side
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
```
|
| 99 |
|
| 100 |
+
## Output Format (W3C DTCG v1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
```json
|
| 103 |
{
|
| 104 |
+
"color": {
|
| 105 |
+
"brand": {
|
| 106 |
+
"primary": {
|
| 107 |
+
"$type": "color",
|
| 108 |
+
"$value": "#005aa3",
|
| 109 |
+
"$description": "[classifier] brand: primary_action",
|
| 110 |
+
"$extensions": {
|
| 111 |
+
"com.design-system-automation": {
|
| 112 |
+
"frequency": 47,
|
| 113 |
+
"confidence": "high",
|
| 114 |
+
"category": "brand"
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
}
|
| 119 |
},
|
| 120 |
+
"radius": {
|
| 121 |
+
"md": { "$type": "dimension", "$value": "8px" }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
},
|
| 123 |
+
"shadow": {
|
| 124 |
+
"sm": {
|
| 125 |
+
"$type": "shadow",
|
| 126 |
+
"$value": {
|
| 127 |
+
"offsetX": "0px",
|
| 128 |
+
"offsetY": "2px",
|
| 129 |
+
"blur": "8px",
|
| 130 |
+
"spread": "0px",
|
| 131 |
+
"color": "#00000026"
|
| 132 |
+
}
|
| 133 |
}
|
| 134 |
}
|
| 135 |
}
|
| 136 |
```
|
| 137 |
|
| 138 |
+
Compatible with Tokens Studio, Style Dictionary v4, and any DTCG-compliant tool.
|
| 139 |
+
|
| 140 |
+
## Project Structure
|
| 141 |
+
|
| 142 |
+
```
|
| 143 |
+
design-system-automation/
|
| 144 |
+
βββ app.py # Main Gradio application (~5000 lines)
|
| 145 |
+
βββ figma-plugin/ # Figma plugin for token import + visual spec
|
| 146 |
+
β βββ manifest.json
|
| 147 |
+
β βββ src/code.js # Plugin logic (v7)
|
| 148 |
+
β βββ ui/ui.html # Plugin UI
|
| 149 |
+
βββ agents/
|
| 150 |
+
β βββ crawler.py # Page discovery
|
| 151 |
+
β βββ extractor.py # 8-source CSS extraction (Playwright)
|
| 152 |
+
β βββ firecrawl_extractor.py # Deep CSS extraction (Firecrawl)
|
| 153 |
+
β βββ normalizer.py # Token dedup, naming, normalization
|
| 154 |
+
β βββ llm_agents.py # AURORA, ATLAS, SENTINEL, NEXUS
|
| 155 |
+
β βββ ...
|
| 156 |
+
βββ core/
|
| 157 |
+
β βββ color_classifier.py # Deterministic color classification (815 lines)
|
| 158 |
+
β βββ rule_engine.py # WCAG, type scale, spacing grid analysis
|
| 159 |
+
β βββ color_utils.py # Color math, contrast, ramp generation
|
| 160 |
+
β βββ token_schema.py # Pydantic models (DTCG compliant)
|
| 161 |
+
β βββ ...
|
| 162 |
+
βββ config/
|
| 163 |
+
β βββ .env.example # Environment template
|
| 164 |
+
β βββ settings.py # Configuration
|
| 165 |
+
β βββ agents.yaml # Agent configurations
|
| 166 |
+
βββ tests/ # 148 tests (82 deterministic + 27 agent + 35 live + 4 pipeline)
|
| 167 |
+
βββ docs/ # Medium article, LinkedIn post, image guide
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
## Tech Stack
|
| 171 |
+
|
| 172 |
+
| Component | Technology |
|
| 173 |
+
|-----------|-----------|
|
| 174 |
+
| UI | Gradio |
|
| 175 |
+
| Extraction | Playwright + Firecrawl |
|
| 176 |
+
| Classification | Custom rule-based (Python) |
|
| 177 |
+
| AI Agents | Qwen 72B + Llama 3.3 70B via HuggingFace Inference API |
|
| 178 |
+
| Hosting | HuggingFace Spaces (Docker) |
|
| 179 |
+
| Figma | Custom plugin (Variables API + Styles API) |
|
| 180 |
+
| Token Format | W3C DTCG v1 (October 2025) |
|
| 181 |
+
| Tests | pytest β 148 passing |
|
| 182 |
+
|
| 183 |
+
## Tests
|
| 184 |
|
| 185 |
+
```bash
|
| 186 |
+
python -m pytest tests/ -q
|
| 187 |
+
```
|
| 188 |
|
| 189 |
+
## License
|
| 190 |
|
| 191 |
MIT
|
| 192 |
|
| 193 |
---
|
| 194 |
|
| 195 |
+
Built by [Riaz](https://medium.com/@designwithriaz) β a UX Design Manager automating design systems with AI.
|