This repository demonstrates how to integrate the Benchify API with a simple UI component builder application built with Next.js and Tailwind CSS.
The UI Builder Cookbook provides a practical example of using the Benchify API to automatically repair and improve code generated by AI. The application allows users to:
- Describe a UI component they want to build
- Generate code for that component using AI
- Automatically repair any issues in the code using the Benchify API
- Preview the component in a live sandbox environment
- AI-Powered UI Generation: Uses OpenAI to generate UI component code based on user descriptions
- Benchify Integration: Demonstrates how to use the Benchify API to detect and fix issues in generated code
- Live Preview: Provides instant previews of components using E2B sandbox
- Modern UI: Built with Next.js 15 and Tailwind CSS v4
- Component Library: Uses shadcn components for a consistent, accessible UI
- Node.js 18.x or later
- Benchify API key
- OpenAI API key
- E2B API key
Create a .env.local
file in the project root with the following variables:
BENCHIFY_API_KEY=your_benchify_api_key
OPENAI_API_KEY=your_openai_api_key
E2B_API_KEY=your_e2b_api_key
# Install dependencies
npm install
# Start the development server
npm run dev
Open http://localhost:5173 in your browser to use the application.
- Frontend: Next.js application with React components and Tailwind CSS styling
- AI Generation: OpenAI API integration to generate component code
- Code Repair: Benchify API integration to fix issues in generated code
- Live Preview: E2B sandbox to provide live previews of components
app/api/generate/route.ts
: API route that handles component generationlib/benchify.ts
: Benchify API integration for code repairlib/e2b.ts
: E2B sandbox integration for previewing componentscomponents/ui-builder/*
: UI components for the application
This cookbook demonstrates how to use the Benchify API to automatically fix issues in code. The integration includes:
- Preparing files for the Benchify API
- Submitting code for repair
- Applying fixes to the original code
- Providing build output for debugging
Example usage can be found in lib/benchify.ts
.
You can customize this cookbook by:
- Modifying the AI prompts in
lib/prompts.ts
- Changing the UI components in
components/ui-builder/*
- Adding additional features to the generation process
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.