Build Guide
How to Build an E-Commerce Store
A custom e-commerce store built with Next.js and Stripe outperforms Shopify on speed and SEO — and costs $0/month to run at small scale.
E-commerce combines auth, payments, inventory, search, and email automation. Master it and you have the building blocks of any transactional business on the internet.
Data model
The core tables you'll need before writing any UI.
Build order
The sequence that minimises rewrites — build in this order.
Product catalogue
Build a product listing page with image, name, price, and an "Add to Cart" button. Use Next.js SSG for product pages — fast loads and good SEO. Fetch product data from Supabase at build time.
Shopping cart
Store the cart as a JSON array in a cookie or localStorage: [{productId, variantId, quantity}]. Add a cart sidebar that slides in on add. Show item count in the header. Persist across page navigations.
Stripe Checkout
On checkout click, POST the cart to /api/checkout. Create a Stripe Checkout Session with line items mapped from your cart. Redirect the user to the Stripe-hosted checkout page. Handle success and cancel redirects.
Webhook for order confirmation
Create a /api/stripe/webhook route. Verify the Stripe signature. On checkout.session.completed: create an Order row in your DB, decrement inventory, send a confirmation email via Resend.
Order history for customers
Add a /orders page that shows a customer's order history when they enter their email. Look up orders by email (no account required for small stores). Show order status, items, and total.
Admin panel
Build a simple /admin route (protected by a secret cookie or Clerk). Show all orders with status. Add buttons to update order status (shipped, delivered). Show low-inventory alerts.
Search and filtering
Add a search input that filters products by name on the listing page. Add category filters and a price range slider. For large catalogues, move to server-side search with Supabase full-text search or Algolia.
Build it with AI — Architect Prompt
Paste this into Claude, Cursor, Windsurf, or any AI coding tool. It includes the full context of this guide — data model, build order, and pitfalls — so the AI starts with everything it needs.
<context>
App: E-Commerce Store
Difficulty: Intermediate
Estimated build time: 1–2 weeks
Data model:
Product: id, name, slug, description, price, compare_at_price, images[], inventory_count, category_id, published
ProductVariant: id, product_id, sku, size, color, price, inventory_count
Order: id, customer_email, status (pending/paid/shipped/delivered/refunded), subtotal, shipping, tax, total, stripe_payment_intent, created_at
OrderItem: id, order_id, product_id, variant_id, quantity, unit_price
Cart: session_id (cookie), items[] — stored in a cookie or localStorage, not DB
Recommended build order:
1. Product catalogue — Build a product listing page with image, name, price, and an "Add to Cart" button. Use Next.js SSG for product pages — fast loads and good SEO. Fetch product data from Supabase at build time.
2. Shopping cart — Store the cart as a JSON array in a cookie or localStorage: [{productId, variantId, quantity}]. Add a cart sidebar that slides in on add. Show item count in the header. Persist across page navigations.
3. Stripe Checkout — On checkout click, POST the cart to /api/checkout. Create a Stripe Checkout Session with line items mapped from your cart. Redirect the user to the Stripe-hosted checkout page. Handle success and cancel redirects.
4. Webhook for order confirmation — Create a /api/stripe/webhook route. Verify the Stripe signature. On checkout.session.completed: create an Order row in your DB, decrement inventory, send a confirmation email via Resend.
5. Order history for customers — Add a /orders page that shows a customer's order history when they enter their email. Look up orders by email (no account required for small stores). Show order status, items, and total.
6. Admin panel — Build a simple /admin route (protected by a secret cookie or Clerk). Show all orders with status. Add buttons to update order status (shipped, delivered). Show low-inventory alerts.
7. Search and filtering — Add a search input that filters products by name on the listing page. Add category filters and a price range slider. For large catalogues, move to server-side search with Supabase full-text search or Algolia.
Known pitfalls to avoid:
- Fulfilling orders without verifying payment — never trust the success redirect URL to confirm payment. Only fulfil orders after receiving the checkout.session.completed webhook from Stripe.
- Not handling inventory concurrency — two users might buy the last item simultaneously. Use a database transaction with a check: UPDATE products SET inventory = inventory - 1 WHERE inventory > 0 AND id = ?. Check the row count to confirm it succeeded.
- Storing prices in the frontend cart — always recalculate prices server-side before creating the Stripe session. A user can modify their localStorage cart to change prices.
Tech stack (intermediate): Next.js + Stripe + Supabase + Cloudinary (images) — custom store, free at small scale
</context>
<role>
You are a Senior Full-Stack Engineer and product architect who has shipped production E-Commerce Stores before. You know exactly where developers get stuck and how to structure the project to avoid rewrites.
</role>
<task id="step-1-clarify">
Before writing any code or spec, ask me 3–5 clarifying questions that will meaningfully change the architecture. Focus on: scale expectations, auth requirements, platform (web / mobile / both), must-have vs nice-to-have features for the MVP, and any hard constraints (budget, deadline, existing infrastructure).
<example>
BAD: "What tech stack do you want to use?" — too broad, doesn't change architecture decisions.
GOOD: "Do you need real-time sync across devices, or is single-device with periodic refresh acceptable? This decides whether we use WebSockets or simple REST polling and significantly affects infrastructure complexity."
</example>
</task>
<task id="step-2-architect">
After I answer your questions, generate a complete project specification including:
1. Final tech stack with version numbers
2. Full file and folder structure
3. Complete database schema — every table, column, type, index, and foreign key
4. All API routes with request/response shapes and auth requirements
5. Component tree with TypeScript props interfaces
6. Auth and authorisation flow (who can do what)
7. Step-by-step implementation plan in the exact build order from <context> above
8. All environment variables with descriptions
<self_check>
Before presenting the spec, verify:
□ Every answer I gave in step 1 is reflected in the spec
□ The database schema matches the data model in <context>
□ The implementation plan follows the build order from <context>
□ No circular dependencies in the component tree
□ Auth is wired up before any protected routes are built
□ All known pitfalls from <context> are addressed in the spec
</self_check>
</task>
<task id="step-2.5-agents-md">
Generate an AGENTS.md file at the project root. This file is read automatically by Claude Code, Cursor, Windsurf, Sourcegraph Cody, and all major AI coding tools at the start of every session.
Include:
- Project overview (2–3 sentences)
- Tech stack with version numbers
- Folder structure with one-line descriptions
- Key architectural decisions and why they were made
- Coding conventions: naming (camelCase components, kebab-case files), max 200 lines per file, one concern per file
- Available commands: dev, build, test, lint, db:migrate, db:seed
Note in the file: "Cursor users can symlink .cursorrules → AGENTS.md. Claude Code users can symlink CLAUDE.md → AGENTS.md."
</task>
<task id="step-3-implement">
Implement the full project following the spec from step 2, in the exact order defined. For each step:
- Write the complete code (no placeholders or TODOs)
- Confirm the step is working before moving to the next
- Note any deviations from the spec with an explanation
<constraints>
- Max 200 lines per file. WHY: every file must fit in one AI context window for easy review and editing.
- One concern per file. WHY: mixing auth logic into API routes makes it impossible to reuse — extract to lib/auth.ts.
- TypeScript strict mode, no `any` types. WHY: catches data shape mismatches at compile time, not in production at 2am.
- All database queries in server components or API routes only. WHY: keeps credentials server-side, prevents accidental client-side exposure.
- All environment variables documented in .env.example. WHY: the next developer (or your future self) should be able to set up the project in under 5 minutes.
- Comment every non-obvious decision. WHY: AI tools read your comments to understand intent — without them, the next edit will break the pattern you established.
</constraints>
</task>How to use this prompt
- 1.Copy the prompt above
- 2.Open Claude, Cursor (Cmd+L), or Windsurf
- 3.Paste the prompt and send — the AI will ask 3–5 clarifying questions
- 4.Answer the questions, then it generates your full project spec
- 5.Continue in the same session to implement step by step
Common mistakes
What trips up most developers building this for the first time.
Fulfilling orders without verifying payment — never trust the success redirect URL to confirm payment. Only fulfil orders after receiving the checkout.session.completed webhook from Stripe.
Not handling inventory concurrency — two users might buy the last item simultaneously. Use a database transaction with a check: UPDATE products SET inventory = inventory - 1 WHERE inventory > 0 AND id = ?. Check the row count to confirm it succeeded.
Storing prices in the frontend cart — always recalculate prices server-side before creating the Stripe session. A user can modify their localStorage cart to change prices.
Recommended tech stack
Pick the level that matches your experience.
Shopify — fastest path to a working store, $29/month, zero dev work
Next.js + Stripe + Supabase + Cloudinary (images) — custom store, free at small scale
Next.js + Stripe + Medusa.js (headless commerce) + Algolia (search)
Take it further — related ideas
Each comes with revenue math, a full build guide, and a prompt to paste into Claude or Cursor.
9 ideas in the archive
PackTrack - AI Delay Predictor That Warns E-Commerce Sellers Before a Shipment Goes Late
Small e-commerce sellers find out their shipment is late when the customer already emailed asking where their order is. PackTrack monitors supplier shipment data, carrier APIs, and historical delay patterns to predict delays 5-10 days before they happen and fires an alert so sellers can proactively message customers before the complaint. Reactive customer service is dead — this is the proactive version.
ReplayIQ - MCP Server That Injects Live PostHog Session Replay Context Into Claude for Instant UX Diagnosis
You can watch session replays in PostHog all day but Claude has no idea what your users are actually doing. ReplayIQ is an MCP server that pulls live PostHog session replay metadata, event sequences, and rage-click hotspots into Claude's context so you can ask it to diagnose UX failures in plain English. It's like giving Claude eyes on your product.
ScopeCast - NLP Feedback Intent Classifier That Turns User Emails Into Prioritized Backlog Items
Product teams drown in unstructured user feedback emails, Intercom threads, and App Store reviews — none of which maps cleanly to a backlog. ScopeCast classifies every piece of feedback by intent (bug, feature request, churn signal, praise), extracts the core ask, and pushes a structured ticket to Linear or Jira automatically. Finally, your inbox becomes a roadmap.
SceneWatch - Autonomous Retail Shelf Compliance Vision Agent
Brands pay field reps to walk stores and photograph shelves to check if products are placed correctly — in April 2026 that is a $40/hour human doing a job a phone camera and a vision model can do in 30 seconds. SceneWatch is the autonomous compliance agent that replaces the clipboard.
NoteShip - Shareable Public Pages From Obsidian Notes Instantly
Your Obsidian note is brilliant. Your client cannot open a .md file. NoteShip turns any Obsidian markdown paste into a shareable, readable public URL in one click — like Notion public pages but for people who actually write in Obsidian.
VaultMark - One-Click Obsidian Markdown to PDF and Word Exporter
Obsidian is where your best thinking lives, but sharing it means fighting pandoc on a Friday afternoon. VaultMark lets you paste raw Obsidian markdown and get a clean, formatted PDF or DOCX in under 10 seconds. No CLI, no plugins, no copy-paste degradation.
TradeSpot - On-Demand Emergency Home Repair at 2am
Your pipe bursts at midnight and Google gives you a graveyard of disconnected plumber listings. TradeSpot connects homeowners to vetted, on-call tradespeople within minutes — live map, upfront price, Stripe escrow. Sleep is optional, but at least your house won't flood.
PawRoute - White-Label Booking App for Independent Dog Walkers
Independent dog walkers are hemorrhaging clients to Rover's 30% commission cut while managing everything via PayPal.me links and texts. PawRoute gives every solo pet care pro their own branded booking page, live GPS walk tracking for anxious owners, and Stripe-powered invoicing.
CoachSlot - Mobile Booking and Payments for Solo Fitness Coaches
Solo yoga teachers and PTs are running $5k/month businesses on WhatsApp and bank transfers like it's 2009. CoachSlot gives every solo fitness coach a personal booking link, Stripe card payments, and automatic cancellation fee enforcement — no more ghost clients.