Files
Design-Buddy/docs/technical/ai/google/image-editing.md
Rosario Moscato 57361a3e34 feat: implement Design Buddy AI interior design application
- Replace boilerplate with complete Design Buddy application
- Add AI-powered room design generation using Google Gemini SDK
- Implement user authentication with Google OAuth via Better Auth
- Create credit system with 30 free credits for new users
- Build image upload interface with drag-and-drop functionality
- Add room type and design style selection (Living Room, Kitchen, etc.)
- Implement AI generation with geographical restriction handling
- Add credit refund system for API failures
- Create responsive landing page with feature sections
- Replace all branding and navigation with Design Buddy theme
- Add complete user dashboard with real-time credit balance
- Implement download functionality for generated designs

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-16 16:17:50 +02:00

1.6 KiB

// To run this code you need to install the following dependencies: // npm install @google/genai mime // npm install -D @types/node

import { GoogleGenAI, } from '@google/genai'; import mime from 'mime'; import { writeFile } from 'fs';

function saveBinaryFile(fileName: string, content: Buffer) { writeFile(fileName, content, 'utf8', (err) => { if (err) { console.error(Error writing file ${fileName}:, err); return; } console.log(File ${fileName} saved to file system.); }); }

async function main() { const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY, }); const config = { responseModalities: [ 'IMAGE', 'TEXT', ], }; const model = 'gemini-2.5-flash-image-preview'; const contents = [ { role: 'user', parts: [ { text: INSERT_INPUT_HERE, }, ], }, ];

const response = await ai.models.generateContentStream({ model, config, contents, }); let fileIndex = 0; for await (const chunk of response) { if (!chunk.candidates || !chunk.candidates[0].content || !chunk.candidates[0].content.parts) { continue; } if (chunk.candidates?.[0]?.content?.parts?.[0]?.inlineData) { const fileName = ENTER_FILE_NAME_${fileIndex++}; const inlineData = chunk.candidates[0].content.parts[0].inlineData; const fileExtension = mime.getExtension(inlineData.mimeType || ''); const buffer = Buffer.from(inlineData.data || '', 'base64'); saveBinaryFile(${fileName}.${fileExtension}, buffer); } else { console.log(chunk.text); } } }

main();