3.0 KiB
3.0 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Banatie is a REST API service for AI-powered image generation using the Gemini Flash Image model. It's built with Express.js and TypeScript, providing endpoints to generate images from text prompts with optional reference images.
Development Commands
Core Development
pnpm dev- Start development server with auto-reload using tsxpnpm start- Start production server (runs build first)pnpm build- Build TypeScript to JavaScript in ./distpnpm typecheck- Run TypeScript type checking without emitting files
Code Quality
pnpm lint- Run ESLint on all TypeScript files in src/pnpm lint:fix- Run ESLint with auto-fixpnpm format- Format code with Prettierpnpm format:check- Check if code is formatted correctly
Testing
pnpm test- Run Jest testspnpm test:watch- Run tests in watch modepnpm test:coverage- Run tests with coverage report
Architecture
Core Structure
- Express App: Configured in
src/app.tswith middleware, CORS, and route mounting - Server Entry:
src/server.tsstarts the HTTP server - Image Generation:
src/services/ImageGenService.tshandles Gemini AI integration - Route Handling:
src/routes/generate.tscontains the main API endpoint logic
Middleware Stack
src/middleware/upload.ts- Multer configuration for file uploads (max 3 files, 5MB each)src/middleware/validation.ts- Express-validator for request validationsrc/middleware/errorHandler.ts- Centralized error handling and 404 responses
TypeScript Configuration
- Path aliases configured in tsconfig.json:
@/*maps tosrc/*@/types/*maps tosrc/types/*@/services/*maps tosrc/services/*@/middleware/*maps tosrc/middleware/*@/routes/*maps tosrc/routes/*@/utils/*maps tosrc/utils/*
File Handling
- Uploads: Temporary files stored in
./uploads/temp - Results: Generated images saved to
./results - Logs: Application logs in
./logs
Environment Configuration
Required environment variables:
GEMINI_API_KEY- Google Gemini API key (required)PORT- Server port (default: 3000)NODE_ENV- Environment modeCORS_ORIGIN- CORS origin setting (default: *)
Key Dependencies
- @google/genai - Google Gemini AI client
- express v5 - Web framework
- multer - File upload handling
- express-validator - Request validation
- winston - Logging
- helmet - Security middleware
- express-rate-limit - Rate limiting
API Endpoints
GET /health- Health check with uptime and statusGET /api/info- API information and limitsPOST /api/generate- Main image generation endpoint (multipart/form-data)
Development Notes
- Uses pnpm as package manager (required >= 8.0.0)
- Node.js >= 18.0.0 required
- TypeScript with strict mode enabled
- ESLint configured with TypeScript and Prettier integration
- Jest for testing with ts-jest preset