How kesavgopan10/ai-prompt-artisan works
Project type and purpose
• This is a single-page frontend application built with React (TypeScript) and Vite.
• Purpose: Let users enter ideas via text, voice, or drawings, call Google Gemini’s API to refine those ideas into optimized prompts (generic/chatbot/image), and display/save the results.
File structure
• Top-level entries:
• App.tsx / index.tsx / index.html: root of the React SPA
• components/: all presentational and container React components
• hooks/: custom React hooks (speech recognition)
• services/: API interaction layer (geminiService.ts)
• types.ts / metadata.json: shared data definitions
• config files: package.json, tsconfig.json, vite.config.ts
• No separate backend—everything runs client-side and calls the external Gemini API
• Settings, Favorites, and Input/Output areas are modularized into their own components
README for additional insights
• Multi-modal input (text, Web Speech API, canvas drawing)
• Uses Google Gemini API (gemini-2.5-flash preview)
• Two modes of API use: direct text vs. multi-modal for drawings
• Persists API key in local storage (encrypted) or via .env
• UI styling: Tailwind CSS; animations: Framer Motion
a. Main components:
• Browser / React SPA
• Presentation Layer (React components: InputArea, DrawingCanvas, OutputArea, Favorites, SettingsModal)
• Hooks Layer (useSpeechRecognition)
• Service Layer (geminiService)
• Data Storage (Local Storage for favorites & API key)
• External Service (Google Gemini API)
• Build Tool (Vite)
b. Relationships & interactions:
1. User enters input in the UI (text, voice, drawing).
2. If voice → useSpeechRecognition hook converts speech to text.
3. If drawing → DrawingCanvas exports JPEG blob → geminiService sends to Gemini multimodal endpoint → receives descriptive text.
4. Text (direct or converted) → geminiService sends to Gemini chat endpoint with a system prompt → receives JSON with three prompt variations.
5. UI parses JSON and displays in OutputArea; user may save to Favorites (writes to Local Storage).
6. SettingsModal reads/writes API key to Local Storage; geminiService reads key before API calls.
c. Architectural patterns & principles:
• Layered architecture (Presentation → Hooks → Service → External API)
• Single responsibility: each component/hook/service has a clear role
• Separation of concerns: UI vs. business logic vs. data access
d. Technologies/frameworks:
• React 19 + TypeScript for UI
• Vite for bundling and dev server
• Web Speech API for voice input
• Canvas API (via React) for drawing
• Google Gemini API for AI processing
• Tailwind CSS for styling, Framer Motion for animations
• Browser Local Storage for persistence