Building a React E-commerce App with AI Coding Tools: Limits, Pitfalls, and a Practical Checklist
AI coding tools have evolved from simple code completion to generating entire projects. This article uses a 10-page React e-commerce site as a benchmark task to examine where these tools succeed and where they break down—architecture, cross-page business flows, and responsive layout—then provides ready-to-use practices: prompt templates, directory structure, mock data contracts, step-by-step generation, and a final acceptance checklist.
Introduction: Why an E-commerce Site Is a Good Test
AI coding tools have progressed from code completion to generating entire projects. A multi-page e-commerce site involves routing, state management, forms, API calls, and styling all at once—far more complex than a single component. That makes it a good benchmark for testing whether a tool can go from zero to a runnable project.
This article uses a React front-end e-commerce site as the benchmark task, observes the problems that arise during generation, and offers practical steps developers can apply immediately. One caveat: this observation did not track specific tool names, versions, environments, or failure counts, so the article does not compare individual tools. It focuses only on recurring patterns and how to handle them.
1. The Task: 10 Pages
The task is to generate a shopping site with 10 core pages. The table below lists each page’s route, key state, and acceptance criteria. Before giving instructions to a tool, developers should put this table into the requirements document.
| Page | Route | Key State | Acceptance Criteria |
|---|---|---|---|
| Home (product list) | / |
List data, filter conditions, loading state | List loads; filtering returns correct results |
| Product detail | /product/:id |
Current product, selected specs, quantity | Shows empty state when product doesn’t exist |
| Checkout | /checkout/:id |
Shipping info, quantity, amount due | Form validation works; amount calculated correctly |
| Order success | /order/success/:orderId |
Order ID | Order ID still displays after page refresh |
| Login | /login |
Form values, error messages | Clear empty-value messages; correct redirect after login |
| Registration | /register |
Form values, validation results | Password rules enforced; duplicate accounts rejected |
| Dashboard | /user |
Order count, coupon count | Numbers match the orders and wallet pages |
| Orders | /user/orders |
Order list, status filter | Orders in each status can be filtered |
| Wallet (coupons) | /user/wallet |
Balance, coupon list, usage status | Used coupons cannot be used again |
| Settings | /user/settings |
Profile form | Info persists after save and refresh |
The hard part is data flowing between pages. An order created on the checkout page must appear on the orders page; order statuses must affect the Dashboard stats; coupon usage must be reflected in the wallet. Passing a single page in isolation doesn’t mean the site works end to end.
2. Observed Patterns
1. Code Structure and Engineering Quality
Some generated results were decent. Styles and logic were separated, and hooks and context directories were reserved—signs the tool has some understanding of architecture.
Other results had obvious problems. Mock data was written directly inside view components, so pages both rendered and fetched data, meaning any API change required editing every page. Some results showed a flattened project structure or nested folders with duplicate names, leaving the project unable to start.
For developers, AI-generated code needs to satisfy two things: it runs, and it’s maintainable afterward. A single successful launch test cannot tell you whether the code is maintainable.
2. Transaction Flows and Business Completeness
Some results produced basic form validation, and product detail pages were reasonably complete. But tools were consistently weak on cross-page business flows. For example, whether an order’s status syncs to the orders page after purchase, or whether the balance recalculates after a coupon is used—these links usually had to be added manually.
Such problems rarely show up during page rendering; they only surface after walking through the full flow. So acceptance testing should follow complete business paths, not just take screenshots page by page.
3. UI and Responsive Layout
UI quality varied widely across results. Some leaned toward mobile layouts with only basic adaptivity. Some had broken styles on the login and registration pages, and a few buttons had white text on white backgrounds, making them invisible.
Responsive layout is a baseline requirement for modern web apps. When writing CSS media queries and flex layouts, tools need more explicit constraints—such as specified breakpoints and contrast standards.
3. Practical Methods
1. Specify the Tech Stack and Constraints in the Prompt
Here’s a prompt template you can adapt directly:
Create a React e-commerce site with the following stack:- React 18 + Vite- Routing: React Router v6- State management: Zustand (only for cart and login state)- UI: Tailwind CSS, breakpoints at sm 640px / md 768px / lg 1024px- Data: all mock data goes in src/mock/, accessed via src/api/; page components must not hardcode data- First generate only the project scaffold, directory structure, and routing config—no page content- Every page must work at both 360px and 1280px widths; body text contrast at least 4.5:1
This prompt spells out the stack, state scope, data location, and acceptance widths in one shot. Write out version numbers and breakpoints explicitly, or the tool will pick them for you.
2. Define the Directory Structure First
Here’s a recommended structure. It separates data, views, and routing, making it easy to generate and replace pieces step by step.
src/api/ Request wrappers; pages only call functions heremock/ Mock data, fields matching the API contractroutes/ Route configurationpages/ The 10 pages, one folder per pagecomponents/ Components reused across pageshooks/ Custom hooks, e.g. useProductsstore/ Zustand statestyles/ Global styles and design variables
3. Define the Mock Contract
Define mock data fields first, then have the tool generate pages against them. For example, product data:
Product {id: stringname: stringprice: number // in currency units, two decimal placesstock: number // inventory, >= 0cover: string // image URLspecs: { name: string; options: string[] }[]}
Define entities like Order and Coupon the same way. Pages and mock data both follow this contract; when fields change, update the contract only—not the pages.
4. Generate in Steps, Verify Each Step
Asking a tool to generate ten pages in one shot tends to produce a mess. A safer sequence:
- Generate the scaffold and routes; run
npm run buildto confirm it compiles. - Generate the mock and API layers; use
npm testor a simple script to verify data loads. - Generate the purchase path in order—product list, detail, checkout, success page—and walk through the full flow.
- Generate login, registration, and the four account pages; check whether login state affects route protection.
- Finally handle styling; check layouts at 360px and 1280px.
Commit the code after every step. If something goes wrong, you only need to roll back one step instead of starting over.
5. Fix Errors Rather Than Regenerating
When generated code throws an error, give the tool the error message along with the relevant files to fix. That’s usually faster than regenerating from scratch. After a fix, re-run the build to confirm the problem is truly resolved—not just the line that threw the error.
4. Security and Risks
AI-generated code needs the same review as human-written code. The main risks:
- Dependency risk: The tool may introduce outdated or vulnerable packages. Run
npm auditafter every new dependency and check the package’s maintenance status. - Secret leakage: Never paste real API keys or database passwords into prompts. Keep environment variables in a
.envfile and add it to.gitignore. - Accidental overwrites: Generated code may overwrite existing files. Set up a Git repository before you start, commit after every step, and never overwrite unsaved changes directly.
5. Acceptance Checklist
Before delivery, check each item:
-
npm run buildpasses without errors - All 10 routes are directly accessible and don’t break on refresh
- The full purchase flow works, and the order appears on the orders page
- After using a coupon, the wallet page and Dashboard update in sync
- Form validation covers empty values, format errors, and duplicate submissions
- No horizontal scrollbar at 360px or 1280px
- All buttons and body text meet the 4.5:1 contrast ratio
- All mock data lives in
mock/, with no hardcoded data in page components -
npm auditreports no high-severity vulnerabilities
6. Limits and Scenarios Not Covered
This task covered front-end pages only. Real API implementations, database design, payment integration, and server-side rendering were not tested and need separate evaluation—don’t substitute this article’s conclusions for them.
The methods here suit the early stages of small to mid-sized single-page applications. For large projects with multiple collaborators and frequent iteration, architecture still needs human design, along with a complete testing system.
AI coding tools can significantly cut the time spent on scaffolding and basic pages. Complex business logic, polished visual design, and long-term code maintenance still require developer review and refactoring. Treat these tools as productivity aids, combined with the constraints and acceptance methods above, to effectively reduce rework.
