🎨 UI Generation Workflows
Figma to UI Generation
Description: Convert Figma designs into responsive UI components and pages using a schema-first approach. This workflow prioritizes structure and fidelity by generating schemas before code.
Prerequisites:
- Figma file URL
- Figma Personal Access Token
- Optional: Swagger/OpenAPI spec JSON for API integration
Process:
- Input Collection – User provides Figma URL, Token, and file type (App or Page).
- Schema Generation – Saarthi uses
gs-nodegen-figmatool to generate component schemas locally. - Scaffolding – Generates the project structure (or uses existing) via
gs-ui-inittool. - API Setup (Optional) – If a Swagger spec is provided, generates API slices using
gs-codegen-openapitool and sets up the Redux store/provider. - Component Implementation – Iteratively reads schemas and Figma images to build responsive, atomic components and transfers necessary assets.
- Assembly & Routing – Combines components into full web pages and configures application routing.
- Validation & Handoff – Runs the development server and asks the user to confirm if the output meets requirements or if changes are needed before final delivery.
🔑 How to Get a Figma API Key
- Go to Figma → Settings → Security.
- Under Personal Access Tokens, click Generate new token.
- Copy the generated token and store it securely.
- Use this token when prompted by Saarthi or the CLI.
💡 Tips for Best Results
- Organize Frames: Keep components logically grouped and avoid deeply nested auto-layouts.
- Clear Naming: Use descriptive layer names in Figma to help with component identification.
- Large Designs: To generate large Figma files in one go, move to a paid Figma plan. On free or limited plans, prefer generating smaller pages or sections incrementally.
⚠️ Troubleshooting
Windows CLI Argument Parsing
When using the CLI on Windows (PowerShell), wrap option values for gs-tools in both single and double quotes to correctly escape special characters.
Example: --url '"https://example.com/file?id=123"'
429 – Rate Limit Exceeded
This indicates that your Figma API key has hit rate limits.
Note: Many Figma APIs used by this tool are Tier-1 APIs and are subject to the limits described in the Figma rate-limit documentation.
If you are on a limited or free plan, you may encounter frequent connection errors.
Recommended actions:
- Retry after some time.
- Use smaller design or page-level URLs.
- Move to a paid Figma plan for large or frequent exports.
403 – Forbidden
This means the token does not have access to the Figma file.
Check the following:
- Verify that the Figma account used to generate the token has access to the design.
- If you are on a paid plan, ensure the design is added to the correct paid team/workspace.
500 Error or Timeout
This can occur due to:
- Large or complex Figma designs
- API rate limits on free or limited plans
- Figma servers not responding in time
Recommended actions:
- Try generating smaller pages or sections instead of the full file.
- Retry later.
- Move to a paid Figma plan to reduce timeouts and API throttling.
Prompt to UI Generation
Description:
Generate UI pages and components directly from text prompts or PRDs.
This workflow emphasizes predictability and reuse by leveraging the gs-ui-kit tool.
Prerequisites:
- A text prompt or PRD/TRD
- Project brief
- Optional: Swagger/OpenAPI spec JSON for API integration
Process:
- Scaffolding – Sets up the UI project workspace via
gs-ui-inittool. - Requirement Gathering – Captures project goals or parses the provided PRD.
- API Setup (Optional) – Generates API slices via
gs-codegen-openapitool and wraps the app in a Redux provider. - Strategy & Component Selection – Analyzes requirements to create a
ui-details.mdplan, selecting necessary components and variants fromgs-ui-kittool. - Build & Assemble – Iteratively builds components (adapting from the kit or generating new ones) and assembles them into pages.
- Validation & Handoff – Starts the development server, verifies navigation, and asks the user to confirm if the application is ready or requires refinement.
💡 Tips for Best Results
- Be Explicit: Clearly state the page purpose (e.g., "dashboard", "auth page") and specific behaviors.
- Structure over Aesthetics: Focus the prompt on layout and functionality first; refine styles later.
- API Planning: Identify which components need which endpoints early in the prompt.
Image to UI Generation
Description:
Generate UI pages and components directly from design images. This workflow balances creative freedom with guardrails using atomic design principles.
Prerequisites:
- One or more UI design images
- Page-level metadata (color palette, fonts, theme)
- Optional: Swagger/OpenAPI spec JSON
Process:
- Image Upload – User provides design images for pages or sections.
- Scoping – Define whether the image maps to a full page or a specific component.
- Scaffolding – Sets up the UI project workspace.
- Metadata Capture – User provides context (colors, fonts, themes).
- Generation – Creates atomic components based on image analysis.
- Assembly – Wires components into pages and connects optional APIs.
- Validation & Handoff – Runs the application and asks the user to validate the visual fidelity and functionality before finishing.
💡 Tips for Best Results
- Use high-resolution images – Clear contrast and crisp details lead to better code generation
- Provide actual asset files upfront – Share logos, icons, illustrations, and image assets directly instead of relying on generated placeholders. This ensures visual accuracy and maintains brand consistency
- Define design tokens clearly – Specify your color palette, typography, and spacing scale before generation
- Document theme details – Be explicit about light/dark mode, shadows, borders, and other style properties
- Share design system guidelines – If you have existing design standards, provide them to maintain consistency across generated components
Choosing the Right Workflow
| Workflow | Start With | Best For |
|---|---|---|
| Figma → UI | Figma designs | Production-ready applications |
| Prompt → UI | Text / PRD | Structured app bootstrapping |
| Image → UI | Design images | Creative or non-standard designs |