How apple/ml-keyframer works
Project type and purpose
• Project Type: Full-stack web application built with Next.js and React.
• Purpose: “Keyframer” allows designers to upload or select an SVG, send a natural-language prompt to GPT-4 (via an API route), and receive CSS animations which can then be iteratively refined through a UI with code and property editors.
File structure
• Top-level directories/files:
• pages/ → Next.js routing:
– pages/index.js: main UI entry point
– pages/api/generate.js: serverless API endpoint that forwards prompts to OpenAI
• components/ → React components for inputs, forms, editors, output displays
• public/ → static assets (e.g., default SVGs under figs/)
• package.json → dependencies (React, Next.js, OpenAI SDK, CSS modules)
• figs/ → documentation screenshots used in README
• No traditional database—state is kept in React, calls to GPT-4 are stateless, with prompts and SVG code passed on each request.
README for additional insights
• Architecture described implicitly:
• Frontend React interface (Input SVG, Prompt editors, Code/Property editors, Output display)
• Backend API route that uses the OpenAI Node.js client to call GPT-4
• Dependencies:
• OpenAI API key required
• Next.js dev and build scripts
Elements
• Clear labels:
• “Browser UI (Next.js + React components)”
• “Serverless Function (/api/generate.js)”
• “OpenAI GPT-4 API”
• Blue rectangles for UI components
• Orange rectangle for serverless/API layer
• Annotations for key functions:
• “GenerateAnimationsButton → POST SVG + prompt”
• “PropertyEditor → CSS updates”
• “CodeEditor → raw CSS editing”