| name | figma-reference-architecture |
| description | Reference architecture for production Figma API integrations.
Use when designing a new Figma integration, planning project structure,
or establishing patterns for design-to-code pipelines.
Trigger with phrases like "figma architecture", "figma project structure",
"figma integration design", "figma best practices layout".
|
| allowed-tools | Read, Grep |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","figma"] |
| compatibility | Designed for Claude Code |
Figma Reference Architecture
Overview
Production-ready architecture for Figma REST API integrations. Covers the three most common use cases: design token pipelines, asset export systems, and webhook-driven automation.
Prerequisites
- Understanding of Figma REST API endpoints
- TypeScript project setup
- Decision on deployment platform
Instructions
Step 1: Project Structure
figma-integration/
โโโ src/
โ โโโ figma/
โ โ โโโ client.ts # Typed REST API wrapper
โ โ โโโ types.ts # Figma API response types
โ โ โโโ errors.ts # FigmaApiError, FigmaRateLimitError
โ โ โโโ cache.ts # LRU cache for API responses
โ โ โโโ walker.ts # Node tree traversal utilities
โ โโโ services/
โ โ โโโ token-extractor.ts # Design token extraction
โ โ โโโ asset-exporter.ts # Image/icon export pipeline
โ โ โโโ comment-syncer.ts # Comment sync to Slack/Jira
โ โ โโโ variable-syncer.ts # Variables API sync (Enterprise)
โ โโโ webhooks/
โ โ โโโ handler.ts # Webhook event router
โ โ โโโ verify.ts # Passcode verification
โ โ โโโ processors/
โ โ โโโ file-update.ts # FILE_UPDATE handler
โ โ โโโ comment.ts # FILE_COMMENT handler
โ โ โโโ library.ts # LIBRARY_PUBLISH handler
โ โโโ api/
โ โ โโโ health.ts # Health check endpoint
โ โ โโโ tokens.ts # Token API endpoint
โ โ โโโ assets.ts # Asset download endpoint
โ โโโ index.ts
โโโ scripts/
โ โโโ extract-tokens.mjs # CLI: extract tokens from Figma
โ โโโ export-icons.mjs # CLI: export icons from Figma
โ โโโ setup-webhooks.mjs # CLI: create/manage webhooks
โโโ output/
โ โโโ tokens.css # Generated CSS custom properties
โ โโโ tokens.json # Generated JSON tokens
โ โโโ icons/ # Exported SVG/PNG icons
โโโ tests/
โ โโโ fixtures/ # Saved Figma API responses
โ โโโ *.test.ts
โโโ .env.example
โโโ package.json
Step 2: Data Flow Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Figma Cloud โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ Files API โ โImages APIโ โ Webhooks V2 โ โ
โ โ /v1/files โ โ/v1/imagesโ โ /v2/webhooks โ โ
โ โโโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโโโฌโโโโโโโโ โ
โโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโ
โ โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ โโโโโโโผโโโโโ
โ Token โ โ Asset โ โ Webhook โ
โExtractorโ โExporter โ โ Handler โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโโฌโโโโโ
โ โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ โโโโโโโผโโโโโ
โ Cache โ โ Cache โ โ Event โ
โ (LRU) โ โ (URLs) โ โ Queue โ
โโโโโโฌโโโโโ โโโโโโฌโโโโโ โโโโโโโฌโโโโโ
โ โ โ
โโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโ
โ Output Layer โ
โ tokens.css โ icons/ โ Slack/Jira โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ