A modern, interactive meal recipe discovery application built with React and Vite. Browse meals by category, search for recipes, view detailed meal information, and save your favorite meals.
- Browse Meals: Explore a wide collection of meals from TheMealDB API
- Search Functionality: Real-time search as you type to find meals by name
- Category Filter: Filter meals by category (Seafood, Dessert, Breakfast, etc.)
- Favorites Management: Add and remove meals to/from your favorites
- Persistent Storage: Your favorites are saved in localStorage and persist across sessions
- Meal Details: View comprehensive meal information including:
- Ingredients with measurements
- Step-by-step cooking instructions
- Category and origin information
- Tags and related metadata
- YouTube video links for visual cooking guides
- Responsive Design: Fully responsive UI that works on desktop, tablet, and mobile devices
- Beautiful UI: Modern design with Tailwind CSS and Flowbite components
- React 18 - UI library
- Vite - Build tool and development server
- React Router DOM - Client-side routing
- Axios - HTTP client for API requests
- Tailwind CSS - Utility-first CSS framework
- Flowbite React - Pre-built React components
- React Icons - Icon library (FcHome, FcLike, FiHeart, FaHeart, etc.)
- TheMealDB API - Free API for meal and recipe data
- Base URL:
https://www.themealdb.com/api/json/v1/1
- Base URL:
- Node.js (v16 or higher)
- npm or yarn
-
Clone the repository (or extract the project folder)
cd MealApplication -
Install dependencies
npm install
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173(Vite default port)
- View initial meal suggestions
- Use the search bar to find meals by name (searches as you type)
- Click category buttons to filter meals
- Click "View Details" on any meal card to see full recipe
- Click the heart icon to add/remove meals from favorites
- View complete meal information
- See all ingredients with measurements
- Read step-by-step instructions
- Watch embedded YouTube cooking video
- Check origin, category, and tags
- Add or remove from favorites using the prominent button
- Access via "Favorites" in the navigation
- View all your saved favorite meals
- Click any meal to view its details
- Remove meals by toggling the heart icon in meal cards
MealApplication/
βββ public/ # Static assets
βββ src/
β βββ api/
β β βββ mealApi.js # API calls to TheMealDB
β βββ assets/ # Images and logos
β βββ components/ # Reusable components
β β βββ CategoryFilter.jsx # Category filtering buttons
β β βββ LoadingSpinner.jsx # Loading indicator
β β βββ MealCard.jsx # Individual meal card
β β βββ SearchBar.jsx # Search input
β β βββ TopNavbar.jsx # Navigation bar
β βββ context/
β β βββ FavoritesContext.jsx # Global favorites state
β βββ hooks/
β β βββ useFavorites.js # Favorites logic (legacy - use context)
β βββ pages/
β β βββ Home.jsx # Main page with search & filter
β β βββ Favorites.jsx # Favorites listing page
β β βββ MealDetails.jsx # Detailed meal view
β β βββ Error.jsx # 404 error page
β βββ App.jsx # Main app component with routing
β βββ main.jsx # Entry point
β βββ index.css # Global styles
βββ package.json # Dependencies
βββ vite.config.js # Vite configuration
βββ eslint.config.js # ESLint configuration
βββ README.md # This file
Fetch Categories
GET /categories.phpReturns all meal categories available in the database.
Search Meals
GET /search.php?s={meal_name}Search meals by name. Returns array of matching meals.
Fetch Meals by Category
GET /filter.php?c={category_name}Get all meals in a specific category.
Fetch Meal Details
GET /lookup.php?i={meal_id}Get complete details for a specific meal including ingredients and instructions.
Fetch Initial Meals (on page load)
GET /search.php?s=Returns a random set of meals for initial display.
- Displays category buttons for filtering
- Shows selected state with visual feedback
- Calls parent's
onCategorySelectcallback
- Real-time search input
- Triggers search on change (onChange event)
- Prevents default form submission
- Displays meal image, name, and controls
- "View Details" link to meal details page
- Heart icon button to toggle favorites
- Uses FavoritesContext for state management
- Shows loading indicator during data fetching
- Used on initial load and API calls
- Navigation with logo and links
- Links to Home and Favorites pages
- Sticky positioning
- Full meal information display
- Image, ingredients list, instructions
- YouTube video embed
- Add/remove from favorites button
- Back button to return to previous page
- Manages favorite meals across entire application
- Persists to localStorage automatically
- Provides
toggleFavorite()andisFavorite()methods
- Individual component state for UI interactions (loading, search query, selected category)
- Implemented with
onChangehandler in SearchBar - Instantly updates meal display without page reload
- Handles empty results gracefully
- Fetches meals by selected category
- Maintains UI state to show selected category
- Can reset to "All" to show initial meals
- Uses browser's localStorage API
- Automatically saves when favorites change
- Loads on app startup via context initialization
- Works across browser sessions and tabs
Development Server
npm run devBuild for Production
npm run buildPreview Production Build
npm run previewLint Code
npm run lint- β Fixed null reference errors when meal data loads
- β Fixed nested anchor tags (hydration error)
- β Fixed multiple favorites only storing the last one (context state management)
- β Fixed page reload on category filter click (LoadingSpinner logic)
- β Added proper API base URL with HTTPS protocol
- User authentication and cloud-based favorites sync
- Recipe rating and review system
- Dietary restrictions filter (vegan, keto, etc.)
- Meal planning and weekly schedule
- Social sharing functionality
- Dark mode support
- Recipe print functionality
- Shopping list generator from ingredients
This project is part of a learning curriculum. The meal data is provided by TheMealDB which is free to use.
Created as a mini project for frontend development learning.
Happy cooking! π½οΈ