





A concept e-commerce store for lifting gear and 12-week training programs. I built it end to end over three assignments, then wrote the tests that try to break it.
Rep Theory sells lifting gear (straps, wraps, cable attachments, clips) and 12-week training programs, plus a monthly 1:1 coaching subscription. It isn’t a real brand: checkout runs in Stripe test mode and nothing ships.
Every page is pre-rendered at build time and served from Vercel’s CDN. Server code runs in only four places: checkout, the paid-order page, reviews and contact. Everything else (cart, consent, recently viewed) lives in the visitor’s browser.
The cart sends only slug, qty and options. The server checks the origin and rate limit, re-prices every line, and creates one Checkout Session with gear, programs and a monthly coaching subscription in the same cart.
mode: subscription, and its tax is a separate recurring line.RT-2026-4F8K2 skip look-alike characters (0/O, 1/I).
A cart in localStorage is just user input: anyone can open DevTools and post their own. So the server treats every line as hostile and rebuilds it from the catalogue.
lib/pricing.ts runs in the browser to show the live cart and on the server to charge it, so the two can’t disagree. All money is integer cents, so there’s no floating-point drift.
data/catalog.ts is the single source of truth. Each entry generates its card, its detail page, its related links and its program-week gear tags. In Assignment 3, four new features read from the same file instead of copying it.
generateStaticParams turns 10 entries into 10 static pages at build time.The Ask us button opens a chat on every page. It greets you by the product you’re looking at, answers common questions instantly from what’s already on the site, and hands anything else to the team as a ticket with an instant auto-reply.
lib/chat.ts, a pure function with 11 unit tests, while the React component only renders.Reviews and messages are the first data strangers can write to the store, so /api/reviews and /api/contact check each request in a fixed order and fail with the right status code, not just an error.
vi.mock, so each status code is checked in milliseconds, with no network and no keys. Every request also gets its own fake IP, so one test’s rate limit can’t leak into the next.“Recommended for you” scores every product against what you’ve viewed, entirely in your browser. Your history never leaves localStorage, and one click clears it.
Google Analytics 4 doesn’t load at all until a visitor accepts analytics cookies. Decline, or withdraw later, and its cookies are deleted. Vercel Web Analytics is cookieless and counts everyone.
view_item, add_to_cart, begin_checkout, purchase) are queued if GA is still starting, then flushed, so the first page view isn’t lost.Security is layers, each assuming the last one failed: HTTPS everywhere, strict headers, origin checks, honeypots, rate limits, server-side pricing, and card data that never touches our servers.
Two layers. Fast unit and API tests check the rules; browser tests check that a real visitor can actually use them, at desktop and phone width.
next build && next start), the same code visitors get.page.route, and Google is blocked, so tests never touch real services..github/workflows/ci.yml runs the whole suite on every push and pull request. A newer push cancels the older run, and a failed run uploads the Playwright report so the failure can be replayed.
Most of the work here is invisible to a shopper. These are the rules I kept to, each tied to the file that enforces it:
The Playwright smoke test loads all 11 key pages on a Pixel 7 and fails if anything scrolls sideways. Drawers trap focus and close with Escape, toggles expose their state to screen readers, and every animation respects reduced motion.
After Assignment 2 I wrote that the hard part of e-commerce is everything the customer never sees, and that next I wanted to break the store on purpose. In Assignment 3 I did: tampered prices, cross-site posts, bots, floods and analytics before consent are now tests that run on every push.
The lesson I’ll keep is that a test is only worth something if red means something. A flaky test teaches everyone to click re-run. Finding the 1-in-10 failure and fixing its cause taught me more about React hydration than any feature did.
Next is the ML side. With view_item and add_to_cart now flowing into analytics, I want to train an “also bought” recommender on real orders and measure it against today’s explainable rules before it ever reaches the live store.