How liu-ziting/what-to-eat works
Project type and purpose
• This is a full-stack-style Single-Page Application (SPA) focused on “intelligent recipe generation” using AI.
• There is no custom backend server in the repo—everything runs in the browser (Vue 3 + TypeScript + Tailwind) and calls out to external AI APIs (302.AI for text, BigModel/智谱 AI for images).
• Core features: recipe generation, nutrition analysis, image generation, wine pairing, sauce design, favorites management, dynamic AI config, and a “food fortune” mini-game.
File structure
• Top-level:
• Public/statically served assets (public/, index.html)
• Config and build scripts (.env.example, netlify.toml, vercel.json, build.sh, deployment guides)
• Source code under src/
• src/ breakdown:
• views/ – page‐level Vue components (Home, Favorites, FortuneCooking, etc.)
• components/ – reusable UI building blocks (RecipeCard, SettingsModal, FloatingChefAssistant, etc.)
• services/ – API wrappers for AI text (aiService.ts), AI image (imageService.ts), favorites (favoriteService.ts), gallery (galleryService.ts)
• stores/ – runtime config state (settings.js persisted locally)
• config/ – static lookup data (cuisines, ingredients, sauces, default AI settings)
• utils/ – low‐level helpers (apiConfig, envWatcher)
• types/ – TS type definitions
• main.ts – SPA bootstrap and router mount
README for additional insights
• Tech stack: Vue 3.4, TS 5.3, Tailwind 3.4, Vite 5.0
• Deployment: Netlify & Vercel for static hosting
• AI services: dynamic config allowing runtime switching of base URLs, keys, models, temperature, timeouts
• Architectural notes: “Dynamic Config System,” “service layer,” “stores,” “views/components” separation
a. Main components
• Client Browser (SPA)
• UI Layer (Vue Views & Components)
• State Management (stores/settings, localStorage)
• Service Layer (aiService, imageService, favoriteService, galleryService)
• Utility Layer (apiConfig, envWatcher)
• External AI Providers (302.AI for text gen; BigModel/智谱 for image gen; any OpenAI‐compatible API)
• Deployment Platform (Vercel / Netlify serving static assets)
b. Relationships & interactions
• UI Layer binds to State Management (reads/writes settings, favorites)
• UI dispatches service calls via Service Layer → External AI Providers
• Service Layer uses Utility Layer (apiConfig) to assemble requests
• Responses flow back to Service Layer → State / UI for rendering
• User actions (save favorite) call favoriteService → localStorage
• Dynamic Config UI modifies store → envWatcher picks up changes → apiConfig updated at runtime
c. Architectural patterns & design principles
• MVVM (Vue views bound to reactive state in stores)
• Layered architecture: UI → State → Services → External APIs
• Separation of concerns:
• Components vs Views
• Service abstraction for API calls
• Utility modules for config management
• Runtime configurability & persistence of settings (demo of dynamic config)
d. Key technologies & frameworks
• Vue 3 + TypeScript
• Vite build
• Tailwind CSS styling
• Pinia or Vue-reactive store (settings.js)
• REST/HTTP client (fetch or axios inside services)
• LocalStorage for favorites & config persistence
• External AI APIs (OpenAI-compatible)
Key takeaways
• Layers: Presentation, State Management, Service Abstraction, Utilities, External APIs, Deployment
• Detail relationships: how config flows at runtime, how services decouple from UI, how state persists
• Every module from the file tree appears in the appropriate layer