miro-reference-architecture
Implement a production-ready reference architecture for Miro REST API v2 integrations with layered design, caching, and event processing. Trigger with phrases like "miro architecture", "miro project structure", "how to organize miro integration", "miro design patterns".
What this skill does
# Miro Reference Architecture
## Overview
Production-ready architecture for Miro REST API v2 integrations. Layered design with a board service, item factory, webhook event processor, and caching layer.
## Architecture Diagram
```
┌──────────────────────────────────────────────────────────┐
│ API / UI Layer │
│ Express routes, Next.js API routes, CLI commands │
├──────────────────────────────────────────────────────────┤
│ Service Layer │
│ BoardService, ItemService, SyncService │
│ (business logic, orchestration, validation) │
├──────────────────────────────────────────────────────────┤
│ Miro Client Layer │
│ MiroApiClient (REST v2), TokenManager (OAuth 2.0) │
│ ItemFactory (typed creation), ConnectorBuilder │
├──────────────────────────────────────────────────────────┤
│ Infrastructure Layer │
│ Cache (LRU/Redis), Queue (PQueue), Monitor (metrics) │
│ WebhookProcessor (signature + idempotency) │
└──────────────────────────────────────────────────────────┘
│
▼
https://api.miro.com/v2/
```
## Project Structure
```
src/
├── miro/
│ ├── client.ts # MiroApiClient — wraps fetch with auth, retries, monitoring
│ ├── token-manager.ts # OAuth 2.0 token lifecycle (refresh, storage)
│ ├── item-factory.ts # Typed item creation (sticky notes, shapes, cards, etc.)
│ ├── connector-builder.ts # Fluent API for creating connectors
│ ├── types.ts # TypeScript types for all Miro v2 responses
│ └── errors.ts # MiroApiError, MiroAuthError, MiroRateLimitError
├── services/
│ ├── board-service.ts # Board CRUD + member management
│ ├── item-service.ts # Item CRUD + tag operations
│ ├── sync-service.ts # Two-way sync between Miro and your database
│ └── search-service.ts # Find items by content, type, or tag
├── webhooks/
│ ├── handler.ts # Express/serverless webhook endpoint
│ ├── processor.ts # Event routing and processing
│ └── idempotency.ts # Duplicate event prevention
├── cache/
│ ├── board-cache.ts # Board metadata cache
│ └── item-cache.ts # Item data cache with webhook invalidation
├── config/
│ ├── miro.ts # Environment-based Miro configuration
│ └── index.ts # Config loader
└── monitoring/
├── metrics.ts # Prometheus counters/histograms for Miro API
└── health.ts # Health check endpoint
```
## Core Components
### MiroApiClient
```typescript
// src/miro/client.ts
export class MiroApiClient {
constructor(
private tokenManager: TokenManager,
private cache: ItemCache,
private monitor: MiroMetrics,
) {}
async fetch<T>(path: string, method = 'GET', body?: unknown): Promise<T> {
const token = await this.tokenManager.getValidToken();
const start = performance.now();
const response = await fetch(`https://api.miro.com${path}`, {
method,
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
...(body ? { body: JSON.stringify(body) } : {}),
});
const duration = performance.now() - start;
this.monitor.recordRequest(method, path, response.status, duration);
this.monitor.updateRateLimit(response);
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') ?? '5', 10);
throw new MiroRateLimitError(retryAfter);
}
if (!response.ok) {
const error = await response.json().catch(() => ({}));
throw new MiroApiError(response.status, error.message, error.code);
}
if (response.status === 204) return null as T;
return response.json() as T;
}
// Paginated fetch — returns all pages
async fetchAll<T>(path: string, limit = 50): Promise<T[]> {
const items: T[] = [];
let cursor: string | undefined;
do {
const params = new URLSearchParams({ limit: String(limit) });
if (cursor) params.set('cursor', cursor);
const result = await this.fetch<PaginatedResponse<T>>(
`${path}?${params}`
);
items.push(...result.data);
cursor = result.cursor;
} while (cursor);
return items;
}
}
```
### Board Service
```typescript
// src/services/board-service.ts
export class BoardService {
constructor(
private api: MiroApiClient,
private cache: BoardCache,
) {}
async getBoard(boardId: string): Promise<MiroBoard> {
const cached = await this.cache.get(boardId);
if (cached) return cached;
const board = await this.api.fetch<MiroBoard>(`/v2/boards/${boardId}`);
await this.cache.set(boardId, board, 120); // 2 min TTL
return board;
}
async createBoard(params: CreateBoardParams): Promise<MiroBoard> {
return this.api.fetch<MiroBoard>('/v2/boards', 'POST', {
name: params.name,
description: params.description,
teamId: params.teamId,
policy: {
sharingPolicy: { access: params.access ?? 'private' },
permissionsPolicy: { sharingAccess: 'team_members_and_collaborators' },
},
});
}
async shareBoard(boardId: string, emails: string[], role: BoardRole): Promise<void> {
await this.api.fetch(`/v2/boards/${boardId}/members`, 'POST', {
emails,
role, // 'viewer' | 'commenter' | 'editor' | 'coowner'
});
}
async getMembers(boardId: string): Promise<BoardMember[]> {
return this.api.fetchAll(`/v2/boards/${boardId}/members`);
}
}
```
### Webhook Processor
```typescript
// src/webhooks/processor.ts
export class WebhookProcessor {
private handlers = new Map<string, EventHandler[]>();
on(eventType: string, handler: EventHandler): void {
const existing = this.handlers.get(eventType) ?? [];
existing.push(handler);
this.handlers.set(eventType, existing);
}
async process(event: MiroBoardEvent): Promise<void> {
// Type-based routing
const key = `${event.item.type}:${event.type}`; // e.g., 'sticky_note:create'
const handlers = [
...(this.handlers.get(key) ?? []),
...(this.handlers.get(`*:${event.type}`) ?? []), // Wildcard item type
...(this.handlers.get('*:*') ?? []), // Catch-all
];
for (const handler of handlers) {
await handler(event);
}
}
}
// Usage
const processor = new WebhookProcessor();
processor.on('sticky_note:create', async (event) => {
console.log(`New sticky note on board ${event.boardId}: ${event.item.id}`);
await syncService.syncItem(event.boardId, event.item.id);
});
processor.on('*:delete', async (event) => {
console.log(`Item deleted from board ${event.boardId}: ${event.item.id}`);
await database.deleteItem(event.item.id);
});
```
### Connector Builder (Fluent API)
```typescript
// src/miro/connector-builder.ts
export class ConnectorBuilder {
private config: any = { style: {} };
constructor(private api: MiroApiClient, private boardId: string) {}
from(itemId: string, snapTo?: SnapPosition): this {
this.config.startItem = { id: itemId, ...(snapTo ? { snapTo } : {}) };
return this;
}
to(itemId: string, snapTo?: SnapPosition): this {
this.config.endItem = { id: itemId, ...(snapTo ? { snapTo } : {}) };
return this;
}
caption(text: string, position = 0.5): this {
this.config.captions = [{ content: text, position }];
return this;
}
dashed(): this { this.config.style.strokeStyle = 'dashed'; return this; }
curved(): this { this.config.shape = 'curved'; return this; }
arrow(): this { this.config.style.endStrokeCap = 'stealth'; return this; }
async build(): Promise<MiroConnector> {
return this.api.fetch(`/v2/boards/${this.boardId}/connectors`, 'POST', this.confRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.