An AI-powered image generator application that uses ComfyUI to create and refine images based on detailed prompts with optional reference images (avatars) for consistent character generation.
- AI Image Generation: Generate images using ComfyUI with multi-turn conversation support for refinements
- Prompt Builder: Intuitive UI to construct detailed prompts with location, lighting, camera angle, style, and subject options
- Avatar System: Upload reference images to maintain consistent characters/objects across generations
- Gallery: Browse generated images
- Framework: Next.js 16 (App Router) with React 19
- Database: PostgreSQL with Drizzle ORM
- AI: ComfyUI backend
- Storage: Vercel Blob (production) / local filesystem (development)
- UI: shadcn/ui with Tailwind CSS v4
- Node.js 18+
- PostgreSQL database
- pnpm (recommended)
-
Clone the repository:
git clone <repository-url> cd comfyui-image-generator
-
Install dependencies:
pnpm install
-
Set up environment variables:
cp env.example .env
-
Configure your
.envfile:# Database POSTGRES_URL="postgresql://username:password@localhost:5432/comfyui_generator" # App URL NEXT_PUBLIC_APP_URL="http://localhost:3000" # Optional: Vercel Blob storage (leave empty for local storage) BLOB_READ_WRITE_TOKEN=""
-
Set up the database:
pnpm db:migrate
-
Start the development server:
pnpm dev
- Create avatars by uploading reference images for consistent character generation
- Build your prompt using the Prompt Builder interface
- Generate images and refine them with follow-up prompts
- Browse the gallery to see all generated images
pnpm dev # Start dev server with Turbopack
pnpm build # Build for production
pnpm lint # Run ESLint
pnpm typecheck # Run TypeScript type checking
pnpm check # Run both lint and typecheck
pnpm format # Format code with Prettierpnpm db:push # Push schema changes (development)
pnpm db:generate # Generate migrations
pnpm db:migrate # Run migrations
pnpm db:studio # Open Drizzle Studio GUI
pnpm db:reset # Drop and recreate all tablessrc/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── gallery/ # Gallery page
│ └── avatars/ # Avatar management page
├── components/
│ ├── generate/ # Prompt builder and generation UI
│ └── ui/ # shadcn/ui components
├── hooks/ # Custom React hooks
│ ├── use-avatars.ts # Avatar management
│ ├── use-generation.ts # Image generation logic
│ └── use-prompt-builder.ts # Prompt builder state
└── lib/
├── schema.ts # Database schema
├── storage.ts # File storage abstraction
└── generate-stub.ts # Stub image generation
| Variable | Required | Description |
|---|---|---|
POSTGRES_URL |
Yes | PostgreSQL connection string |
NEXT_PUBLIC_APP_URL |
No | Application URL |
BLOB_READ_WRITE_TOKEN |
No | Vercel Blob token (uses local storage if not set) |
- Push your code to GitHub
- Import the project in Vercel
- Add environment variables
- Deploy
The application will automatically use Vercel Blob for storage when BLOB_READ_WRITE_TOKEN is configured.
MIT License - see LICENSE for details.