riazmo Claude Opus 4.6 commited on
Commit
d69ae21
Β·
1 Parent(s): d969659

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>

Files changed (1) hide show
  1. README.md +131 -169
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Design System Automation v3
3
  emoji: 🎨
4
  colorFrom: purple
5
  colorTo: blue
@@ -8,226 +8,188 @@ pinned: false
8
  license: mit
9
  ---
10
 
11
- # Design System Automation v3
12
 
13
- > 🎨 A semi-automated, human-in-the-loop agentic system that reverse-engineers design systems from live websites.
14
 
15
- ## 🎯 What It Does
16
 
17
- When you have a website but no design system documentation (common when the original Sketch/Figma files are lost), this tool helps you:
18
 
19
- 1. **Crawl** your website to discover pages
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
- ## 🧠 Philosophy
 
 
 
 
 
26
 
27
- This is **not a magic button** β€” it's a design-aware co-pilot.
28
 
29
- - **Agents propose β†’ Humans decide**
30
- - **Every action is visible, reversible, and previewed**
31
- - **No irreversible automation**
32
-
33
- ## πŸ—οΈ Architecture
34
 
35
  ```
36
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
37
- β”‚ TECH STACK β”‚
38
- β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
39
- β”‚ Frontend: Gradio (interactive UI with live preview) β”‚
40
- β”‚ Orchestration: LangGraph (agent workflow management) β”‚
41
- β”‚ Models: Claude API (reasoning) + Rule-based β”‚
42
- β”‚ Browser: Playwright (crawling & extraction) β”‚
43
- β”‚ Hosting: Hugging Face Spaces β”‚
44
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 
 
 
 
45
  ```
46
 
47
- ### Agent Personas
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
- ### Prerequisites
59
 
60
- - Python 3.11+
61
- - Node.js (for some dependencies)
62
-
63
- ### Installation
64
 
65
  ```bash
66
- # Clone the repository
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 # or `venv\Scripts\activate` on Windows
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
- # Edit .env and add your ANTHROPIC_API_KEY
83
- ```
84
 
85
- ### Running
86
-
87
- ```bash
88
  python app.py
89
  ```
90
 
91
- Open `http://localhost:7860` in your browser.
92
-
93
- ## πŸ“– Usage Guide
94
 
95
- ### Stage 1: Discovery
96
 
97
- 1. Enter your website URL (e.g., `https://example.com`)
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
- ### Stage 2: Extraction
103
 
104
- 1. Choose viewport (Desktop 1440px or Mobile 375px)
105
- 2. Click "Extract Tokens"
106
- 3. Review extracted:
107
- - **Colors**: With frequency, context, and AA compliance
108
- - **Typography**: Font families, sizes, weights
109
- - **Spacing**: Values with 8px grid fit indicators
110
- 4. Accept or reject individual tokens
111
 
112
- ### Stage 3: Export
113
 
114
- 1. Review final token set
115
- 2. Export as JSON
116
- 3. Import into Figma via Tokens Studio or your plugin
117
-
118
- ## πŸ“ Project Structure
119
 
120
  ```
121
- design-system-automation/
122
- β”œβ”€β”€ app.py # Main Gradio application
123
- β”œβ”€β”€ requirements.txt
124
- β”œβ”€β”€ README.md
125
- β”‚
126
- β”œβ”€β”€ config/
127
- β”‚ β”œβ”€β”€ .env.example # Environment template
128
- β”‚ β”œβ”€β”€ agents.yaml # Agent personas & settings
129
- β”‚ └── settings.py # Configuration loader
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
- ## πŸ”§ Configuration
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
- "metadata": {
196
- "source_url": "https://example.com",
197
- "version": "v1-recovered",
198
- "viewport": "desktop"
199
- },
200
- "colors": {
201
- "primary-500": {
202
- "value": "#007bff",
203
- "source": "detected",
204
- "contrast_white": 4.5
 
 
 
 
205
  }
206
  },
207
- "typography": {
208
- "heading-lg": {
209
- "fontFamily": "Inter",
210
- "fontSize": "24px",
211
- "fontWeight": 700
212
- }
213
  },
214
- "spacing": {
215
- "md": {
216
- "value": "16px",
217
- "source": "detected"
 
 
 
 
 
 
218
  }
219
  }
220
  }
221
  ```
222
 
223
- ## 🀝 Contributing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
- Contributions are welcome! Please read the contribution guidelines first.
 
 
226
 
227
- ## πŸ“„ License
228
 
229
  MIT
230
 
231
  ---
232
 
233
- Built with ❀️ for designers who've lost their source files.
 
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
+ ![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)
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.