Building an E-Commerce Site from Scratch with AI Coding Tools: Practice and Lessons Learned

    This article explores how to use modern AI coding tools to build a complete e-commerce frontend from zero using React. Rather than testing single-line completion or isolated snippets, it uses a ten-page shopping site as a rigorous benchmark for an AI assistant's full-chain engineering ability. It covers how to structure requirements into layered, executable prompts; five core dimensions for evaluating the results (requirement understanding, architecture, design consistency, iterative debugging, and code quality); the typical problems that tend to surface; and practical advice for integrating these tools into a real production workflow. Developers will learn how to guide AI tools with structured prompts, constrain them with engineering standards, and validate them through iteration, turning the question of "can it generate" into "how to generate better and more reliably."

    Building an E-Commerce Site from Scratch with AI Coding Tools: Practice and Lessons Learned

    1. Why Use a “Complete Project” as the Test

    Code completion and single-file snippet generation no longer reveal the true capability of a modern AI coding assistant. As the boundaries of intelligent coding tools keep expanding, what really separates them is their engineering ability across the full chain—from a single natural-language requirement to a runnable, maintainable, well-structured application.

    Single-point generation mainly tests the model’s memory of syntax and local logic. Complete project generation tests a different layer of ability: whether the tool can understand cross-page business semantics, maintain global consistency in naming, styling, and data, autonomously locate and fix errors after they appear, and produce results that have an architectural foundation for further iteration. For this reason, using a medium-complexity e-commerce site with a substantial number of pages and a relatively complete business flow as the “exam” is both a fairly demanding and a fairly realistic way to evaluate a tool.

    2. Task Setup: From Requirements to a Runnable Site

    The core task of this exercise is to use an AI coding tool to build a frontend shopping site from zero with React, covering ten main business pages in full:

    • Home (product listing page)
    • Product detail page
    • Checkout page
    • Payment success page
    • User login page
    • User registration page
    • User Center – Dashboard
    • User Center – Order List
    • User Center – Wallet / Coupon Pack
    • User Center – Settings

    The real difficulty lies not in whether a single page can be drawn, but in “completeness” and “consistency”: whether ten pages can share the same routing, the same set of layout components, the same design language, and the same state-management logic; whether the entire flow—from browsing, adding to cart, and placing an order to the personal center after login—closes smoothly; and whether easily overlooked details such as form validation, error messages, and empty states are covered.

    3. Prompt Engineering: Turning Business Requirements into Executable Instructions

    For a generation task of this scale, prompt quality directly determines success or failure. An effective approach is to break a “vague one-liner” into a structured specification, usually with five layers:

    1. Tech stack constraints: Clearly specify the framework, language, and build method (for example, React + TypeScript + a mainstream CSS approach) to prevent the tool from making inconsistent technology choices while free-styling within the ecosystem.
    2. Feature list: List the pages and the key interactions within each page one by one, spelling out requirements such as “the home page has a product list with category filtering” rather than vaguely saying “build a home page.”
    3. Data and state conventions: Describe the rough fields of entities such as products, users, and orders, and explain how login state is shared across the whole application.
    4. Consistency requirements: Explicitly require all pages to reuse unified layout components and design variables (colors, spacing, typography) to avoid each page being drawn in isolation.
    5. Acceptance criteria: Specify that forms must have basic validation, pages need simple responsiveness, and hardcoded placeholder images are prohibited.

    A reusable prompt skeleton looks roughly like this:

    1. Generate a React + TypeScript e-commerce frontend site with the following requirements:
    2. 1. Tech stack: React + TypeScript + CSS Modules, developed in a component-based way;
    3. 2. Pages: home, detail, checkout, payment success, login, register,
    4. and User Center (Dashboard / Orders / Wallet / Settings), 10 routes in total;
    5. 3. Consistency: all pages reuse the Layout component and unified design tokens;
    6. 4. State: use a global store to manage login state and the cart;
    7. 5. Acceptance: forms need basic validation, responsive adaptation is required,
    8. and placeholder images used directly are prohibited.

    The more precise the granularity of the prompt, the higher the tool’s stability across files and pages. Conversely, an overly brief requirement usually yields a result that “runs but feels heavily pieced together.”

    4. Core Dimensions for Evaluating an AI Coding Tool

    After getting the generated result, it is worth assessing it objectively along the following five dimensions—also a general yardstick for measuring the engineering maturity of any intelligent coding tool.

    4.1 Requirement Understanding and Context Handling

    A good tool should understand the business relationships among all ten pages at once, rather than treating each page as an isolated task. The criteria to judge are: does it proactively establish a routing structure, does it recognize business prerequisites such as “the User Center is only available after login,” and does it reasonably decompose the shopping main flow and the account system.

    4.2 Project Architecture and Engineering Standards

    The weakest area most easily exposed by generated code is architecture. The ideal output should have a clear directory structure with separated responsibilities: page components, layout components, shared UI components, state management, mock data, and style variables each in their proper place, with styles separated from logic rather than crammed into one giant file. If mock data is directly coupled into rendering logic and the project structure is too flat, so that adding a new requirement demands large-scale changes, it means the tool is still fairly “primitive” at the architectural level.

    4.3 Page Consistency and Design System

    Consistency is the litmus test for complete project generation. You can check whether multiple pages reuse the same color scheme, the same card component, and the same form styles. A single primary color running throughout the design, along with reusable components, is a plus. When pages such as login and registration become misaligned during responsive adaptation, it reflects that responsive handling is not robust enough.

    4.4 Iterative Debugging and Self-Repair

    Real development rarely succeeds on the first try. Whether the generated result runs directly, whether the tool can read and automatically fix errors after they appear, and how many rounds of manual intervention are needed—these are what distinguish a “demo-level” tool from a “usable-level” one. A healthy signal is that the tool can converge to a runnable state within a few iterations, and that fixes do not introduce new cascading problems.

    4.5 Code Quality and Maintainability

    This includes whether naming is standard, whether there are basic type constraints, whether data and views are separated, and whether necessary handling is applied to critical paths (such as form validation). Code quality determines whether the output is a “decent but one-off demo” or “a project starting point that a team can take over.”

    5. Typical Problems Exposed in Practice

    No matter which tool you use, this kind of full-project generation task tends to surface a few recurring problems. Identifying them in advance helps set reasonable expectations:

    • Placeholder and mock data coupling: Images are mostly placeholders, the product detail page is too simplistic, and fake data is entangled with business logic. This is the most common phenomenon. The direction for improvement is to decouple the mock layer from the rendering layer, making it easy to later replace it with real APIs.
    • Responsive and form distortion: The overall design leans toward mobile, but pages such as login and registration fall into layout disarray during responsive adaptation, showing that grids and breakpoints need manual reinforcement.
    • Too-thin architecture: The features “work,” but the project structure is flat and lacks layering, offering poor extensibility.
    • First generation not directly runnable: It takes several rounds of error fixing before the complete effect is visible, and the debugging cost cannot be ignored.

    These problems are not unique to any single tool, but are common characteristics of AI full-project generation at the current stage. Understanding them matters more than demanding a “perfect on the first try.”

    6. Recommendations for Engineering Integration

    To genuinely bring AI coding tools into a production workflow, the following practices are recommended:

    1. Clear division of labor between human and machine: Position the tool as a “high-quality scaffold plus first-pass implementation,” and keep key decisions—architecture review, security review, and confirmation of business boundaries—on the human side.
    2. Set the architecture first, then generate: Fix the tech stack, directory conventions, and design variables at the prompt stage, and use them as anchors for incremental generation of subsequent requirements.
    3. Iteration over one-shot: Allow the tool to produce results in rounds, with each round focused on a verifiable goal, reducing the failure surface of a single generation.
    4. Build reusable templates: Consolidate successful prompts, directory structures, and component conventions into team templates to form stable productivity.
    5. Pair with engineering capabilities: For real go-live, the output can be combined with common cloud capabilities such as containerized deployment, object storage, and logging, monitoring, and alerting; if using Baidu AI Cloud’s basic cloud products, continuous delivery can also be completed through its standard build and deployment pipeline, keeping the toolchain neutral and replaceable.

    7. Conclusion

    Using a ten-page e-commerce site as the yardstick is essentially about testing an AI coding tool’s overall ability “from requirements to engineering,” rather than the flashiness of single-point generation. At present, these tools show considerable efficiency in requirement understanding, interface production, and iterative repair, but still have room for improvement in architectural layering, data decoupling, and responsive robustness. For developers, the rational stance is neither to deify them nor to be overly harsh, but to treat them as collaboration partners that can significantly speed things up: guide them with structured prompts, constrain them with engineering standards, and tame them through iterative validation—thereby turning the question of “whether it can generate” into a continuous-improvement proposition of “how to generate better and with more control.”