Skip to content

POC nextjs integration of Open AI's latest image generation capability release April 2025. NOT PROD READY

License

Notifications You must be signed in to change notification settings

vibetolaunch/ChatGPT-image-1-POC

🎨 iPaintAI

Advanced AI-Powered Image Editing with ChatGPT-image-1 Integration

License: MIT Next.js TypeScript Supabase

A sophisticated AI-powered image editing platform showcasing the latest in AI image generation technology, featuring OpenAI's ChatGPT-image-1, Stability AI, and Recraft AI integrations with an intuitive mask-based editing interface.

✨ Features

πŸ€– Multi-AI Provider Support

  • OpenAI ChatGPT-image-1: Latest image generation model (April 2025)
  • Stability AI: Stable Diffusion integration
  • Recraft AI: Advanced AI image generation
  • Extensible Provider Pattern: Easy to add new AI services

🎨 Advanced Image Editing

  • Mask-Based Editing: Paint areas to modify with precision
  • Floating Toolbar: Draggable, collapsible interface
  • Edge-to-Edge Canvas: Maximum workspace utilization
  • Real-time Preview: Instant feedback on edits
  • Export Options: PNG/JPG with quality controls

πŸ–₯️ Modern Interface

  • Dark Theme: Professional editing environment
  • Glassmorphism Design: Modern, semi-transparent UI elements
  • Responsive Layout: Works on desktop and mobile
  • Auto-docking: Smart toolbar positioning
  • Undo/Redo: Full history management

πŸ” Secure & Scalable

  • Supabase Authentication: Secure user management
  • Row Level Security: Data protection
  • API Key Protection: Server-side security
  • Stripe Integration: Token-based billing
  • File Storage: Secure image management

πŸš€ Quick Start

Prerequisites

  • Node.js 18.0 or higher
  • npm or yarn
  • API keys for AI providers
  • Supabase project
  • Stripe account (for payments)

Installation

  1. Clone the repository

    git clone https://github.com/your-username/ipaintai.git
    cd ipaintai
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env.local

    Fill in your API keys in .env.local:

    # AI Provider Keys
    OPENAI_API_KEY=sk-your-openai-key
    STABILITY_API_KEY=sk-your-stability-key
    RECRAFT_API_KEY=your-recraft-key
    
    # Supabase Configuration
    NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
    NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-key
    
    # Stripe Configuration
    STRIPE_SECRET_KEY=sk_test_your-stripe-key
    NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_your-stripe-key
  4. Set up the database

    npm run db:migrate
  5. Start the development server

    npm run dev
  6. Open your browser Navigate to http://localhost:3000

πŸ“– Documentation

πŸ—οΈ Architecture

iPaintAI is built with a modern, scalable architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Backend       β”‚    β”‚   External      β”‚
β”‚   (Next.js)     β”‚    β”‚   (API Routes)  β”‚    β”‚   Services      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β€’ Canvas Editor β”‚    β”‚ β€’ Image API     β”‚    β”‚ β€’ OpenAI        β”‚
β”‚ β€’ Auth UI       │◄──►│ β€’ Auth Routes   │◄──►│ β€’ Stability AI  β”‚
β”‚ β€’ File Upload   β”‚    β”‚ β€’ Stripe API    β”‚    β”‚ β€’ Recraft AI    β”‚
β”‚ β€’ Result View   β”‚    β”‚ β€’ Storage API   β”‚    β”‚ β€’ Stripe        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚   Supabase      β”‚
                    β”‚   Database      β”‚
                    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
                    β”‚ β€’ User Auth     β”‚
                    β”‚ β€’ Image Storage β”‚
                    β”‚ β€’ Edit History  β”‚
                    β”‚ β€’ Token Trackingβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Key Components

  • Canvas System: HTML5 Canvas with dual-layer architecture
  • Provider Pattern: Unified interface for multiple AI services
  • Floating UI: Draggable, responsive toolbar system
  • Authentication: Supabase Auth with SSR support
  • File Management: Secure upload and storage system

πŸ“š API Documentation

Image Generation Endpoint

POST /api/mask-edit-image
{
  "imageUrl": "string",
  "maskDataUrl": "string", 
  "prompt": "string",
  "provider": "openai" | "stability" | "recraft"
}

Provider Interface

interface ImageProvider {
  generateImage(params: GenerationParams): Promise<GenerationResult>
  validateInput(params: GenerationParams): ValidationResult
  getCapabilities(): ProviderCapabilities
}

πŸ› οΈ Development

Project Structure

ipaintai/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”œβ”€β”€ components/               # Shared components
β”‚   └── image-mask-editor/        # Main editor interface
β”œβ”€β”€ lib/                          # Utilities and configurations
β”‚   β”œβ”€β”€ providers/                # AI provider implementations
β”‚   └── supabase/                 # Database configuration
β”œβ”€β”€ memory-bank/                  # Project documentation
└── supabase/                     # Database migrations

Adding a New AI Provider

  1. Create provider class

    // lib/providers/NewProvider.ts
    export class NewProvider implements ImageProvider {
      async generateImage(params: GenerationParams) {
        // Implementation
      }
    }
  2. Register in factory

    // lib/providers/ImageProviderFactory.ts
    case 'new-provider':
      return new NewProvider();
  3. Update configuration

    // lib/config.ts
    export const AI_PROVIDERS = {
      'new-provider': { name: 'New Provider', ... }
    }

Running Tests

npm run test          # Run unit tests
npm run test:e2e      # Run end-to-end tests
npm run lint          # Check code style
npm run type-check    # TypeScript validation

🀝 Contributing

We welcome contributions from the community! Please see our Contributing Guidelines for details.

Ways to Contribute

  • πŸ› Bug Reports: Help us identify and fix issues
  • ✨ Feature Requests: Suggest new functionality
  • πŸ”§ Code Contributions: Implement features or fix bugs
  • πŸ“š Documentation: Improve guides and examples
  • πŸ§ͺ Testing: Add test coverage
  • 🎨 UI/UX: Enhance the user interface

Development Priorities

High Priority

  • Complete OpenAI ChatGPT-image-1 integration
  • Mobile optimization and touch support
  • Performance optimization for large images
  • Comprehensive testing framework

Medium Priority

  • Additional AI provider integrations
  • Advanced canvas features (zoom, layers)
  • Keyboard shortcuts and accessibility
  • Batch processing capabilities

Quick Contribution Guide

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and test them
  4. Commit: git commit -m 'Add amazing feature'
  5. Push: git push origin feature/amazing-feature
  6. Open a Pull Request

πŸ”’ Security

Important Security Notice

⚠️ This is currently a Proof of Concept and is NOT production-ready.

  • Development Only: Contains security vulnerabilities
  • API Key Protection: Never expose keys in frontend code
  • No Production Deployment: Requires security hardening

See our Security Policy for details on:

  • Reporting vulnerabilities
  • Security best practices
  • Production deployment considerations

API Key Setup

OpenAI (ChatGPT-image-1)

  1. Get API key from OpenAI Platform
  2. Important: Requires organization verification for ChatGPT-image-1 access
  3. Visit OpenAI Image Generation Guide

Stability AI

  1. Create account at Stability AI
  2. Get API key from Account Keys

Recraft AI

  1. Sign up at Recraft AI
  2. Generate API key from dashboard

πŸ“Š Project Status

Current State

  • Functionality: 95% complete
  • UI/UX: 98% complete with modern floating interface
  • Technical Quality: 94% complete with clean architecture
  • Documentation: 90% complete
  • Security: POC-level, needs production hardening

What's Working

  • βœ… Multi-provider AI integration (Stability AI, Recraft AI)
  • βœ… Advanced mask-based image editing
  • βœ… Modern floating toolbar interface
  • βœ… Complete authentication and user management
  • βœ… File upload, storage, and export
  • βœ… Responsive design and mobile support

What's Missing

  • ❌ OpenAI ChatGPT-image-1 provider implementation
  • ❌ Production security hardening
  • ❌ Comprehensive test coverage
  • ❌ Performance optimization for large images

🎯 Roadmap

Version 1.0 (Current)

  • Core image editing functionality
  • Multi-provider AI integration
  • Modern UI with floating toolbar
  • Authentication and user management
  • OpenAI ChatGPT-image-1 integration
  • Mobile optimization

Version 1.1 (Planned)

  • Advanced canvas features (zoom, pan, layers)
  • Keyboard shortcuts and accessibility
  • Performance optimizations
  • Comprehensive testing

Version 2.0 (Future)

  • Plugin system for extensibility
  • Batch processing capabilities
  • Advanced export options
  • Collaboration features

πŸ† Showcase

Key Features Demo

Floating Toolbar Interface

  • Draggable positioning anywhere on screen
  • Auto-docking to screen edges
  • Collapsible design with glassmorphism effects

AI-Powered Editing

  • Paint masks to define edit areas
  • Multiple AI providers for different styles
  • Real-time preview and comparison

Professional Workflow

  • Undo/redo with full history
  • Export in multiple formats
  • Seamless AI result integration

🌟 Community

Get Involved

  • GitHub Discussions: Ask questions and share ideas
  • Issues: Report bugs and request features
  • Pull Requests: Contribute code and improvements
  • Discord (coming soon): Real-time community chat

Recognition

We believe in recognizing our contributors:

  • All contributors listed in the README
  • Significant contributions highlighted in releases
  • Community spotlight in discussions

πŸ“„ License

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

πŸ™ Acknowledgments

  • OpenAI for ChatGPT-image-1 and API access
  • Stability AI for Stable Diffusion integration
  • Recraft AI for advanced image generation
  • Supabase for backend infrastructure
  • Next.js team for the excellent framework
  • Community contributors for their valuable input

πŸ“ž Support

  • Documentation: Check our comprehensive guides
  • GitHub Issues: Report bugs and request features
  • GitHub Discussions: Ask questions and get help
  • Security Issues: Follow our Security Policy

Built with ❀️ by the iPaintAI community

🌟 Star this repo β€’ πŸ› Report Bug β€’ ✨ Request Feature β€’ πŸ’¬ Discussions

About

POC nextjs integration of Open AI's latest image generation capability release April 2025. NOT PROD READY

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages