Testing AI Coding Tools in Practice: Building a 10-Page React E-commerce Site and Validating the Result
AI coding tools are often judged on isolated function completions or single widgets, which either overestimates or underestimates what they can actually do. This article takes a closer-to-engineering approach: asking a tool to independently build a complete e-commerce frontend with ten pages in React. It walks through the full workflow of scoping the task, scoring tools across six practical dimensions, categorizing the failure modes AI-generated projects typically show, restructuring output into a maintainable skeleton-first architecture, and deploying the result with a repeatable build, cache, fallback, and rollback procedure. You get concrete prompts, project structure examples, an AuthContext implementation, a ten-point acceptance checklist, and deployment configurations you can reuse as a repeatable evaluation process.
1. Why a “Zero-to-One” Task Is a Better Test for AI Coding Tools
AI coding tools are now widely used for code completion, page generation, and project scaffolding. But testing only single functions or one small widget makes it easy to either overrate or underrate a tool’s real capability. A method closer to actual engineering work is to let the AI complete an entire project on its own: build a ten-page e-commerce frontend with React.
This task tests far more than code generation. It also tests how well a tool controls requirement boundaries, routing structure, state management, style consistency, and whether the output actually runs.
The evaluation scope is ten pages: a home product listing, a product detail page, checkout, purchase confirmation, login, registration, a user dashboard, order management, a wallet and coupon pack, and a settings page. On the surface it looks like page assembly, but in practice it carries several engineering constraints:
- Completeness: all ten pages must be reachable, and navigation between them must not break.
- Consistency: colors, spacing, corner radii, buttons, and form styles must be uniform.
- Runnability: the project must start, must build, and must produce no blocking console errors.
- Maintainability: data, views, routing, and state management must be layered.
- Extensibility: connecting real APIs later should not require a large-scale rewrite.
So that you can reproduce the evaluation, fix the environment and startup flow first. Node.js 20 LTS, npm or pnpm, React 18+, Vite, and TypeScript are recommended. The terminal commands look like this:
node -vnpm -vnpm create vite@latest react-shop-ai -- --template react-tscd react-shop-ai# If a package-lock.json already exists, prefer:npm cinpm run devnpm run buildnpm run preview
If your questions are “how do I choose an AI coding tool”, “how do I build a React e-commerce site from scratch”, or “what should I check in AI-generated code”, this article breaks evaluation, acceptance, fixing, and deployment into executable steps instead of staying at the conceptual level.
2. Core Dimensions for Evaluating AI Coding Tools
To compare tools, you cannot look only at whether they can generate a few pages. Six dimensions matter.
2.1 UI Friendliness and Learning Curve
A mature tool offers clear context previews, conversational editing, diff comparison, and one-click apply. If the generated result cannot be previewed directly, or if you cannot tell what a change actually modified, debugging cost rises sharply.
2.2 Completeness and First-Pass Success Rate
First-pass success rate is the key metric that separates tools. To avoid subjective judgment, record the following fields:
| Field | Description |
|---|---|
| Tool name and version | For example model, plugin version, IDE version |
| Prompt | Save the full prompt or a prompt ID |
| Commands run | npm run dev, npm run build, and so on |
| Generation time | Time from start of generation to first runnable state |
| Blocking errors | Whether the app fails to start or fails to build |
| Passing page count | How many of the ten pages are reachable and usable |
| Repair rounds | How many repair rounds are needed to reach a basically working state |
Several tools can then be compared in one table:
| Tool or model | First-pass success | Code quality | Responsive behavior | State management | Generation latency | Conclusion |
|---|---|---|---|---|---|---|
| Tool A | 8/10 pages | Mediocre component splitting | Overflow on mobile | Placeholder only | Fast | Needs several repair rounds |
| Tool B | 10/10 pages | Data and view separated | Basically usable | Has Context | Medium | Worth further polishing |
2.3 Code Quality
Good code generally separates styling from logic, splits components sensibly, uses clear naming, and keeps the data layer independent. If the AI inlines large amounts of styling and hardcodes product data inside page components, connecting APIs and collaborating with other developers both become harder later.
2.4 Responsiveness and Adaptability
An e-commerce site has to work on both desktop and mobile. Typical problems are horizontal overflow on mobile, invisible buttons, uncontrolled image dimensions, text that is too small, and insufficient contrast. Check at common widths such as 375px, 768px, and 1440px.
2.5 State Management and Architecture Headroom
An extensible project reserves a place for state management in advance: auth state, cart, wallet balance, order list, and so on. A common mistake is creating hooks or context directories with no real implementation inside. This kind of “structural placeholder” surfaces as soon as features are extended.
2.6 Response Speed and Stability
Generation latency affects iteration speed. Beyond raw speed, check whether a tool can recover reliably after failure. Frequent interruptions, repeated regeneration, and inability to locate errors all stretch out the delivery timeline.
3. Common Failure Modes and How to Diagnose Them
When AI generates an entire site, the usual problems fall into five categories. Each should be handled with the same pattern: symptom, diagnosis, fix.
3.1 It Runs, But It Runs Poorly
Symptom: the project starts, but product images are all placeholders, detail page content is vague, the checkout button has no real interaction, and the order list has no data.
Diagnosis: check whether the data source is missing, whether the pages are only static skeletons, whether image fields are empty, and whether components only render default text.
Fix: add an independent data module and implement loading, empty, and error states. If there is no backend yet, use local mock data, but make sure it can later be swapped for API requests.
3.2 Mock Data Coupled with Business Logic
Symptom: products, orders, and user info are written directly inside components, so changing a page means changing data logic too.
Diagnosis: search component files for arrays, objects, and hardcoded text, and confirm whether data is mixed into JSX.
Fix: extract data into src/data or src/services, and let view components obtain data only through props, hooks, or context. For example:
// src/data/products.jsexport const products = [{ id: 1, name: 'Product A', price: 99, stock: 12, image: '/images/a.png' },{ id: 2, name: 'Product B', price: 159, stock: 8, image: '/images/b.png' }];
function ProductList({ items }) {return (<ul>{items.map((item) => (<li key={item.id}>{item.name} - ¥{item.price}</li>))}</ul>);}
3.3 Architecture That Exists Only on Paper
Symptom: the project has hooks, context, and services directories, but the files are empty or only export empty objects.
Diagnosis: open the directories and check for real state logic; then click login, add to cart, and view wallet, and watch whether state actually changes.
Fix: implement a minimal working architecture, such as persisted auth state, cart CRUD, and reading the order list. At minimum, state must travel between pages instead of every page maintaining its own fake data.
3.4 Missing Responsiveness and Visual Consistency
Symptom: horizontal scrolling on mobile, buttons whose foreground color matches their background, cards squeezed and deformed at narrow widths, text too small.
Diagnosis: switch to a mobile viewport in the browser developer tools and check whether elements exceed their containers; use a contrast-checking tool on buttons and body text.
Fix: use consistent design tokens, for example:
:root {--color-primary: #2563eb;--color-text: #111827;--color-bg: #ffffff;--space-sm: 8px;--space-md: 16px;--radius-md: 12px;}
Also give buttons explicit styles so a case where color and background-color are identical never appears.
3.5 Broken Project Structure or Path Conflicts
Symptom: dependency installation fails, modules cannot be found, pages fail to start; sometimes a folder contains a same-named folder, for example src/src.
Diagnosis: check whether package-lock.json is corrupted, whether node_modules installed completely, whether build aliases are correct, and whether import paths have case mismatches or nested directories with identical names.
Fix: delete the lock file and reinstall dependencies, standardize on a path alias such as @/components, and audit all import paths. If the AI has already scrambled the directory structure, do not keep patching locally; regenerate a clean skeleton and migrate the pages into it.
4. Engineering Practices for AI Coding: Skeleton First, Then Flesh
To use AI coding tools efficiently, do not ask for all ten pages in one shot. Use “skeleton first, then flesh, then validation”.
4.1 Generate the Project Skeleton and Routing First
Have the AI produce the project directories, routes, and page placeholders first, then fill in each page one by one. A minimal maintainable structure can look like this:
src/components/contexts/AuthContext.jsxCartContext.jsxdata/products.jshooks/useAuth.jsuseCart.jspages/Home.jsxProductDetail.jsxCheckout.jsxOrderSuccess.jsxLogin.jsxRegister.jsxDashboard.jsxOrders.jsxWallet.jsxSettings.jsxrouter.jsxmain.jsxApp.jsx
react-router-dom is recommended for routing, covering at least the ten pages:
import { createBrowserRouter, RouterProvider } from 'react-router-dom';const router = createBrowserRouter([{ path: '/', element: <Home /> },{ path: '/product/:id', element: <ProductDetail /> },{ path: '/checkout', element: <Checkout /> },{ path: '/order-success', element: <OrderSuccess /> },{ path: '/login', element: <Login /> },{ path: '/register', element: <Register /> },{ path: '/dashboard', element: <Dashboard /> },{ path: '/orders', element: <Orders /> },{ path: '/wallet', element: <Wallet /> },{ path: '/settings', element: <Settings /> }]);export default function AppRouter() {return <RouterProvider router={router} />;}
In production, if you use BrowserRouter or createBrowserRouter, you need history fallback configured; otherwise refreshing /orders directly may return 404.
4.2 State Constraints Explicitly and Unify the Design System
Declare design tokens directly in the prompt: primary color, secondary colors, font sizes, spacing, radii, and button states. Ask the AI to reuse existing components rather than writing a fresh set of styles on every page.
A recommended prompt fragment:
Build an e-commerce frontend with React + Vite. Use react-router-dom for routing.Unified styles: primary #2563eb, background #ffffff, text #111827.Buttons must have hover, disabled, and loading states.All pages must adapt to a 375px mobile width.Keep product data in src/data/products.js; page components must not hardcode product arrays.Generate the routing skeleton first, then implement pages one by one.
4.3 Minimal State Management That Actually Works
Auth state can live in AuthContext, and the cart in CartContext. A demo project can persist to localStorage first, but a production project should delegate sensitive credentials to backend session management and avoid exposing high-risk tokens in frontend storage.
Example:
import { createContext, useContext, useEffect, useState } from 'react';const AuthContext = createContext(null);export function AuthProvider({ children }) {const [user, setUser] = useState(() => {const saved = localStorage.getItem('auth-user');return saved ? JSON.parse(saved) : null;});useEffect(() => {if (user) {localStorage.setItem('auth-user', JSON.stringify(user));} else {localStorage.removeItem('auth-user');}}, [user]);const login = (nextUser) => setUser(nextUser);const logout = () => setUser(null);return (<AuthContext.Provider value={{ user, login, logout }}>{children}</AuthContext.Provider>);}export function useAuth() {return useContext(AuthContext);}
The cart can be managed similarly, storing product IDs and quantities. The point is that global data has a clear owner, rather than being passed between pages through URL parameters or temporary variables.
4.4 Build an Acceptance Checklist
After generation, do not look only at the home page. Verify each item on a checklist:
| Check item | Pass criteria | If it fails |
|---|---|---|
| App starts | npm run dev runs with no blocking errors | Read terminal errors, fix missing dependencies or syntax problems |
| Production build | npm run build succeeds | Check import paths, type errors, undefined variables |
| Pages reachable | All ten pages open through routing | Add route configuration or fix component exports |
| Route refresh | Refreshing a nested route does not return 404 | Configure history fallback or a 404 redirect |
| Console | No unhandled exceptions | Fix undefined values, empty-array rendering, missing keys |
| Mobile | No visible horizontal scroll at 375px | Adjust flex, grid, image dimensions, and spacing |
| Button visibility | Foreground and background contrast is clear | Use shared style tokens and a contrast checker |
| Form validation | Login, registration, and checkout validate required fields and show errors | Add validation logic and error messages |
| Data layering | Page components do not hardcode business arrays | Move them to the data or services layer |
| State works | Auth, cart, and wallet state can change | Implement Context or hooks |
4.5 Fix Iteratively
Do not ask the AI to rewrite ten pages at once. A better order is: fix blocking problems first, such as failure to start, failure to build, and 404 routes; then fix usability problems, such as unresponsive buttons and missing form validation; and only then optimize visuals and experience. After every change, re-run startup, build, and the key-path checks.
5. From Local to Cloud: Reproducible Release and Rollback
Once the frontend is built, deployment comes next. Many AI-generated projects do not fail because the AI cannot write pages, but because it does not know how to publish, how to handle refresh 404s, or how to roll back. Below is a general-purpose procedure.
5.1 Build Locally
Run this in the project root:
npm cinpm run build
With Vite, the output directory is usually dist; with Create React App, it is usually build. Before publishing, confirm the output directory contains index.html, static assets, and the route entry files.
5.2 Upload the Static Assets
Upload the build output to object storage, static site hosting, or a CDN origin. Publish only the build artifacts: never upload source code, node_modules, or local environment files. Product images are best kept in a separate asset directory such as /images or /assets and served through a CDN.
5.3 Configure SPA History Fallback
With BrowserRouter, the server must fall back to index.html for unknown paths; otherwise visiting /orders or refreshing /product/1 returns 404.
Two common approaches:
- Redirect 404s to
/index.htmlwhile keeping a 200 status. - Use the SPA fallback built into your hosting platform.
If you cannot configure a server-side fallback, HashRouter is a temporary alternative, but it hurts URL readability and shareability in some scenarios.
5.4 Configure CDN Caching
Static asset filenames usually carry a hash, so they can be cached long-term; index.html should use a short cache or no cache, so users do not keep loading a stale entry file after a release. After going live, verify origin fetch behavior so the CDN does not cache an error page.
5.5 Containers and Dynamic Capabilities
If the site is purely static frontend, a container is not necessarily needed. If you later need server-side rendering, API proxying, login sessions, or dynamic order services, use a container platform to host the dynamic parts. Before deploying, be explicit about which capabilities run in the browser and which must run on the server.
5.6 Logs and Rollback
After release, check at least three kinds of logs: browser console errors, failed network requests, and server access logs. Keep the build artifacts of several recent releases, for example:
/releases/20260622-01//releases/20260623-01/
When a new version has a blocking problem, point the site entry back to the previous release instead of rebuilding. Before rolling back, confirm the static asset paths are still valid, so old pages do not reference new assets.
5.7 Security and Permissions
A public static site should follow least privilege: object storage denies write access and allows public read only; do not hardcode API keys, admin passwords, or private third-party credentials in the frontend; if a protected API must be called, let a backend proxy handle it. Enable hotlink protection, cache purging, and origin verification on the CDN so a release does not leave the site unreachable or assets broken.
6. Conclusion
In one sentence: AI coding tools do not replace engineers; they are engineering partners that need task decomposition, constraints, validation, and a deployment checklist.
When you build a React e-commerce site with AI, the real difficulty is not whether it can generate ten pages, but whether it can generate a project that runs, can be validated, can be maintained, and can ship. Developers have to split the work into skeleton, routing, state management, data layer, visual standards, and release process, then accept the result using first-pass success records, an acceptance checklist, and a table of common fixes. Only when AI generation is folded into the engineering workflow does it move from “looks usable” to “deliverable on an ongoing basis”.
