How mharis0801/chef-ai works
Project Type and Purpose
• This is a single‐page AI‐powered recipe generator built with React and Vite.
• It lives entirely in the browser (static hosting on Netlify) and calls out to the Hugging Face AI API to generate recipes from user-provided ingredients.
File Structure Analysis
• Top-level config: package.json, vite.config.js, eslint.config.js
• Public assets: index.html, public/ (favicon, static images)
• Source code under src/:
• App.jsx, Header.jsx, Main1.jsx – high-level layout
• ai.js – encapsulates calls to the external Hugging Face AI service
• components/ – reusable UI pieces (IngredientsList, Recipe display, ThemeToggle)
• context/ThemeContext.jsx – global theming state
• index.css, main.jsx – entrypoint and global styles
Key Insights from README
• Core feature: generate a recipe from at least four ingredients
• Live deployment: static site served by Netlify
• External dependency: Hugging Face AI inference API
Main Components
a. Frontend (React SPA)
• UI Layer: Header, IngredientsList input, ThemeToggle, Recipe display
• State Management: ThemeContext (dark/light mode)
• Business Logic: ai.js module orchestrates API calls
b. External Service
• Hugging Face AI Inference API – receives JSON payload of ingredients, returns recipe text
c. Hosting/Delivery
• Netlify (or any static host) serves the compiled bundle
Component Interactions & Data Flow
• User enters ingredients in IngredientsList → Main1 (or App) collects input
• On submit, ai.js sends HTTP POST to Hugging Face endpoint
• Hugging Face returns generated recipe → ai.js resolves promise
• App updates state → Recipe component renders the result
• ThemeToggle dispatches actions to ThemeContext → UI theme updates
Architectural Patterns & Design Principles
• Unidirectional data flow (React hooks + context)
• Separation of concerns: UI components vs. API logic vs. global state
• Modular file organization (components, context, assets)