# arthurogunfiye/chatgpt-mern-react-course architecture

> Architecture diagram of the GitHub repository arthurogunfiye/chatgpt-mern-react-course, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arthurogunfiye/chatgpt-mern-react-course
- Repository: https://github.com/arthurogunfiye/chatgpt-mern-react-course

## Overview

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: [`src/App.jsx`](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/App.jsx) (App coordinator), [`src/context/CartContext.jsx`](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/context/CartContext.jsx) (Cart context), [`src/utils/loadSavedCart.js`](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/loadSavedCart.js) (Saved cart loader), [`src/reducers/cartReducer.js`](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/reducers/cartReducer.js) (Cart reducer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront UI"]
  node_app["App coordinator<br/>[App.jsx]"]
  node_header["Header<br/>[Header.jsx]"]
  node_navigation["Navigation<br/>[Nav.jsx]"]
  node_welcome["Welcome panel<br/>[Welcome.jsx]"]
  node_footer["Footer<br/>[Footer.jsx]"]
end

subgraph group_catalogue["Product discovery"]
  node_searchbar["Search bar<br/>[SearchBar.jsx]"]
  node_searchterm["Search term state<br/>[useSearchTerm.js]"]
  node_debounce["Search debounce"]
  node_filters["Product filters<br/>[ProductFilters.jsx]"]
  node_selection["Visible product selector"]
  node_catalogueview["Product catalogue"]
  node_productcard["Product card<br/>[ProductCard.jsx]"]
end

subgraph group_cart["Cart state"]
  node_cartcontext["Cart context<br/>[CartContext.jsx]"]
  node_reducer["Cart reducer<br/>[cartReducer.js]"]
  node_storage["Saved cart loader<br/>[loadSavedCart.js]"]
  node_browserstore[("Browser localStorage")]
  node_summary["Cart summary<br/>[CartSummary.jsx]"]
  node_cartitem["Cart item<br/>[CartItem.jsx]"]
end

subgraph group_logic["Domain logic"]
  node_products["Sample products<br/>[sampleProducts.js]"]
  node_saleprice["Sale pricing<br/>[getSalePrice.js]"]
  node_formatprice["Price formatting<br/>[formatPrice.js]"]
end

node_shopper(("Shopper"))

node_shopper -->|"uses storefront"| node_app
node_app -->|"renders"| node_header
node_app -->|"renders"| node_searchbar
node_app -->|"renders"| node_filters
node_app -->|"renders"| node_catalogueview
node_app -->|"renders"| node_summary
node_app -->|"renders"| node_footer
node_header -->|"renders"| node_navigation
node_header -->|"renders"| node_welcome
node_app -->|"reads state"| node_searchterm
node_app -->|"debounces term"| node_debounce
node_searchbar -->|"updates term"| node_searchterm
node_app -->|"selects products"| node_selection
node_app -->|"filters catalogue"| node_products
node_filters -->|"updates filter state"| node_app
node_app -->|"reads cart state"| node_cartcontext
node_app -->|"dispatches cart actions"| node_reducer
node_catalogueview -->|"renders cards"| node_productcard
node_productcard -->|"formats amount"| node_formatprice
node_productcard -->|"calculates sale price"| node_saleprice
node_cartcontext -->|"reduces actions"| node_reducer
node_cartcontext -->|"loads initial cart"| node_storage
node_cartcontext -->|"persists cart"| node_browserstore
node_storage -->|"reads saved cart"| node_browserstore
node_storage -->|"validates items"| node_products
node_storage -->|"prices restored items"| node_saleprice
node_reducer -->|"checks stock"| node_products
node_reducer -->|"prices added items"| node_saleprice
node_summary -->|"renders entries"| node_cartitem
node_summary -->|"formats total"| node_formatprice
node_cartitem -->|"formats item price"| node_formatprice
node_selection -->|"sorts by sale price"| node_saleprice

click node_app "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/App.jsx"
click node_header "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Header.jsx"
click node_navigation "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Nav.jsx"
click node_welcome "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Welcome.jsx"
click node_footer "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Footer.jsx"
click node_searchbar "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/SearchBar.jsx"
click node_searchterm "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/hooks/useSearchTerm.js"
click node_debounce "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/hooks/useDebouncedValue.js"
click node_filters "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductFilters.jsx"
click node_selection "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/selectVisibleProducts.js"
click node_catalogueview "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductCatalogue.jsx"
click node_productcard "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductCard.jsx"
click node_products "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/data/sampleProducts.js"
click node_cartcontext "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/context/CartContext.jsx"
click node_reducer "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/reducers/cartReducer.js"
click node_storage "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/loadSavedCart.js"
click node_summary "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/CartSummary.jsx"
click node_cartitem "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/CartItem.jsx"
click node_saleprice "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/getSalePrice.js"
click node_formatprice "https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/formatPrice.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_header,node_navigation,node_welcome,node_footer toneBlue
class node_searchbar,node_searchterm,node_debounce,node_filters,node_selection,node_catalogueview,node_productcard toneAmber
class node_cartcontext,node_reducer,node_storage,node_browserstore,node_summary,node_cartitem toneMint
class node_products,node_saleprice,node_formatprice toneRose
class node_shopper toneIndigo
```

## Components

### Storefront UI

- [App coordinator](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/App.jsx): `src/App.jsx`
- [Header](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Header.jsx): `src/components/Header.jsx`
- [Navigation](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Nav.jsx): `src/components/Nav.jsx`
- [Welcome panel](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Welcome.jsx): `src/components/Welcome.jsx`
- [Footer](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/Footer.jsx): `src/components/Footer.jsx`

### Product discovery

- [Search bar](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/SearchBar.jsx): `src/components/SearchBar.jsx`
- [Search term state](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/hooks/useSearchTerm.js): `src/hooks/useSearchTerm.js`
- [Search debounce](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/hooks/useDebouncedValue.js): `src/hooks/useDebouncedValue.js`
- [Product filters](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductFilters.jsx): `src/components/ProductFilters.jsx`
- [Visible product selector](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/selectVisibleProducts.js): `src/utils/selectVisibleProducts.js`
- [Product catalogue](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductCatalogue.jsx): `src/components/ProductCatalogue.jsx`
- [Product card](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/ProductCard.jsx): `src/components/ProductCard.jsx`

### Cart state

- [Cart context](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/context/CartContext.jsx): `src/context/CartContext.jsx`
- [Cart reducer](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/reducers/cartReducer.js): `src/reducers/cartReducer.js`
- [Saved cart loader](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/loadSavedCart.js): `src/utils/loadSavedCart.js`
- **Browser localStorage**
- [Cart summary](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/CartSummary.jsx): `src/components/CartSummary.jsx`
- [Cart item](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/components/CartItem.jsx): `src/components/CartItem.jsx`

### Domain logic

- [Sample products](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/data/sampleProducts.js): `src/data/sampleProducts.js`
- [Sale pricing](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/getSalePrice.js): `src/utils/getSalePrice.js`
- [Price formatting](https://github.com/arthurogunfiye/chatgpt-mern-react-course/blob/main/src/utils/formatPrice.js): `src/utils/formatPrice.js`

### Other components

- **Shopper**

## Connections

- Shopper → App coordinator: uses storefront (evidence: `src/App.jsx`)
- App coordinator → Header: renders (evidence: `src/App.jsx`)
- App coordinator → Search bar: renders (evidence: `src/App.jsx`)
- App coordinator → Product filters: renders (evidence: `src/App.jsx`)
- App coordinator → Product catalogue: renders (evidence: `src/App.jsx`)
- App coordinator → Cart summary: renders (evidence: `src/App.jsx`)
- App coordinator → Footer: renders (evidence: `src/App.jsx`)
- Header → Navigation: renders (evidence: `src/components/Header.jsx`)
- Header → Welcome panel: renders (evidence: `src/components/Header.jsx`)
- App coordinator → Search term state: reads state (evidence: `src/App.jsx`)
- App coordinator → Search debounce: debounces term (evidence: `src/App.jsx`)
- Search bar → Search term state: updates term (evidence: `src/App.jsx`)
- App coordinator → Visible product selector: selects products (evidence: `src/App.jsx`)
- App coordinator → Sample products: filters catalogue (evidence: `src/App.jsx`)
- Product filters → App coordinator: updates filter state (evidence: `src/App.jsx`)
- App coordinator → Cart context: reads cart state (evidence: `src/App.jsx`)
- App coordinator → Cart reducer: dispatches cart actions (evidence: `src/App.jsx`)
- Product catalogue → Product card: renders cards (evidence: `src/components/ProductCatalogue.jsx`)
- Product card → Price formatting: formats amount (evidence: `src/components/ProductCard.jsx`)
- Product card → Sale pricing: calculates sale price (evidence: `src/components/ProductCard.jsx`)
- Cart context → Cart reducer: reduces actions (evidence: `src/context/CartContext.jsx`)
- Cart context → Saved cart loader: loads initial cart (evidence: `src/context/CartContext.jsx`)
- Cart context → Browser localStorage: persists cart (evidence: `src/context/CartContext.jsx`)
- Saved cart loader → Browser localStorage: reads saved cart (evidence: `src/utils/loadSavedCart.js`)
- Saved cart loader → Sample products: validates items (evidence: `src/utils/loadSavedCart.js`)
- Saved cart loader → Sale pricing: prices restored items (evidence: `src/utils/loadSavedCart.js`)
- Cart reducer → Sample products: checks stock (evidence: `src/reducers/cartReducer.js`)
- Cart reducer → Sale pricing: prices added items (evidence: `src/reducers/cartReducer.js`)
- Cart summary → Cart item: renders entries (evidence: `src/components/CartSummary.jsx`)
- Cart summary → Price formatting: formats total (evidence: `src/components/CartSummary.jsx`)
- Cart item → Price formatting: formats item price (evidence: `src/components/CartItem.jsx`)
- Visible product selector → Sale pricing: sorts by sale price (evidence: `src/utils/selectVisibleProducts.js`)
