🌐 English | Tiếng Việt
AI-Powered Design Intelligence Platform — tự động audit UI/UX, sinh code từ design, và học hỏi từ mỗi dự án.
Desygn AI là nền tảng trí tuệ thiết kế kết nối Figma với AI coding agents. Hệ thống gồm 3 surface chính:
| Surface | Mục đích |
|---|---|
| Figma Plugin | Quét component, variables, responsive variants — chấm điểm AI-readiness |
| Web Workspace | Sinh Design.md, chat AI, preview handoff, template library, audit UI/UX |
| Agent System v5 | 8 AI agents tự động audit, scoring, fix planning, tạo GitHub Issues |
| Agent Fleet v6 | 22 agents / 8 fleets — self-improving, worktree-isolated, cost-gated |
┌─────────────────────────────────────────────────────────────────────────┐
│ DESYGN AI PLATFORM v5 │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Figma Plugin│ │ Web App │ │ API Layer │ │ Agent System│ │
│ │ (Sandbox) │──▶│ (React+Vite)│──▶│ (Serverless)│──▶│ (Shannon v3)│ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ INTELLIGENCE LAYER │ │
│ ├─────────────────────────────────────────────────────────────────────┤ │
│ │ Shannon Engine ─── GOAP Planner ─── Evidence Memory (HNSW) │ │
│ │ PII Scanner ────── Usage Analytics ── Collaboration CRDT │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ UX CHECKLIST AUDITOR (v5) │ │
│ ├─────────────────────────────────────────────────────────────────────┤ │
│ │ AuditAgent → ScoreAgent → RecommendAgent → IssueWriter → CIGate │ │
│ │ MemoryAgent (cross-project) ── LearningLoop (sigmoid decay) │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
figma.* — chỉ parent.postMessagePluginMessage qua postMessageuseSyncExternalStore với localStorage persistenceFigma Plugin ──scan──▶ DesignAuditAgent ──▶ AccessibilityAgent
│ │
▼ ▼
ScoreAgent ◄──── DesignSystemAgent
│
▼
┌───────┴───────┐
▼ ▼
FixPlannerAgent RecommendAgent
│ │
▼ ▼
IssueWriterAgent CIGate
(GitHub Issues) (Block deploy)
│ │
▼ ▼
PRAutomation DeployGate
(Draft PRs) (Vercel/Slack)
│
▼
MemoryAgent
(Learn + Persist)
| Agent | Vai trò | Khả năng |
|---|---|---|
| DesignAuditAgent | Analyzer | Chấm UI/UX theo 19+ criteria, multi-category |
| AccessibilityAgent | Analyzer | WCAG 2.2: contrast, touch target, ARIA, focus, headings |
| DesignSystemAgent | Analyzer | Token coverage, naming, variant, spacing grid |
| ScoreAgent | Validator | Bayesian calibration với historical evidence |
| RecommendAgent | Optimizer | GOAP-planned improvement paths |
| FixPlannerAgent | Optimizer | Fix plans với risk assessment, code change suggestions |
| IssueWriterAgent | Generator | GitHub issues với evidence + acceptance criteria |
| MemoryAgent | Orchestrator | Cross-project learning, semantic recall, GDPR forget |
AuditResultScoreAgent calibrate bằng Bayesian + historical evidenceLearningLoop lưu vào Evidence Memory (HNSW vector search)Architecture Decision Record:
docs/architecture/AGENT_FLEET_V6.md
Hệ thống 22 agent / 8 fleet hoạt động tự chủ với worktree isolation, cost gating, và self-improvement loop.
| Fleet | Agents | Vai trò |
|---|---|---|
| Command | HumanCommandAgent, IssueToTaskAgent | Parse NL commands, convert issues to tasks |
| Map | RepoMapAgent, ComponentTraceAgent, DesignContextAgent | Index repo, trace components, bridge design context |
| Audit | ArchitectureDriftAgent | Circular deps, naming, barrel gaps, layer breaches |
| Self-Improve | SelfDiagnosticAgent, RefactorAgent, TestGenAgent, DependencyAuditAgent, SelfAuditAgent, BenchmarkAgent | Scan, refactor, generate tests, audit deps, grade health |
| Fix | CodeFixAgent, DiffApplierAgent, RollbackAgent + FixApprovalUI | Generate diffs, apply in worktree, rollback, user approval |
| Safety | SafetyGateAgent, RegressionGuardAgent, ConflictResolverAgent | Secret detection, lint/build/test gate, conflict resolution |
| Verify | TestRunnerAgent, LintRunnerAgent, BuildVerifierAgent | CLI wrappers: vitest, eslint, tsc+build |
User/Cron → HumanCommandAgent → SelfDiagnosticAgent → OrchestratorAgent
→ WorktreeRunner.create() → RefactorAgent/TestGenAgent → CodeFixAgent
→ SafetyGateAgent → DiffApplierAgent → RegressionGuardAgent
→ ConflictResolverAgent → FixApprovalUI → User Approve/Reject
→ SelfAuditAgent + BenchmarkAgent (health tracking)
$MAX_COST_USD budget per orchestration runmain is read-only.env*, *.pem, credentials*, CI workflows, lock filesdesygn-ai/
├── api/ # Vercel serverless functions
│ ├── chat.ts # Groq AI chat endpoint
│ ├── generate-html.ts # HTML generation
│ ├── generate-screens.ts # Screen generation
│ ├── analyze-image.ts # Image analysis
│ └── lib/sanitize.ts # Input sanitization
│
├── plugin/ # Figma plugin (sandbox)
│ ├── code.ts # Entry point
│ ├── serializer.ts # Node serialization (isMixed checks)
│ └── handlers/ # Auto-layout, fixes, profiles
│
├── shared/ # Shared code (plugin + UI + web)
│ ├── types.ts # SerializedNode, PluginMessage
│ ├── viewport.ts # Viewport classification
│ └── designContext.ts # DesignContext types
│
├── ui/ # Figma plugin React UI (iframe)
│ ├── App.tsx # Root component
│ ├── components/ # 38 UI components (CSS Modules)
│ ├── hooks/ # Custom React hooks
│ └── lib/ # Scanner, scoring, prompt gen
│
├── web/src/ # Web workspace (Desygn AI)
│ ├── main.tsx # App entry
│ ├── ai-layer/ # AI experiment orchestration
│ │ └── index.ts # 6 built-in experiments, A/B testing
│ ├── app-shell/ # Toast, theme, global config
│ ├── auth/ # Session controller + TTL watchdog
│ ├── chat-engine/ # AI chat + provider abstraction
│ ├── design-engine/ # Design.md generation + validation
│ ├── workspace-store/ # Reactive state (useSyncExternalStore)
│ │ ├── index.ts # Store<T>, workspaceStore, projectStore
│ │ └── useStore.ts # React hook adapter
│ ├── ux-checklist/ # Agentic UI/UX Auditor v5
│ │ ├── index.ts # Orchestrator + CriteriaRegistry + LearningLoop
│ │ ├── agents.ts # 5 specialized agents
│ │ ├── github.ts # GitHub Issue/PR bridge
│ │ ├── stream.ts # Real-time streaming + React hook
│ │ ├── memory.ts # Cross-project learning + persistence
│ │ └── ci.ts # CI gate + SARIF + Deploy gate
│ ├── lib/ # AI Intelligence Engines
│ │ ├── shannonEngine.ts # Multi-agent orchestrator (6 agents)
│ │ ├── evidenceMemory.ts # HNSW vector search + sigmoid decay
│ │ ├── goapPlanner.ts # Goal-Oriented Action Planning (A*)
│ │ ├── goapShannonBridge.ts # GOAP → Shannon → Evidence pipeline
│ │ ├── piiDetection.ts # PII scanner (Luhn, SSN, VN IDs)
│ │ ├── usageAnalytics.ts # SaaS tiers, quotas, feature flags
│ │ ├── collaborationEngine.ts # CRDT (LWW + OR-Set) + PII
│ │ ├── designAnalyzer.ts # Design auditor (WCAG 2.2)
│ │ ├── agents/v6/ # Agent Fleet v6 (22 agents, 8 fleets)
│ │ │ ├── BaseAgent.ts # Abstract base + FleetName type
│ │ │ ├── OrchestratorAgent.ts # Multi-fleet scheduler + cost gate
│ │ │ ├── WorktreeRunner.ts # Git worktree isolation
│ │ │ ├── audit/ # ArchitectureDriftAgent
│ │ │ ├── command/ # HumanCommand, IssueToTask
│ │ │ ├── map/ # RepoMap, ComponentTrace, DesignContext
│ │ │ ├── self-improve/ # Diagnostic, Refactor, TestGen, DepAudit, SelfAudit, Benchmark
│ │ │ ├── fix/ # CodeFix, DiffApplier, Rollback, useFixApproval
│ │ │ ├── safety/ # SafetyGate, RegressionGuard, ConflictResolver
│ │ │ ├── verify/ # TestRunner, LintRunner, BuildVerifier
│ │ │ └── __tests__/ # 25 test files, 192 tests
│ │ └── __tests__/ # 69 test files
│ ├── design/ # Template registry + validators
│ │ └── design-md-templates/ # 73 stored DESIGN.md templates
│ └── workspace/ # UI components (SplitView, Chat, etc.)
│
├── docs/ # Tài liệu kỹ thuật
│ ├── DEV_GUIDE.md # Hướng dẫn phát triển chi tiết
│ └── adr/ # Architecture Decision Records
│ ├── 001-dual-mode-auth.md
│ ├── 002-event-driven-architecture.md
│ ├── 003-api-layer-architecture.md
│ └── 004-command-pattern-undo-redo.md
│
├── e2e/ # E2E tests (Playwright)
│ └── chat.spec.ts
│
├── .vscode/launch.json # IDE configurations
├── vercel.json # Deployment + security headers
├── vite.web.config.ts # Web build config
├── vitest.config.ts # Test config
└── tsconfig.json # TypeScript config
Hệ thống phân loại trạng thái:
- 🟢 Đã triển khai — Production-ready, có test coverage, đã kiểm chứng trên production
- 🟡 Thử nghiệm — Code hoàn chỉnh, có unit tests, chưa kiểm chứng trên production
- 🔴 Kế hoạch — Chưa triển khai, nằm trong roadmap
Figma Plugin
Web Workspace
Design System & Detection
Hạ tầng & Chất lượng
AI Intelligence Engines
Agentic UI/UX Auditor (v5)
Collaboration & Analytics
| Tính năng | Mô tả |
|---|---|
| Real authentication | Supabase Auth — thay thế localStorage demo hiện tại |
| Redis/KV rate limiting | Thay thế in-memory rate limiting |
| GitHub PR automation | Tự động tạo issue + coding agent workflow |
| Team workspace | Multi-user collaboration workspace |
| Enterprise RBAC | Phân quyền doanh nghiệp |
| Template marketplace | Cộng đồng chia sẻ Design.md templates |
| Self-hosted editions | Triển khai on-premise |
| Playwright web audit API | Audit UI/UX trực tiếp trên web |
| Sentry/observability | Error tracking + performance monitoring |
| Thành phần | Phiên bản |
|---|---|
| Node.js | 20+ |
| npm | 10+ |
| Figma Desktop | Mới nhất (cho plugin dev) |
git clone https://github.com/minhduchd-mds/desygn-ai.git
cd desygn-ai
npm ci
# Web workspace (port 5174)
npm run web:dev
# Figma plugin (watch mode)
npm run dev
# Web workspace (port 5173 — alternative)
npm run dev:web
npm run build # Figma plugin → dist/
npm run web:build # Web app → public/
| Script | Mô tả |
|---|---|
npm run dev |
Watch mode: Figma plugin (UI + controller) |
npm run dev:web |
Web workspace dev server (port 5173) |
npm run web:dev |
Web workspace dev server (port 5174) |
npm run web:build |
Production build cho web app |
npm run build |
Production build cho Figma plugin |
npm test |
Chạy 1529 tests (Vitest) |
npm run lint |
ESLint 9 |
npm run format |
Prettier format |
npm run typecheck |
TypeScript type checking (UI + plugin) |
npm run storybook |
Storybook dev server (port 6006) |
Vercel serverless functions trong api/:
| Route | Method | Mô tả |
|---|---|---|
/api/chat |
POST | Groq AI chat (cần GROQ_API_KEY) |
/api/generate-html |
POST | Sinh HTML từ text prompt |
/api/generate-screens |
POST | Sinh screen layouts |
/api/analyze-image |
POST | Phân tích design image |
73 Design.md templates trong web/src/design-md-templates/.
AI, Developer, Workspace, Product, Commerce, Finance, Automotive, Media
npx getdesign@latest add <template-id>
# Ví dụ: npx getdesign@latest add airtable
Templates lazy-loaded — chỉ tải metadata lúc khởi động, full content khi chọn.
npm test # 1529 tests / 102 files
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run lint # ESLint 9
npm run format:check # Prettier check
npm run typecheck # TypeScript (UI + plugin)
| Module | Số tests | Mô tả |
|---|---|---|
| Core lib (Shannon, GOAP, Evidence, PII) | ~890 | Intelligence engines |
| Agent Fleet v6 (22 agents) | 192 | Autonomous agent system |
| UX Checklist (agents, CI, memory, stream) | ~72 | Agentic auditor v5 |
| Modular architecture (stores, engines) | ~68 | App modules |
| Design (templates, parser, validator) | ~50 | Design.md |
| Plugin (serializer, handlers, scoring) | ~60 | Figma plugin |
| Workspace (SplitView, helpers) | ~50 | Web UI |
| Target | Size | Ghi chú |
|---|---|---|
Figma Plugin (dist/code.js) |
98.6 kB | esbuild, ES6 |
Figma UI (dist/index.html) |
496 kB | Vite, single-file |
Web App (public/) |
~2.1 MB | Vite, code-split, 84 chunks |
{
"buildCommand": "npm run web:build",
"outputDirectory": "public",
"installCommand": "npm ci"
}
Live: design-md-ai-yd6r.vercel.app
Security headers: CSP, HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy (cấu hình trong vercel.json).
npm run buildCtrl+Shift+P → Import plugin from manifestmanifest.json trong repo| Biến | Bắt buộc | Mô tả |
|---|---|---|
GROQ_API_KEY |
Có | Groq API key cho AI chat |
VITE_SCREENSHOT_TO_CODE_WS_URL |
Không | WebSocket URL cho screenshot-to-code |
VITE_SUPABASE_URL |
Không | Supabase project URL |
VITE_SUPABASE_ANON_KEY |
Không | Supabase anonymous key |
| Tài liệu | Đường dẫn | Nội dung |
|---|---|---|
| Hướng dẫn phát triển | docs/DEV_GUIDE.md |
Kiến trúc chi tiết, module map, agent pipeline, hard rules |
| ADR: Dual-Mode Auth | docs/adr/001 |
Quyết định kiến trúc authentication |
| ADR: Event-Driven | docs/adr/002 |
Event bus architecture |
| ADR: API Layer | docs/adr/003 |
API design decisions |
| ADR: Command Pattern | docs/adr/004 |
Undo/redo implementation |
| ADR: Agent Fleet v6 | docs/architecture/AGENT_FLEET_V6.md |
22-agent autonomous system |
| Bảo mật | SECURITY.md |
Security policy + PII protection |
| Changelog | CHANGELOG.md |
Lịch sử phiên bản |
| Contributing | CONTRIBUTING.md |
Hướng dẫn đóng góp |