AI-Assisted E-Commerce Frontend Development: A Full-Workflow Practice with Consistency Control

    Learn how to use an e-commerce site as a benchmark for AI-assisted coding tools. This article covers page inventory and information architecture, writing acceptance-ready specifications, project structure design, route guards, and consistency control across a ten-page frontend project.

    AI-Assisted E-Commerce Frontend Development: A Full-Workflow Practice with Consistency Control

    1. Why Use an E-Commerce Site to Test AI-Assisted Development

    An e-commerce site covers the most common scenarios in frontend development: product listing and detail pages, form input, authentication state control, transaction flows, and a user center. There are explicit data dependencies between pages. For example, the checkout page needs to read product details, and the order success page needs to display the order number. This makes an e-commerce site a good sample for evaluating intelligent coding tools.

    Evaluation should focus on two dimensions. The first is local correctness: whether a single page renders properly and whether its interactions behave as expected. The second is global integrity: whether the ten pages, once combined, form a coherent product. Each dimension requires a different kind of constraint. Local correctness depends on accurately describing the specification of each page, while global integrity depends on project-wide structural conventions and checklists.

    2. Define the Page Inventory and Information Architecture First

    Before writing any code, list all pages and map out the navigation relationships between them. The example site in this article contains the following ten pages:

    1. Home: product listing with category filtering and sorting
    2. Product detail: images, variants, price, and description
    3. Checkout: confirm quantity, shipping information, and total amount
    4. Order success: display the order number and entry points for follow-up actions
    5. Login: sign in with account and password
    6. Register: information entry and form validation
    7. User center dashboard: overview of orders and account summary
    8. User center orders: order list with status filtering
    9. User center wallet: balance, coupons, and voucher management
    10. User center settings: profile and security settings

    Routes should map one-to-one to pages and be maintained centrally in a single file. Protected pages (user center pages and the checkout page) need a unified authentication guard, so that each page does not implement its own redirect logic.

    1. // routes.js
    2. export const routes = [
    3. { path: "/", name: "home", auth: false },
    4. { path: "/product/:id", name: "detail", auth: false },
    5. { path: "/checkout/:id", name: "checkout", auth: true },
    6. { path: "/order/success/:orderId", name: "success", auth: true },
    7. { path: "/login", name: "login", auth: false },
    8. { path: "/register", name: "register", auth: false },
    9. { path: "/user/dashboard", name: "dashboard", auth: true },
    10. { path: "/user/orders", name: "orders", auth: true },
    11. { path: "/user/wallet", name: "wallet", auth: true },
    12. { path: "/user/settings", name: "settings", auth: true },
    13. ];

    3. Write Requirements as Acceptance-Ready Specifications

    How well a generation tool understands requirements depends on the precision of the specification. Vague descriptions force the tool to decide details on its own, and those details often end up inconsistent with each other. An effective prompt should contain five parts: technical constraints, the page inventory, data conventions, design guidelines, and acceptance criteria.

    1. Goal: Build an e-commerce frontend site with ten pages.
    2. Technical constraints: Use a component-based frontend approach, with styles and logic in separate files.
    3. Data conventions: Product, order, and user data are all fetched through a unified service layer; page components must not hard-code data.
    4. Design guidelines: Primary color #1F6FEB; breakpoints at 768px and 1024px; minimum button height 40px.
    5. Page requirements: List the route, input fields, output content, and navigation targets for each page.
    6. Acceptance criteria: All routes are accessible; product, amount, and order number stay consistent across pages in the purchase flow; form error messages are complete.

    Anything not defined in the specification—such as how amounts are calculated or the exact copy for a login failure—should be decided explicitly by the engineer, not left for the generation tool to guess.

    4. Project Structure: Layering Matters More Than Directory Count

    The goal of project structure is to give every type of code exactly one place to live. The recommended layering is:

    1. src/
    2. pages/ Page-level components, one directory per page
    3. components/ Reusable components such as navbar, product card, form controls
    4. services/ Data access layer with unified API definitions
    5. mocks/ Mock data, used only in development and demo environments
    6. hooks/ Reusable logic; keep only when it has real content
    7. state/ Global state such as auth state and cart
    8. styles/ Global variables and base styles
    9. utils/ Pure functions such as amount calculation and form validation

    Common problems in generated code include nested directories with the same name, empty placeholder directories, and files with overlapping responsibilities. Nested directories make import paths confusing, and empty directories mislead maintainers into thinking a certain kind of logic already exists. Every directory should contain actual content; otherwise, it should be removed. Pure functions are centralized in utils so they can be tested independently.

    5. Decouple Mock Data from Business Logic

    If mock data is written directly into page components, it becomes entangled with presentation logic, which undermines the data conventions established earlier. Keeping mock data isolated in the mocks/ layer, accessed only through the service layer, preserves a clean separation between data and business logic.