An AI-powered backend application that analyzes website screenshots and generates dramatically improved redesigns as production-ready TSX components.
This tool takes a screenshot of any website's landing page and uses AI to generate a "10x better" redesigned version in TSX with modern design principles, responsive layouts, and Tailwind CSS styling.
- Automated Screenshot Capture: Uses Cua ComputerAgent for AI-driven browser automation
- AI Design Analysis: Leverages Google Gemini Vision to analyze design elements, color palettes, typography, and layout
- Intelligent Redesign: Generates production-ready TSX components with:
- Modern, clean aesthetics
- Tailwind CSS styling
- Responsive design (mobile-first)
- Dark mode support
- Accessibility features (ARIA labels, semantic HTML)
- Smooth animations and transitions
- Backend: Python, FastAPI
- AI Models:
- Google Gemini 2.0 Flash (vision analysis + code generation)
- Claude 3.5 Sonnet (browser automation via Cua)
- Browser Automation: Cua Framework (ComputerAgent)
- Styling: Tailwind CSS (in generated components)
- Python 3.10+
- Google Gemini API key
- Cua Cloud API key and container
cd redesignpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .envEdit .env with your API keys:
# Google Gemini API
GEMINI_API_KEY=your-gemini-api-key
# Cua Cloud
CUA_API_KEY=your-cua-api-key
CUA_CONTAINER_NAME=your-container-name
# Browser Control Model (for ComputerAgent)
CUA_BROWSER_MODEL=anthropic/claude-3-5-sonnet-20241022
# Server
PORT=8000
HOST=0.0.0.0# Option 1: Using Python module
python -m src.main
# Option 2: Using Uvicorn directly
uvicorn src.main:app --reloadThe API will be available at http://localhost:8000
Visit http://localhost:8000/docs for interactive API documentation (Swagger UI)
curl -X POST http://localhost:8000/api/redesign \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'Generate a redesigned TSX component from a website URL.
Request Body:
{
"url": "https://example.com",
"style_preferences": {
"color_scheme": "dark",
"style": "minimal"
}
}Response:
{
"original_url": "https://example.com",
"original_screenshot": "data:image/png;base64,...",
"analysis": {
"color_palette": {
"primary": "#FF5733",
"secondary": ["#C70039", "#900C3F"],
"background": "#FFFFFF"
},
"typography": {
"heading": "Large, bold sans-serif",
"body": "Medium weight, readable"
},
"layout": {
"grid": "12-column",
"sections": ["header", "hero", "features", "footer"]
},
"improvements": [
"Increase whitespace for better readability",
"Modernize color palette",
"Add subtle animations"
]
},
"tsx_code": "import React from 'react';\n\nexport default function LandingPage() {\n return (\n <div className=\"min-h-screen bg-white\">\n ...\n </div>\n );\n}"
}Health check endpoint.
Response:
{
"status": "healthy"
}redesign/
├── src/
│ ├── api/
│ │ ├── __init__.py
│ │ └── routes.py # FastAPI routes
│ ├── services/
│ │ ├── __init__.py
│ │ ├── screenshot.py # Cua screenshot service
│ │ ├── analyzer.py # Design analysis with Gemini
│ │ └── generator.py # TSX generation with Gemini
│ ├── config/
│ │ ├── __init__.py
│ │ └── settings.py # Environment config
│ └── main.py # Application entry point
├── venv/ # Virtual environment
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── .env # Your environment variables (not in git)
├── IMPLEMENTATION_PLAN.md # Detailed implementation plan
└── README.md # This file
- Screenshot Capture: ComputerAgent uses AI to control a browser in a sandboxed environment, navigates to the provided URL, and captures screenshots
- Design Analysis: Gemini Vision analyzes the screenshot to extract:
- Color palette
- Typography
- Layout structure
- UI components
- Visual hierarchy
- Areas for improvement
- Redesign Generation: Gemini generates a modern TSX component that:
- Maintains the original content and purpose
- Dramatically improves visual design
- Implements modern UX best practices
- Uses Tailwind CSS for all styling
- Includes responsive and dark mode support
The project is structured around three main checkpoints:
- Screenshot Transfer: Capture and transfer screenshots from Cua sandbox to backend
- Redesign Generation: Generate valid TSX components from screenshots using Gemini
- User Display: Present the redesigned component in a viewable format
See IMPLEMENTATION_PLAN.md for detailed checkpoint criteria.
- Multiple viewport captures (mobile, tablet, desktop)
- Component library integration (shadcn/ui, Radix)
- Style presets ("minimal", "playful", "corporate")
- Iterative refinement based on user feedback
- A/B comparison view
- Export options (Next.js page, standalone HTML, Figma tokens)
MIT
Contributions are welcome! Please open an issue or submit a pull request.
For issues or questions, please open an issue on the repository.