How arthurogunfiye/chatgpt-mern-react-course works
This repository is a small React storefront: shoppers search and filter a sample catalogue, inspect product cards, and manage a cart whose state is persisted in browser localStorage. App coordinates the user-facing flow; CartContext and its reducer own cart state. The README describes only the Vite template, so product capabilities are inferred from the sampled source and source index. Unsampled component behavior is not assumed beyond documented imports and the props App passes.
Main entry points: App.jsx App coordinator · CartContext.jsx Cart context · loadSavedCart.js Saved cart loader · cartReducer.js Cart reducer
Components 22
Storefront UI
- App coordinator
src/App.jsx - Header
src/components/Header.jsx - Navigation
src/components/Nav.jsx - Welcome panel
src/components/Welcome.jsx - Footer
src/components/Footer.jsx
Product discovery
- Search bar
src/components/SearchBar.jsx - Search term state
src/hooks/useSearchTerm.js - Search debounce
src/hooks/useDebouncedValue.js - Product filters
src/components/ProductFilters.jsx - Visible product selector
src/utils/selectVisibleProducts.js - Product catalogue
src/components/ProductCatalogue.jsx - Product card
src/components/ProductCard.jsx
Cart state
- Cart context
src/context/CartContext.jsx - Cart reducer
src/reducers/cartReducer.js - Saved cart loader
src/utils/loadSavedCart.js - Browser localStorage
- Cart summary
src/components/CartSummary.jsx - Cart item
src/components/CartItem.jsx
Domain logic
- Sample products
src/data/sampleProducts.js - Sale pricing
src/utils/getSalePrice.js - Price formatting
src/utils/formatPrice.js
Other components
- Shopper
Connections 32
- Shopper → App coordinator: uses storefront
src/App.jsx - App coordinator → Header: renders
src/App.jsx - App coordinator → Search bar: renders
src/App.jsx - App coordinator → Product filters: renders
src/App.jsx - App coordinator → Product catalogue: renders
src/App.jsx - App coordinator → Cart summary: renders
src/App.jsx - App coordinator → Footer: renders
src/App.jsx - Header → Navigation: renders
src/components/Header.jsx - Header → Welcome panel: renders
src/components/Header.jsx - App coordinator → Search term state: reads state
src/App.jsx - App coordinator → Search debounce: debounces term
src/App.jsx - Search bar → Search term state: updates term
src/App.jsx - App coordinator → Visible product selector: selects products
src/App.jsx - App coordinator → Sample products: filters catalogue
src/App.jsx - Product filters → App coordinator: updates filter state
src/App.jsx - App coordinator → Cart context: reads cart state
src/App.jsx - App coordinator → Cart reducer: dispatches cart actions
src/App.jsx - Product catalogue → Product card: renders cards
src/components/ProductCatalogue.jsx - Product card → Price formatting: formats amount
src/components/ProductCard.jsx - Product card → Sale pricing: calculates sale price
src/components/ProductCard.jsx - Cart context → Cart reducer: reduces actions
src/context/CartContext.jsx - Cart context → Saved cart loader: loads initial cart
src/context/CartContext.jsx - Cart context → Browser localStorage: persists cart
src/context/CartContext.jsx - Saved cart loader → Browser localStorage: reads saved cart
src/utils/loadSavedCart.js - Saved cart loader → Sample products: validates items
src/utils/loadSavedCart.js - Saved cart loader → Sale pricing: prices restored items
src/utils/loadSavedCart.js - Cart reducer → Sample products: checks stock
src/reducers/cartReducer.js - Cart reducer → Sale pricing: prices added items
src/reducers/cartReducer.js - Cart summary → Cart item: renders entries
src/components/CartSummary.jsx - Cart summary → Price formatting: formats total
src/components/CartSummary.jsx - Cart item → Price formatting: formats item price
src/components/CartItem.jsx - Visible product selector → Sale pricing: sorts by sale price
src/utils/selectVisibleProducts.js