Recipe Hub follows a layered architecture with a clean separation of concerns. Data flows in one direction — from the external API through services and hooks into pages and finally into presentational components.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Miguelcds/Recipe-Hub/llms.txt
Use this file to discover all available pages before exploring further.
Data flow
Routing structure
Routing is configured insrc/main.jsx using React Router v7’s BrowserRouter, Routes, and Route components. The entire app is wrapped in FavoriteProvider so that favorites state is available on every page.
src/main.jsx
FavoriteProvider wraps BrowserRouter, not the other way around. This ensures favorites context is available to all pages rendered inside the router.App layout shell
App.jsx defines the persistent layout shared across all routes. It renders a header with the site title and navigation, a main content area using <Outlet /> (where child routes render), and a footer.
src/App.jsx
<Outlet /> is the React Router placeholder that renders the matched child route. All pages mount and unmount here while the header and footer remain constant.
Pages
Pages are route-level components. They own data fetching (via hooks) and compose presentational components to build their UI.| Page | Path | Responsibility |
|---|---|---|
Home | / | Displays search bar and recipe grid; uses useRecipes for fetch and random recipe logic |
RecipeDetail | /recipe/:id | Fetches and displays a single recipe; uses useRecipeDetail with the id URL param |
Favorites | /favorites | Reads favorite IDs from context, renders saved recipes |
Contact | /contact | Contact page (currently shows a placeholder message) |
NotFound | * | Shown for any unmatched route |
Architecture layers
| Layer | Location | Role |
|---|---|---|
| API service | src/services/api.js | Fetches from TheMealDB, validates responses, normalizes data shapes |
| Custom hooks | src/hooks/ | Manage loading, error, and data state for async operations |
| Context | src/context/ | Provides global state (favorites) shared across unrelated components |
| Pages | src/pages/ | Orchestrate hooks and compose components for each route |
| Components | src/components/ | Presentational; receive props and render UI with no direct API or hook calls |
Component composition pattern
Pages orchestrate; components are presentational. A page likeHome calls useRecipes, holds state, and passes data down:
RecipeDetailCard, which consumes useFavorites from context directly to toggle favorites inline.