Skip to content

ChanMeng666/image-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

AI Image Generator

🎨 AI Image Generator

Transform Your Ideas Into Stunning Visual Art

An innovative AI-powered image generation platform that leverages Cloudflare Workers AI with FLUX.1 Schnell to transform text descriptions into high-quality images — completely FREE (100k requests/day).
Supports real-time generation, instant downloads, and features a beautiful Mondrian-inspired UI design.
Deployed on Cloudflare Workers for global edge performance.

Live Demo · Documentation · GitHub · Issues


🚀 Try Live Demo 🚀




Share AI Image Generator

🌟 Pioneering the future of AI-powered creative tools. Built for artists, designers, and creative professionals.

📸 Project Screenshots

[!TIP] Experience the intuitive interface and powerful AI image generation capabilities.

Main Interface

Main Interface - Clean and intuitive design inspired by Mondrian's art

Image Generation Process Generated Results

AI Generation Process - From prompt to stunning visuals

Tech Stack Badges:

🎨 See it live

AI Image Generator community gallery — 'Community gallery' headline, search bar for prompts, Latest grid showing 4 AI-generated images: anime figure in autumn coat, premium food advertisement, Chinese moonlit mountain landscape, and photorealistic red apple on black background

Demo: AI Image Generator walk-through — login page with GitHub and Google OAuth options and email sign-in form, then transition to the public community gallery showing 13 community-generated images with anime, food, landscape, and product photography styles

🔐 Sign-in page AI Image Generator sign-in — 'Welcome back / Sign in to keep generating.' card with GitHub OAuth, Google OAuth, and email + password form fields, plus Sign up link
📱 Mobile gallery AI Image Generator on mobile — community gallery headline, search prompts bar, 2-column image grid showing anime figure and PREMIUM FOOD ad at top, Chinese landscape and red apple below, with download buttons

Important

This project demonstrates modern AI integration with Next.js 15 App Router, featuring real-time image generation powered by Cloudflare Workers AI's FLUX.1 Schnell model (free, 100k requests/day). Deployed on Cloudflare Workers via the OpenNext adapter, with React 19, TypeScript, and Tailwind CSS.

📑 Table of Contents

TOC


🌟 Introduction

We are passionate developers creating the next generation of AI-powered creative tools. By adopting modern web technologies and cutting-edge AI models, we aim to provide users with powerful, intuitive, and accessible image generation capabilities.

Whether you're a professional designer, digital artist, or creative enthusiast, this AI Image Generator will be your creative playground. The application leverages Cloudflare Workers AI's FLUX.1 Schnell model to transform text descriptions into stunning visual art — completely free with 100,000 requests per day.

Note

  • Node.js >= 18.0 required
  • Cloudflare account required (free tier is sufficient — no API key needed, Workers AI is built-in)
  • Modern browser with JavaScript enabled
No installation required! Visit our live demo to experience AI image generation firsthand.

Tip

⭐ Star us to receive all release notifications from GitHub without delay!

⭐ Star History

✨ Key Features

1 AI-Powered Image Generation

Experience state-of-the-art image generation using Cloudflare Workers AI's FLUX.1 Schnell model. Our platform delivers high-quality, creative visuals from simple text descriptions with impressive speed and accuracy — at zero cost.

Key capabilities include:

  • 🚀 Lightning Fast: Generate images in seconds at the edge
  • 🎨 High Quality: FLUX.1 Schnell 12B parameter model for superior results
  • 💡 Creative Freedom: Transform any text into visual art
  • 🔄 Real-time Processing: Instant feedback and generation
  • 🆓 Completely Free: 100,000 requests/day on Cloudflare Workers AI free tier

Tip

The FLUX.1 Schnell model excels at understanding complex prompts and generating detailed, creative images across various styles and subjects. Running on Cloudflare's global edge network ensures low latency worldwide.

2 Mondrian-Inspired Design

Revolutionary user interface inspired by Piet Mondrian's iconic geometric art style. The clean, minimalist design ensures an intuitive user experience while maintaining aesthetic appeal.

Design Features:

  • Geometric Background: Dynamic Mondrian-style shapes
  • Clean Interface: Minimalist and distraction-free design
  • Responsive Layout: Perfect on desktop and mobile devices
  • Accessibility First: WCAG compliant design principles

* Additional Features

Beyond the core AI generation, this project includes:

  • 📱 Responsive Design: Perfect experience across all devices
  • ⬇️ Instant Downloads: One-click image downloading
  • 🛡️ Error Handling: Comprehensive error management and user feedback
  • 🔄 Loading States: Smooth loading animations and progress indicators
  • 🎯 TypeScript: Full type safety throughout the application
  • 🚀 Next.js 15 App Router: Modern React 19 architecture with server components
  • 🎨 Custom UI Components: Built with Radix UI primitives
  • Optimized Performance: Fast loading and efficient rendering

✨ More features are continuously being added as the project evolves.

🛠️ Tech Stack

Next.js
Next.js 15
React
React 19
TypeScript
TypeScript 5
Tailwind CSS
Tailwind CSS
Cloudflare Workers AI
Workers AI
Cloudflare Workers
CF Workers

Frontend Stack:

  • Framework: Next.js 15 with App Router
  • Language: TypeScript for complete type safety
  • Styling: Tailwind CSS with custom design system
  • UI Components: Radix UI primitives + Custom components
  • Icons: Lucide React icon library

AI & Backend:

  • AI Model: Cloudflare Workers AI — FLUX.1 Schnell (free, 100k req/day)
  • API: Next.js API routes via OpenNext adapter
  • AI Binding: Direct Workers AI binding (no external API key needed)
  • Image Processing: Base64 encoding for instant display

DevOps & Deployment:

  • Platform: Cloudflare Workers for global edge deployment
  • Adapter: @opennextjs/cloudflare for Next.js compatibility
  • Build System: OpenNext build pipeline + Wrangler CLI
  • Performance: Edge-first architecture with global CDN

Tip

Each technology was carefully selected for optimal developer experience, performance, and maintainability in production environments. The Cloudflare Workers AI integration eliminates the need for external API keys and provides generous free usage.

🏗️ Architecture

System Architecture

Tip

This architecture supports horizontal scaling and is production-ready for high-traffic applications.

graph TB
    subgraph "User Browser"
        A[Next.js 15 App - React 19] --> B[React Components]
        B --> C[Tailwind CSS Styling]
        B --> K[Text Input]
        B --> L[Image Display]
        B --> M[Download Feature]
    end

    subgraph "Cloudflare Workers"
        D[OpenNext Adapter] --> E[Next.js API Routes]
        E --> F[Workers AI Binding]
        D --> G[Static Assets CDN]
    end

    subgraph "Cloudflare Workers AI"
        H["FLUX.1 Schnell (12B params)"]
    end

    K -->|POST /api/generate| D
    F -->|"env.AI.run()"| H
    H -->|Base64 Image| E
    E -->|JSON Response| L

    style H fill:#F38020,stroke:#F38020,color:#fff
    style D fill:#F38020,stroke:#F38020,color:#fff
Loading

Request Flow:

sequenceDiagram
    participant U as User Browser
    participant W as Cloudflare Worker
    participant AI as Workers AI (FLUX.1 Schnell)

    U->>W: POST /api/generate {prompt}
    W->>W: Validate prompt
    W->>AI: env.AI.run("@cf/black-forest-labs/flux-1-schnell", {prompt, steps: 4})
    AI-->>W: {image: "base64..."}
    W-->>U: JSON Response (base64 image)
    U->>U: Display image via data URI
Loading

Component Structure

├── app/                        # Next.js 15 App Router
│   ├── api/generate/           # Image generation API route (Workers AI)
│   │   └── route.ts            # POST endpoint using env.AI binding
│   ├── layout.tsx              # Root layout with Inter font
│   ├── page.tsx                # Main application page (client component)
│   └── globals.css             # Global styles + Tailwind directives
├── components/                 # React components
│   ├── ui/                     # Base UI components (Button, etc.)
│   ├── MondrianBackground.tsx  # Geometric background component
│   └── DeveloperShowcase.tsx   # Developer profile component
├── lib/                        # Utility libraries
│   └── utils.ts                # cn() helper for Tailwind class merging
├── public/                     # Static assets (logo, favicon, etc.)
├── wrangler.jsonc              # Cloudflare Workers configuration
├── open-next.config.ts         # OpenNext Cloudflare adapter config
├── cloudflare-env.d.ts         # Cloudflare bindings TypeScript types
├── next.config.js              # Next.js config + OpenNext dev init
└── package.json                # Dependencies and build scripts

⚡️ Performance

Performance Metrics

Key Metrics:

  • < 2s Image generation time
  • 🚀 < 300ms Initial page load
  • 💨 95+ Lighthouse Score for performance
  • 📱 100% Mobile Responsive design
  • 🔄 Real-time generation feedback

Performance Optimizations:

  • 🌍 Edge Deployment: Cloudflare Workers runs at 300+ locations worldwide
  • 📦 Code Splitting: Automatic bundle optimization via Next.js 15
  • 🔄 Workers AI Binding: Direct in-platform AI inference with zero network hop to external APIs
  • 🖼️ Base64 Encoding: Instant image display without additional requests

Note

Performance metrics are continuously monitored in production environments. Cloudflare Workers provides built-in analytics and logging.

🚀 Getting Started

Prerequisites

Important

Ensure you have the following installed:

  • Node.js 18.0+ (Download)
  • npm/yarn/pnpm package manager
  • Git (Download)
  • Cloudflare account (Sign up free) — no API key needed, Workers AI is built-in
  • Wrangler CLI (installed as project devDependency)

Quick Installation

1. Clone Repository

git clone https://github.com/ChanMeng666/image-generator.git
cd image-generator

2. Install Dependencies

# Using npm
npm install

# Using yarn
yarn install

# Using pnpm (recommended)
pnpm install

3. Login to Cloudflare

# Login to your Cloudflare account (interactive browser auth)
npx wrangler login

4. Start Development

npm run dev

🎉 Success! Open http://localhost:3000 to start generating images.

Tip

No API key is needed! Cloudflare Workers AI is accessed directly via the AI binding configured in wrangler.jsonc. The free tier includes 100,000 AI requests per day.

Development Mode

# Start development server (with Cloudflare bindings)
npm run dev

# Build and preview locally with Cloudflare Workers runtime
npm run preview

# Build for production
npm run build

# Deploy to Cloudflare Workers
npm run deploy

# Run linting
npm run lint

🛳 Deployment

Important

This project is deployed on Cloudflare Workers using the OpenNext adapter. No external API keys are required.

A Cloudflare Workers Deployment (Recommended)

One-Command Deploy:

# Build and deploy to Cloudflare Workers
npm run deploy

Step-by-Step Deployment:

# 1. Login to Cloudflare
npx wrangler login

# 2. Build the Next.js app + OpenNext bundle
npx opennextjs-cloudflare build

# 3. Deploy to Cloudflare Workers
npx opennextjs-cloudflare deploy

Your app will be available at https://image-generator.<your-subdomain>.workers.dev.

B Deployment Architecture

graph LR
    subgraph "Build Pipeline"
        A[Next.js Build] --> B[OpenNext Adapter]
        B --> C[Worker Bundle]
        B --> D[Static Assets]
    end

    subgraph "Cloudflare Edge Network"
        E[Workers Runtime]
        F[Static Asset CDN]
        G[Workers AI]
    end

    C --> E
    D --> F
    E --> G

    style E fill:#F38020,stroke:#F38020,color:#fff
    style F fill:#F38020,stroke:#F38020,color:#fff
    style G fill:#F38020,stroke:#F38020,color:#fff
Loading

C Configuration

Note

No external API keys or secrets are needed. Workers AI is accessed via a built-in binding.

File Purpose
wrangler.jsonc Cloudflare Workers config (account, AI binding, assets)
open-next.config.ts OpenNext adapter configuration
next.config.js Next.js config with OpenNext dev integration

Key wrangler.jsonc settings:

{
  "name": "image-generator",
  "main": ".open-next/worker.js",
  "compatibility_flags": ["nodejs_compat"],
  "ai": { "binding": "AI" }  // Workers AI binding — no API key needed
}

📖 Usage Guide

Basic Usage

Getting Started with AI Image Generation:

  1. Enter Description: Type your image description in the text area
  2. Generate Image: Click the "Generate Image" button
  3. View Result: Watch as your AI-generated image appears
  4. Download: Click "Download Image" to save your creation

API Reference

Image Generation Endpoint:

POST /api/generate
Content-Type: application/json

{
  "prompt": "A beautiful sunset over mountains"
}

# Response (JSON string — base64-encoded image)
"iVBORw0KGgoAAAANSUhEUgAA..."

Example Usage:

const generateImage = async (prompt) => {
  const response = await fetch('/api/generate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ prompt })
  });
  
  const imageData = await response.json();
  return `data:image/png;base64,${imageData}`;
};

Server-side implementation (via Cloudflare Workers AI binding):

// app/api/generate/route.ts
import { getCloudflareContext } from '@opennextjs/cloudflare';

const { env } = getCloudflareContext();
const response = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', {
  prompt,
  steps: 4,  // 1-8, higher = better quality
});
// response.image contains the base64-encoded image

Error Responses:

Status Code Description Response
400 Missing prompt { error: "Please enter a prompt" }
500 Generation failed { error: "Error generating image" }

🔌 Integrations

Current Integrations:

Service Purpose Status Documentation
Cloudflare Workers AI AI Image Generation (FLUX.1 Schnell) ✅ Active Workers AI Docs
Cloudflare Workers Edge Deployment & Hosting ✅ Active Workers Docs
OpenNext Next.js → Cloudflare Adapter ✅ Active OpenNext Docs
Tailwind CSS Styling System ✅ Active Documentation
Radix UI UI Components ✅ Active Component Docs

⌨️ Development

Local Development

Setup Development Environment:

# Clone and setup
git clone https://github.com/ChanMeng666/image-generator.git
cd image-generator
npm install

# Login to Cloudflare (for Workers AI binding in dev)
npx wrangler login

# Start development
npm run dev

Adding Features

Development Workflow:

# Create feature branch
git checkout -b feature/amazing-feature

# Make your changes
# Add tests if applicable
# Update documentation

# Submit pull request
git push origin feature/amazing-feature

Testing

Manual Testing:

  1. Test image generation with various prompts
  2. Verify responsive design on different devices
  3. Check error handling with invalid inputs
  4. Test download functionality

🤝 Contributing

We welcome contributions! Here's how you can help:

How to Contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contribution Guidelines:

  • Follow TypeScript best practices
  • Maintain consistent code formatting
  • Add meaningful commit messages
  • Update documentation as needed

📄 License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

License Benefits:

  • ✅ Commercial use allowed
  • ✅ Modification allowed
  • ✅ Distribution allowed
  • ✅ Private use allowed

👥 Author

Chan Meng
Chan Meng

Creator & Lead Developer

Chan Meng


🎨 Transforming Ideas into Visual Art with AI 🌟
Empowering creativity through cutting-edge technology

Star us on GitHub • 🚀 Try the Demo • 🐛 Report Issues • 💡 Request Features • 🤝 Contribute



Made with 💛 by Chan Meng

GitHub stars GitHub forks GitHub watchers

---

Chan Meng

Chan Meng
Need a custom app like this one? I build them — let's talk.

Email Chan Meng Chan Meng on GitHub

About

【Your star could be the one that makes our day! ⭐️】A modern Next.js application for AI image generation using Together AI, featuring a beautiful Mondrian-inspired design and intuitive user interface.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors

Languages