Skip to content

Add Amazona: Amazon-style e-commerce storefront (Next.js + Tailwind)#1

Open
hellokij wants to merge 4 commits into
mainfrom
vorflux/amazon-style-storefront
Open

Add Amazona: Amazon-style e-commerce storefront (Next.js + Tailwind)#1
hellokij wants to merge 4 commits into
mainfrom
vorflux/amazon-style-storefront

Conversation

@hellokij

@hellokij hellokij commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

Builds Amazona, an Amazon-style e-commerce storefront, as a new Next.js (App Router) + React + TypeScript + Tailwind CSS v4 app. This is the first code in the repo — the whole diff is new.

The goal was an Amazon-like storefront. Rather than copy Amazon's actual logo, product listings, and copy (which are trademarked/copyrighted), this uses original "Amazona" branding, a seeded placeholder catalog, and generated SVG product images, while closely mirroring Amazon's layout and UX.

Features

  • Amazon-style layout — dark top nav with category-scoped search, cart with live item badge, secondary category nav, and a multi-column footer.
  • Home page — hero banner, curated "shelf" cards, and a full recommended product grid.
  • Search & listing (/search) — full-text search over the catalog with department filters, star-rating filters, and sort (featured / price low→high / price high→low / avg. rating). Includes a mobile-visible department selector since the filter sidebar is hidden on small screens.
  • Product detail (/product/[id], statically generated) — image, ratings, discount + struck-through list price, feature bullets, quantity selector, Add to Cart / Buy Now, and related products.
  • Cart (/cart) — line items with quantity edit and remove, live subtotal, persisted to localStorage so it survives reloads.
  • Mock checkout (/checkout) — shipping + payment form with native HTML5 validation, order summary with tax/shipping, and an order-confirmation state with a generated order number. No real payment is processed.
  • Out-of-stock handling, a custom 404 page, and page metadata/title.

Architecture

  • Cart state via React Context + useReducer, persisted to localStorage. Quantities are clamped to a max of 10 (matching the UI selectors), and stored data is validated/reconciled against the current catalog on load (normalizeStoredItems) so malformed or stale entries can't crash rendering.
  • formatPrice/discountPercent live in a plain (non-client) module so both server and client components can use them.
  • Catalog + search helpers are seeded in src/lib/products.ts; no backend/database.

Testing

Automated + browser end-to-end testing, all passing.

Unit tests (Vitest, 21 tests, npm run test): searchProducts/getProduct (query, brand, category, combined scoping, no-match) and the cart reducer + normalizeStoredItems (add/increment, MAX_CART_QTY clamp, setQuantity clamp + zero-removes, remove, clear, malformed/stale localStorage recovery).

Checks: npm run build prerenders all 19 pages cleanly; npm run lint passes with zero warnings.

Browser E2E (all 7 planned flows + 2 bonus checks PASS):

Flow Result
Home render (nav, hero, shelves, grid, images) PASS
Search (query, department + rating filters, sort, mobile department selector) PASS
Product detail (price/discount/rating/bullets/stock, qty 1–10, Add to Cart) PASS
Cart (add, qty update, delete, subtotal/badge recalc) PASS
MAX_CART_QTY=10 clamp on repeated Add to Cart PASS
Cart persistence across reload (localStorage) PASS
Malformed-localStorage recovery (normalizeStoredItems) PASS
Checkout empty-submit blocked by HTML5 validation PASS
Checkout filled → order confirmation (AMZ-XXXXXX), cart cleared PASS
Out-of-stock product: unavailable + Add to Cart disabled/omitted PASS

During testing a real preview-only defect was found and fixed: the Next.js dev server blocked cross-origin dev resources (HMR/fonts) from the preview proxy host, which prevented hydration on the public URL. Fixed via allowedDevOrigins in next.config.ts (Next.js drops this check in production builds). A cart-badge SSR/client hydration mismatch was also fixed by gating the count until after mount.

Evidence:

  • Screenshots (29)
  • Recording, flows 1–4 — note: recorded before the hydration fix, so it does not reflect the final state.
  • Recording, flows 5–7 (post-fix, clean)

Live preview: https://shf67bq5jzyg.preview.us1.vorflux.com

Notes

Original demo project for learning purposes — not affiliated with, endorsed by, or connected to Amazon.com, Inc. All branding, product names, and imagery are original placeholders.


Attached Videos

🎥 View recording: amazona_e2e.webm

🎥 View recording: amazona_flows5to7.webm

View in Vorflux Session


Session Details

  • Session: View Session
  • Requested by: Unknown
  • Address comments on this PR. Add (aside) to your comment to have me ignore it.

hellokij added 4 commits July 20, 2026 15:03
Full-storefront e-commerce demo with home, search/listing, product
detail, cart, and mock checkout. Cart state via React Context +
useReducer persisted to localStorage. Seed catalog with generated SVG
placeholder assets. Original 'Amazona' branding (not affiliated with
Amazon).
- Extract discountPercent() and MAX_CART_QTY to lib/format; dedupe
  discount computation across ProductCard and product detail
- Add shared QuantitySelect component; dedupe quantity <select>
- Clamp cart quantities to MAX_CART_QTY in reducer (add + setQuantity)
- Validate/reconcile localStorage cart via normalizeStoredItems
- Sync Header search inputs with URL params after client navigation;
  normalize invalid category to All
- Add mobile-visible department selector on search page
- Remove unused useRouter from CheckoutView; dedupe subtotal line
- Add Vitest + unit tests for searchProducts and the cart reducer/
  normalization (21 tests)
Guard the URL category param with categories.includes() so an
out-of-range ?category value normalizes to All in both the header
control and the results grid, keeping them in agreement.
- Add allowedDevOrigins for the Vorflux preview host so Next.js dev
  serves HMR/font resources to the proxied hostname; without it the app
  fails to hydrate on the public preview URL and all client handlers
  fall back to native browser behavior.
- Track a mounted flag in the cart reducer and render the header cart
  count as 0 until after client mount, eliminating the SSR/client
  hydration mismatch on the cart badge (count is only known client-side
  after localStorage hydration). Guard the persist effect on mounted so
  the empty initial state never clobbers stored cart data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant