How aadityageek/ai-image-generator works
Project type and purpose
• This is a single-page web application (frontend only in this repo) that provides a clean HTML/CSS/Vanilla JS interface for generating AI images.
• It relies on a custom backend API (hosted on Render.com) which in turn orchestrates calls to various AI model services (Stable Diffusion, FLUX.1, OpenJourney, etc.).
File structure
• index.html: the entry point. Contains the DOM skeleton for theme toggle, prompt input, model dropdown, aspect-ratio selector, gallery container and fullscreen overlay.
• style.css: global and component styles (responsive grid, light/dark theme, mobile breakpoints).
• script.js: all UI logic (event handlers, theme detection, prompt validation), network logic (fetch to BACKEND_URL), and DOM updates (loading spinner, error states, image rendering, zoom, download).
README for insights
• Confirms feature set (model support, aspect ratios, multiple images, responsive design, fullscreen/zoom/download).
Main components
a. Browser / Client (UI Layer)
– Theme Manager: system-pref light/dark switch
– Prompt & Settings Form: text area, model & ratio selectors, “Generate” button
– Gallery UI: grid layout, loading spinners, error messages, fullscreen & zoom handlers, download link generator
– Network Module: JS fetch wrapper calling the backend API
b. Static Asset Host (optional)
– GitHub Pages, Netlify or Render static site for serving index.html, style.css, script.js, and screenshots
– CDN for Font Awesome & Google Fonts
c. Backend API Endpoint (Render.com)
– Exposes RESTful POST /generate with payload { prompt, model, aspectRatio, count }
– Returns JSON with image URLs or error codes
d. AI Model Services (External)
– Calls to AI inference engines: Stable Diffusion variants, FLUX.1, OpenJourney, etc.
– Could be microservices or third-party hosted inference APIs
Relationships and data flows
1. User loads index.html → browser requests static assets from Hosting/CDN
2. Browser initializes UI & theme
3. User submits prompt → Network Module sends POST to Backend API
4. Backend API → orchestrates calls to AI Model Services → returns images (URLs or base64)
5. Browser receives JSON → Gallery UI renders images → User can fullscreen, zoom, download
Architectural patterns and design principles
• Client-Server separation: clear division between static frontend assets and dynamic AI orchestration in the backend
• Single-page application pattern: UI updates in place without full page reloads
• RESTful HTTP layer between front and back end
• Responsive design: mobile-first CSS grid and breakpoints
• Feature-slice decomposition in the frontend: theme, form, gallery, network modules