Building a React E-commerce Site in Practice: A Guide to Choosing an AI Coding Assistant
Testing AI coding assistants with a complete React e-commerce site reveals their real strengths and weaknesses far better than comparing isolated code snippets. This article walks through building the site from 0 to 1 as a hands-on benchmark: how to break requirements down into four modules and ten pages, how to write a reusable prompt, six core dimensions for evaluation with a weighted scoring table, common issues and their fixes, and the security checks to consider before any launch. It gives developers a practical, comparable framework for selecting an assistant that fits their team.
1. Conclusion first: Why stress-test with a full e-commerce site?
Stress-testing an AI coding assistant with a complete e-commerce site exposes its real capabilities better than comparing isolated code snippets.
The reason is that an e-commerce site is not a collection of standalone pages but a set of interdependent business flows. Users browse products on the homepage, open a detail page to check specs and prices, move to a checkout page to confirm the order, and view the order center after a successful payment. Alongside these, modules such as login, registration, personal center, wallet, and settings connect identity, assets, and after-sales flows. This kind of task checks two things at once: whether the assistant understands cross-page requirements, and whether it has engineering thinking, code-quality awareness, and basic robustness handling.
For this reason, this article uses “building a React e-commerce site from 0 to 1” as the hands-on task. It covers both how to break down requirements and how to evaluate AI coding assistants, helping developers choose efficiently.
2. How do you break down the four modules and ten pages?
Before handing requirements to an AI coding assistant, defining the functional boundaries clearly is the first step to improving generation quality. A commercially usable e-commerce frontend can be split into four modules and ten pages.
2.1 Product browsing module: How does it capture traffic?
The product browsing module serves as the traffic entry point and mainly includes two pages:
- Homepage (product list page): supports product search, category navigation, list rendering, price display, and basic filtering.
- Product detail page: displays product images and text, specifications, price, stock, and purchase entry points.
The goal here is not to “look like an e-commerce site” but to let users quickly find a product and enter the conversion path.
2.2 Transaction flow module: How does it close the loop?
The transaction flow module handles the feedback loop from intent to order placement, including:
- Checkout page: confirm order information, select a shipping address, set quantity, and view discount information.
- Purchase success page: display the payment result, order number, and amount summary, and guide the user back to the homepage or to view orders.
The most critical part of this module is closing the loop: users should clearly know where to go next, and no information should be lost.
2.3 User system module: How does it verify identity?
The user system module mainly includes a login page and a registration page, and needs to handle:
- Inputs such as account, password, email, or phone number;
- Basic form validation, such as required fields, length, and format;
- Error messages and loading states;
- Redirect logic after success.
This module is a good test of how the assistant handles form state, error fallbacks, and interaction feedback.
2.4 Personal center module: How does it organize information?
The personal center module aggregates the user’s follow-up actions, including:
- Dashboard: shows user overview information such as recent orders, balance, and points.
- Orders page: displays order history grouped by status, with view and action support.
- Wallet or coupon pack: manages assets such as balance, coupons, and gift cards.
- Settings page: handles personal profile, security settings, and notification preferences.
This module is well suited to testing how the assistant handles complex information hierarchy, card layouts, and status display.
2.5 How do you write a reusable requirements prompt?
To improve the first-pass generation success rate, it is recommended to use a structured prompt when submitting requirements. The template below can be reused directly:
Build an e-commerce frontend prototype with React to evaluate generation quality.Goal: Deliver a runnable frontend project covering four modules: product browsing, transaction checkout, user system, and personal center.Page list:1. Homepage: product list, search, category filtering;2. Product detail page: images, title, price, stock, specs, add-to-cart button;3. Checkout page: order information, address selection, quantity, discount information;4. Purchase success page: order number, payment result, back to homepage;5. Login page: account/password login, form validation, error messages;6. Registration page: registration form, password strength, error messages;7. Dashboard: user overview, recent orders, balance, points;8. Orders page: order list, status filtering;9. Wallet page: balance, coupons, gift cards;10. Settings page: personal profile, security settings, notification preferences.Technical requirements:1. Use React function components;2. Keep styles and logic separated as much as possible;3. Use clear component names and a sensible directory structure;4. Manage colors, spacing, and font sizes with design tokens;5. Decouple mock data from the view layer to make it easy to connect real APIs later;6. Provide basic form validation, empty states, and error messages;7. Pages should have basic responsive behavior.Acceptance criteria:1. The project starts directly;2. Core flows can be completed by clicking through;3. No obvious style issues such as white text on a white background or invisible buttons;4. Mock data is not hardcoded in page components.
If the assistant supports a longer context window, you can append further requirements on design tokens, breakpoint strategy, directory structure, and data-service conventions to reduce later rework.
3. How do you evaluate AI coding assistants? Six core dimensions and a selection table
With different tools available, developers need a reusable evaluation framework. The following six dimensions help judge whether an AI coding assistant is a good fit for team adoption.
3.1 Does it understand the task and run it through in one pass?
A strong assistant should understand cross-module requirements rather than only generating scattered pages. During evaluation, observe:
- Whether it understands the navigation relationships among the homepage, detail page, checkout page, and success page;
- Whether it delivers a runnable project within a small number of interaction rounds;
- Whether it requires repeated patching just to start;
- Whether it identifies the key constraints in the requirements, such as form validation, order status, and data decoupling.
High first-pass completeness indicates a deeper understanding of context and business structure.
3.2 How good are the UI and interaction friendliness?
UI quality often shows in the details:
- Whether buttons have hover, disabled, and loading feedback;
- Whether form errors are clear and readable;
- Whether page spacing is consistent;
- Whether the color scheme is harmonious;
- Whether long lists, empty states, and error states are displayed reasonably.
If the assistant only generates a “skeleton UI” while ignoring interaction details, substantial manual polishing is still needed afterward.
3.3 How do you judge code quality?
Code quality directly affects later maintenance cost. Judge it from these angles:
- Whether styles are reasonably decoupled from JavaScript logic;
- Whether components have a single responsibility;
- Whether naming is clear;
- Whether large amounts of inline styles are written repeatedly;
- Whether constants, service functions, and utility functions are reasonably abstracted;
- Whether the code remains readable even if comments are missing.
High-quality code is not necessarily complex, but it should be easy for later developers to understand and extend.
3.4 How do you assess engineering capability?
Engineering capability is what separates “can generate pages” from “can generate a project.” Focus on:
- Whether the directory structure is reasonable;
- Whether it separates component, page, and service layers;
- Whether it provides a unified request layer;
- Whether mock data is replaceable;
- Whether it reserves room for routing, state management, and environment configuration;
- Whether it avoids writing mock data directly into page components.
An assistant with strong engineering capability produces output that is closer to a real team project.
3.5 How do you verify robustness and compatibility?
An e-commerce site involves sensitive scenarios such as forms, orders, and wallets, so robustness cannot be ignored. During verification, check:
- Whether forms cover required, format, and length validation;
- Whether empty lists have empty states;
- Whether request failures have fallbacks;
- Whether the login and registration pages break on mobile;
- Whether buttons remain understandable in abnormal states;
- Whether the layout is stable across breakpoints.
If the generated pages work only on desktop but show misalignment, overflow, or invisible buttons on mobile, robustness is insufficient.
3.6 How do you observe response speed?
Response speed has two aspects:
- Generation speed: the wait time from entering requirements to producing code;
- Runtime experience: whether page loading, interaction feedback, and dev preview are smooth.
Stable response times noticeably reduce waiting and stutter, making the “requirement → generation → verification → correction” iteration rhythm smoother.
3.7 How do you complete an efficient selection?
To turn evaluation from subjective impressions into a comparable process, you can build a six-dimension weight table and a scoring table.
Suggested weights:
| Evaluation dimension | Suggested weight |
|---|---|
| Task understanding and first-pass completeness | 20% |
| Code quality | 20% |
| Robustness and compatibility | 20% |
| Engineering capability | 15% |
| UI expressiveness and interaction friendliness | 15% |
| Response speed | 10% |
Scoring table template:
| Dimension | Weight | 1-point standard | 5-point standard | Measured score |
|---|---|---|---|---|
| Task understanding | 20% | Only generates scattered pages | Understands all four modules and ten pages in one pass | |
| Code quality | 20% | Messy naming, coupled logic | Clear structure, maintainable | |
| Robustness | 20% | No validation, no fallbacks | Complete validation, empty states, and fault tolerance | |
| Engineering | 15% | Hardcoded mock data, no layering | Clear layering, replaceable data | |
| UI expressiveness | 15% | Stiff style, missing details | Fairly mature visuals and interactions | |
| Response speed | 10% | Long waits or stutter | Smooth generation and preview |
When comparing 2–3 tools side by side, follow these steps:
- Use the same requirements prompt to avoid too many variables;
- Generate projects under the same environment or constraints;
- Record whether it runs on the first try and whether fixes are needed;
- Score each item against the scoring table;
- Calculate the weighted total and keep notes on any key weaknesses;
- Choose the highest-scoring assistant with acceptable weaknesses as a team candidate.
4. How do you fix common problems?
Even capable AI coding assistants may produce common defects in the first draft. Common problems and optimization strategies are listed below.
4.1 How do you handle missing images and static assets?
In generated output, images are often placeholders, which is a common problem. Ways to address it include:
- Agreeing on a resource directory up front, for example keeping everything under
src/assets/images/; - Hosting image assets on object storage or a CDN;
- Maintaining resource addresses in a config file;
- Establishing separate naming conventions for product images, avatars, and icons;
- Avoiding scattering many uncontrollable external links in the output.
Planning resource management in advance reduces the cost of later replacement.
4.2 How do you fix layout breakage and missing responsiveness?
Mobile misalignment, disappearing buttons, and white text on a white background usually come from missing style tokens. It is recommended to explicitly specify colors, spacing, font sizes, and breakpoint strategy in the prompt.
/* White text on #1a73e8 has a contrast ratio of about 4.48:1, which falls short of the WCAG AA 4.5:1 threshold; use #1558b0 as the primary color, or increase font size and weight */:root {--color-primary: #1558b0;--color-text: #1f2937;--color-bg: #ffffff;--color-on-primary: #ffffff;--space-unit: 8px;}.btn-primary {background: var(--color-primary);color: var(--color-on-primary);padding: calc(var(--space-unit) * 1.5);}
Two points to note here:
- Do not use the background color token
--color-bgdirectly as the text color, or it may conflict with the design token conventions; - Ensure contrast between the primary color and the text color, to avoid a button “seemingly disappearing” due to low contrast.
4.3 How do you manage mock data coupling?
If the assistant writes mock data directly into page components, connecting real APIs later becomes very painful. It is recommended to decouple the data layer from the view layer and switch through a unified service layer.
const USE_MOCK = true; // In a real project, change this to import.meta.env?.MODE === 'development'const mockProducts = [{ id: 1, name: 'Sample Product', price: 99, stock: 10 },{ id: 2, name: 'Sample Product 2', price: 199, stock: 5 }];const request = async (url) => {const res = await fetch(url);if (!res.ok) throw new Error('Request failed: ' + res.status);return res.json();};const productService = {async getList(params) {if (USE_MOCK) return mockProducts;return request('/api/products');}};
Business pages depend only on productService, not directly on mockProducts. This way, during development you use mock data, and when switching to real APIs in production, you do not need to rewrite page logic.
4.4 How do you solve overly simple project structure?
If a project has only a single App file, expansion will quickly get out of hand. It is recommended to guide the assistant to adopt a layered structure.
Recommended directory tree:
src/assets/components/common/product/layout/pages/home/detail/checkout/success/login/register/dashboard/orders/wallet/settings/services/request.jsproductService.jsuserService.jswalletService.jsstore/mocks/styles/tokens.cssApp.jsxmain.jsx
This structure keeps pages, components, services, state management, and mock data in their proper places, and makes team collaboration and future expansion easier.
5. How do you distill best practices?
In actual use, it is recommended to follow these principles:
- Requirements first: write modules, pages, interactions, and acceptance criteria into a checklist before handing it to the assistant.
- Define conventions: specify design tokens, directory structure, and data decoupling requirements in the prompt.
- Verify in small steps: get the core flow working first (homepage, detail page, checkout page), then add the personal center.
- Human-machine collaboration: treat the assistant as an “efficient first-draft generator,” while developers own architecture decisions and quality control.
- Progressive enhancement: first ensure a closed-loop flow and basic validation, then add responsiveness, error fallbacks, and performance optimization.
- Security review: sensitive modules such as login, payment, wallet, and user information must be manually reviewed.
6. Security boundaries and pre-launch notes
It is worth stressing that the scenario discussed in this article is a frontend prototype and an evaluation of AI coding assistants, and is not equivalent to a production-grade e-commerce system.
In real projects, modules such as login, registration, wallet, payment, orders, and user profiles all involve sensitive data and compliance requirements. AI-generated frontend code cannot replace security design. Before going live, at a minimum consider:
- Backend authentication and access control;
- Full-site HTTPS;
- Input validation and server-side re-validation;
- Basic security measures against XSS, CSRF, and injection;
- Integrating payment through a compliant payment gateway, without handling sensitive payment credentials on the frontend;
- Not hardcoding keys, tokens, or private configuration in code;
- Log redaction to avoid leaking user privacy;
- Server-side consistency checks for assets such as coupons, balance, and points.
Even if the generated output is used only for demos or prototype validation, its boundaries should be stated clearly, to avoid misleading users into thinking it already has production-level security.
7. Summary
Using a complete React e-commerce site as a hands-on task both tests an AI coding assistant’s overall understanding of complex requirements and exposes its weaknesses in UI experience, code quality, engineering, and robustness.
For developers, the value of the tool is not “replacing human work with one click,” but handing repetitive labor to machines while keeping architecture design, quality control, and security review for themselves. Defining requirements clearly, agreeing on conventions, verifying in small steps, and collaborating with the assistant are the practical paths to delivering a high-quality frontend project efficiently.
