# vicktor349/nestmart architecture

> Architecture diagram of the GitHub repository vicktor349/nestmart, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vicktor349/nestmart
- Repository: https://github.com/vicktor349/nestmart

## Overview

This is a Next.js storefront with product discovery and detail pages, a client-side cart, Supabase-backed accounts and favourites, and Paystack checkout endpoints. The visible workflow runs from storefront product discovery through product detail and cart; checkout and payment verification are represented as distinct stages. The source index supports several page-to-component relationships, but checkout-to-Paystack invocation is not shown, so that connection is marked unverified. Other unsampled page behavior is kept at the page level.

Main entry points: [`helpers/supabase.js`](https://github.com/vicktor349/nestmart/blob/master/helpers/supabase.js) (Supabase client), [`pages/fullproduct/[id].js`](https://github.com/vicktor349/nestmart/blob/master/pages/fullproduct/%5Bid%5D.js) (Product details), [`components/CartContext.js`](https://github.com/vicktor349/nestmart/blob/master/components/CartContext.js) (Cart state), [`components/userContext.js`](https://github.com/vicktor349/nestmart/blob/master/components/userContext.js) (User session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home storefront<br/>[index.js]"]
  node_shop["Shop catalog<br/>[shop.js]"]
  node_search["Search results<br/>[searchpage.js]"]
  node_searchdata["Catalog search<br/>[SearchDatabase.js]"]
  node_product["Product details<br/>[&#91;id&#93;.js]"]
  node_bestproduct["Best seller details<br/>[&#91;id&#93;.js]"]
  node_relatedpage["Related product page<br/>[&#91;id&#93;.js]"]
  node_recommendations["Related products<br/>[RelatedProducts.js]"]
end

subgraph group_commerce["Commerce"]
  node_cartstate["Cart state<br/>[CartContext.js]"]
  node_cart["Cart and checkout<br/>[cart.js]"]
  node_callback["Checkout callback<br/>[callback.js]"]
  node_payinit["Payment initialization<br/>[initialize.js]"]
  node_payverify["Payment verification<br/>[verify.js]"]
end

subgraph group_accounts["Accounts"]
  node_userstate["User session<br/>[userContext.js]"]
  node_favourites["Favourites state"]
  node_profile["Profile management<br/>[Profile.js]"]
  node_orders["Order dashboard<br/>[Order.js]"]
  node_dashboard["Account dashboard<br/>[dashboard.js]"]
end

subgraph group_backend["Backend"]
  node_supabase["Supabase client<br/>[supabase.js]"]
  node_supabase_service[("Supabase backend")]
  node_localstorage[("Browser cart storage")]
end

node_shopper(("Shopper"))

node_shopper -->|"opens storefront"| node_home
node_home -.->|"opens details"| node_product
node_home -.->|"browses catalog"| node_shop
node_shopper -->|"searches catalog"| node_search
node_search -->|"requests matches"| node_searchdata
node_searchdata -->|"queries catalog"| node_supabase
node_product -->|"loads product"| node_supabase
node_bestproduct -->|"loads product"| node_supabase
node_product -->|"adds item"| node_cartstate
node_product -->|"toggles favourite"| node_favourites
node_product -->|"renders recommendations"| node_recommendations
node_bestproduct -->|"renders recommendations"| node_recommendations
node_relatedpage -->|"renders products"| node_recommendations
node_shop -->|"uses cart"| node_cartstate
node_cart -->|"manages items"| node_cartstate
node_cartstate -->|"persists cart"| node_localstorage
node_cart -.->|"continues checkout"| node_callback
node_callback -.->|"starts payment"| node_payinit
node_callback -.->|"verifies payment"| node_payverify
node_userstate -->|"authenticates user"| node_supabase
node_favourites -->|"reads session"| node_userstate
node_favourites -->|"stores favourites"| node_supabase
node_profile -->|"reads session"| node_userstate
node_profile -->|"updates profile"| node_supabase
node_orders -->|"loads orders"| node_supabase
node_dashboard -->|"uses session"| node_userstate
node_supabase -->|"connects client"| node_supabase_service

click node_home "https://github.com/vicktor349/nestmart/blob/master/pages/index.js"
click node_shop "https://github.com/vicktor349/nestmart/blob/master/pages/shop.js"
click node_search "https://github.com/vicktor349/nestmart/blob/master/pages/searchpage.js"
click node_searchdata "https://github.com/vicktor349/nestmart/blob/master/components/SearchDatabase.js"
click node_product "https://github.com/vicktor349/nestmart/blob/master/pages/fullproduct/%5Bid%5D.js"
click node_bestproduct "https://github.com/vicktor349/nestmart/blob/master/pages/bestsellingproduct/%5Bid%5D.js"
click node_relatedpage "https://github.com/vicktor349/nestmart/blob/master/pages/relatedproduct/%5Bid%5D.js"
click node_recommendations "https://github.com/vicktor349/nestmart/blob/master/components/RelatedProducts.js"
click node_cartstate "https://github.com/vicktor349/nestmart/blob/master/components/CartContext.js"
click node_cart "https://github.com/vicktor349/nestmart/blob/master/pages/cart.js"
click node_callback "https://github.com/vicktor349/nestmart/blob/master/pages/checkout/callback.js"
click node_payinit "https://github.com/vicktor349/nestmart/blob/master/pages/api/paystack/initialize.js"
click node_payverify "https://github.com/vicktor349/nestmart/blob/master/pages/api/paystack/verify.js"
click node_userstate "https://github.com/vicktor349/nestmart/blob/master/components/userContext.js"
click node_favourites "https://github.com/vicktor349/nestmart/blob/master/components/FavouritesContext.js"
click node_profile "https://github.com/vicktor349/nestmart/blob/master/components/dashboard/Profile.js"
click node_orders "https://github.com/vicktor349/nestmart/blob/master/components/dashboard/Order.js"
click node_dashboard "https://github.com/vicktor349/nestmart/blob/master/pages/dashboard.js"
click node_supabase "https://github.com/vicktor349/nestmart/blob/master/helpers/supabase.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_home,node_shop,node_search,node_searchdata,node_product,node_bestproduct,node_relatedpage,node_recommendations toneBlue
class node_cartstate,node_cart,node_callback,node_payinit,node_payverify toneAmber
class node_userstate,node_favourites,node_profile,node_orders,node_dashboard toneMint
class node_supabase,node_supabase_service,node_localstorage toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Home storefront](https://github.com/vicktor349/nestmart/blob/master/pages/index.js): `pages/index.js`
- [Shop catalog](https://github.com/vicktor349/nestmart/blob/master/pages/shop.js): `pages/shop.js`
- [Search results](https://github.com/vicktor349/nestmart/blob/master/pages/searchpage.js): `pages/searchpage.js`
- [Catalog search](https://github.com/vicktor349/nestmart/blob/master/components/SearchDatabase.js): `components/SearchDatabase.js`
- [Product details](https://github.com/vicktor349/nestmart/blob/master/pages/fullproduct/%5Bid%5D.js): `pages/fullproduct/[id].js`
- [Best seller details](https://github.com/vicktor349/nestmart/blob/master/pages/bestsellingproduct/%5Bid%5D.js): `pages/bestsellingproduct/[id].js`
- [Related product page](https://github.com/vicktor349/nestmart/blob/master/pages/relatedproduct/%5Bid%5D.js): `pages/relatedproduct/[id].js`
- [Related products](https://github.com/vicktor349/nestmart/blob/master/components/RelatedProducts.js): `components/RelatedProducts.js`

### Commerce

- [Cart state](https://github.com/vicktor349/nestmart/blob/master/components/CartContext.js): `components/CartContext.js`
- [Cart and checkout](https://github.com/vicktor349/nestmart/blob/master/pages/cart.js): `pages/cart.js`
- [Checkout callback](https://github.com/vicktor349/nestmart/blob/master/pages/checkout/callback.js): `pages/checkout/callback.js`
- [Payment initialization](https://github.com/vicktor349/nestmart/blob/master/pages/api/paystack/initialize.js): `pages/api/paystack/initialize.js`
- [Payment verification](https://github.com/vicktor349/nestmart/blob/master/pages/api/paystack/verify.js): `pages/api/paystack/verify.js`

### Accounts

- [User session](https://github.com/vicktor349/nestmart/blob/master/components/userContext.js): `components/userContext.js`
- [Favourites state](https://github.com/vicktor349/nestmart/blob/master/components/FavouritesContext.js): `components/FavouritesContext.js`
- [Profile management](https://github.com/vicktor349/nestmart/blob/master/components/dashboard/Profile.js): `components/dashboard/Profile.js`
- [Order dashboard](https://github.com/vicktor349/nestmart/blob/master/components/dashboard/Order.js): `components/dashboard/Order.js`
- [Account dashboard](https://github.com/vicktor349/nestmart/blob/master/pages/dashboard.js): `pages/dashboard.js`

### Backend

- [Supabase client](https://github.com/vicktor349/nestmart/blob/master/helpers/supabase.js): `helpers/supabase.js`
- **Supabase backend**
- **Browser cart storage**

### Other components

- **Shopper**

## Connections

- Shopper → Home storefront: opens storefront (evidence: `pages/index.js`)
- Home storefront → Product details: opens details
- Home storefront → Shop catalog: browses catalog
- Shopper → Search results: searches catalog (evidence: `pages/searchpage.js`)
- Search results → Catalog search: requests matches (evidence: `pages/searchpage.js`)
- Catalog search → Supabase client: queries catalog (evidence: `components/SearchDatabase.js`)
- Product details → Supabase client: loads product (evidence: `pages/fullproduct/[id].js`)
- Best seller details → Supabase client: loads product (evidence: `pages/bestsellingproduct/[id].js`)
- Product details → Cart state: adds item (evidence: `pages/fullproduct/[id].js`)
- Product details → Favourites state: toggles favourite (evidence: `pages/fullproduct/[id].js`)
- Product details → Related products: renders recommendations (evidence: `pages/fullproduct/[id].js`)
- Best seller details → Related products: renders recommendations (evidence: `pages/bestsellingproduct/[id].js`)
- Related product page → Related products: renders products (evidence: `pages/relatedproduct/[id].js`)
- Shop catalog → Cart state: uses cart
- Cart and checkout → Cart state: manages items (evidence: `pages/cart.js`)
- Cart state → Browser cart storage: persists cart (evidence: `components/CartContext.js`)
- Cart and checkout → Checkout callback: continues checkout
- Checkout callback → Payment initialization: starts payment
- Checkout callback → Payment verification: verifies payment
- User session → Supabase client: authenticates user (evidence: `components/userContext.js`)
- Favourites state → User session: reads session (evidence: `components/FavouritesContext.js`)
- Favourites state → Supabase client: stores favourites (evidence: `components/FavouritesContext.js`)
- Profile management → User session: reads session (evidence: `components/dashboard/Profile.js`)
- Profile management → Supabase client: updates profile (evidence: `components/dashboard/Profile.js`)
- Order dashboard → Supabase client: loads orders (evidence: `components/dashboard/Order.js`)
- Account dashboard → User session: uses session
- Supabase client → Supabase backend: connects client (evidence: `helpers/supabase.js`)
