Skip to content

Transform your data into beautiful, interactive React components using AI. Powered by Google Gemini 2.5 Flash Lite with real-time streaming and modern UI components.

License

Notifications You must be signed in to change notification settings

codeer-ai/generative-ui

Repository files navigation

Generative UI

Next.js React TypeScript Gemini AI License

Transform your data into beautiful, interactive React components using AI

Powered by Google's Gemini AI β€’ Real-time streaming

View Demo β€’ Features β€’ Quick Start β€’ Deploy β€’ Contributing

🎯 Overview

Generative UI is an innovative application that leverages Google's Gemini AI to automatically generate React components from your data. Simply paste CSV, JSON, or plain text, and watch as AI transforms it into beautiful, interactive visualizations.

πŸš€ Key Highlights

  • Zero-config component generation - No templates or configurations needed
  • Real-time streaming - See components materialize as they're generated
  • Production-ready output - Generated components use shadcn/ui and Recharts
  • Dark/Light theme support - Seamless theme switching with system preference detection
  • Type-safe - Full TypeScript support with proper type inference
  • Edge-optimized - Runs on Vercel Edge Runtime for maximum performance

πŸ“Έ Demo

πŸ”— Try the Live Demo

View Screenshots

Light Mode

Light Mode Preview

✨ Features

Core Capabilities

  • πŸ€– AI-Powered Generation - Transforms raw data into React components using Gemini 2.5 Flash Lite
  • πŸ“Š Smart Visualizations - Automatically selects appropriate chart types based on data structure
  • πŸŒ“ Theme Support - Beautiful dark and light themes with smooth transitions
  • 🎲 Sample Data Generation - AI can create realistic datasets for testing

Supported Data Formats

  • CSV - Comma-separated values with headers
  • JSON - Objects, arrays, and nested structures
  • Plain Text - Markdown tables, lists, or structured text
  • Markdown - Tables and formatted content

Generated Component Types

  • πŸ“Š Charts - Bar, Line, Area, Pie, Radar, and Composed charts
  • πŸ“‹ Tables - Sortable, filterable data tables with pagination
  • πŸƒ Cards - Metric cards, stat cards, and info cards
  • πŸ“ˆ Dashboards - Multi-widget analytical dashboards
  • πŸ—‚οΈ Tabs - Organized multi-view interfaces
  • πŸ“ Lists - Task lists, timelines, and activity feeds

πŸ› οΈ Tech Stack

Frontend

AI & Backend

Development

πŸš€ Quick Start

Prerequisites

  • Node.js 18.17 or later
  • npm, yarn, or pnpm
  • Google AI Studio API key

Installation

  1. Clone the repository

    git clone https://github.com/codeer-ai/generative-ui.git
    cd generative-ui
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    cp .env.example .env.local
  4. Add your Google API key

    Get your API key from Google AI Studio and add it to .env.local:

    GOOGLE_API_KEY=your_api_key_here
  5. Start the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev
  6. Open the app

    Visit http://localhost:3000 in your browser

πŸ“– Usage Guide

Basic Usage

  1. Input your data in one of the supported formats:

    Month,Revenue,Expenses
    Jan,50000,30000
    Feb,60000,35000
    Mar,75000,40000
    
  2. Click "Generate UI" to create a component

  3. View the result - Your component will render below with full interactivity

Advanced Features

Generate Sample Data

Click "Generate Sample Data" to let AI create realistic datasets:

  • Fitness tracking with activities and metrics
  • Library book collections with ratings
  • Restaurant order management
  • Weather monitoring across locations
  • Employee directories with departments
  • And more...

Customize Output

The AI understands context, so you can guide generation:

  • Add a title row for dashboard layouts
  • Include metadata for specific chart types
  • Use descriptive column names for better components

Example Inputs

Sales Dashboard CSV
Product,Q1,Q2,Q3,Q4,Total
Widget A,12500,15000,18000,22000,67500
Widget B,8000,9500,11000,13500,42000
Widget C,5500,6000,7500,9000,28000
Task Management JSON
[
  {
    "task": "Implement user authentication",
    "status": "completed",
    "priority": "high",
    "assignee": "John Doe"
  },
  {
    "task": "Design dashboard layout",
    "status": "in-progress",
    "priority": "medium",
    "assignee": "Jane Smith"
  }
]

πŸ—οΈ Architecture

System Design

graph LR
    A[User Input] --> B[API Route]
    B --> C[Gemini AI]
    C --> D[Component String]
    D --> E[Streaming Response]
    E --> F[Dynamic Component]
    F --> G[Babel Transform]
    G --> H[Rendered UI]
Loading

Key Components

/app/api/generate/route.ts

Handles AI component generation with streaming support:

  • Validates input data
  • Constructs optimized prompts
  • Streams component code
  • Implements error recovery

/components/dynamic-component.tsx

Runtime component renderer with:

  • Babel transformation
  • Error boundaries
  • Component validation
  • Auto-fixing common issues

/app/page.tsx

Main application interface featuring:

  • Real-time updates
  • Theme-aware styling
  • Responsive layout

AI Prompt Engineering

The system uses carefully crafted prompts that:

  • Specify component requirements
  • Include shadcn/ui component imports
  • Define Recharts chart configurations
  • Handle edge cases and data validation

πŸš€ Deployment

Deploy to Vercel (Recommended)

Deploy with Vercel

Manual Deployment

  1. Fork or clone the repository
  2. Push to your GitHub account
  3. Import to Vercel:
    • Go to vercel.com/new
    • Import your repository
    • Add environment variables
    • Deploy

Environment Variables

Variable Description Required
GOOGLE_API_KEY Google AI Studio API key βœ… Yes

πŸ§ͺ Development

Project Structure

generative-ui/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ generate/          # Component generation endpoint
β”‚   β”‚   └── generate-data/     # Sample data generation
β”‚   β”œβ”€β”€ fonts/                # Local font files
β”‚   β”œβ”€β”€ globals.css           # Global styles & theme tokens
β”‚   β”œβ”€β”€ layout.tsx            # Root layout with providers
β”‚   └── page.tsx              # Main application UI
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/                   # shadcn/ui components
β”‚   β”œβ”€β”€ dynamic-component.tsx # Runtime renderer
β”‚   β”œβ”€β”€ theme-provider.tsx   # Theme context
β”‚   └── theme-toggle.tsx     # Theme switcher
β”œβ”€β”€ lib/
β”‚   └── utils.ts             # Utility functions
β”œβ”€β”€ public/                  # Static assets
β”œβ”€β”€ .env.example            # Environment template
β”œβ”€β”€ components.json         # shadcn/ui config
β”œβ”€β”€ next.config.ts         # Next.js configuration
β”œβ”€β”€ tailwind.config.ts     # Tailwind configuration
└── vercel.json           # Deployment config

Available Scripts

# Development
npm run dev          # Start dev server
npm run build       # Build for production
npm run start       # Start production server
npm run lint        # Run ESLint
npm run type-check  # Run TypeScript compiler

# Component Management
npx shadcn@latest add [component]  # Add shadcn/ui components

About

Transform your data into beautiful, interactive React components using AI. Powered by Google Gemini 2.5 Flash Lite with real-time streaming and modern UI components.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •