Building and Evaluating an E-commerce Frontend with AI Coding Assistants

    This article explores the practice of using AI coding assistants to build an e-commerce frontend site from scratch. It covers task decomposition for a 10-page site, compares overall generation and step-by-step iteration modes, and provides a seven-dimension evaluation checklist to ensure completeness, consistency, and maintainability. It also outlines engineering best practices such as using design tokens and unified routing to maintain site consistency.

    I. Background: From Requirements to a Runnable Site

    AI coding assistants can now generate frontend project skeletons, page components, and basic interactions based on natural language descriptions. For e-commerce sites with numerous pages and interdependent states, the value of these tools lies not just in generation speed, but in whether the final output maintains completeness and consistency.

    This article uses “building an e-commerce frontend with ten pages from scratch” as a typical task to discuss three questions: how to write effective task descriptions, how to evaluate tool outputs, and how to push the product to a deliverable state after human intervention.

    II. Task Breakdown: E-commerce Page Inventory

    A minimal viable e-commerce frontend typically includes the following ten pages. Grouped by business flow, they fall into four categories:

    • Browsing: Homepage (Product List), Product Detail
    • Transaction: Checkout, Checkout Success
    • Account: Login, Register
    • User Center: Dashboard, Orders, Wallet & Coupons, Settings

    There are clear state dependencies between pages. The checkout page depends on login status and selected product info. Checkout success depends on the order result. The orders page depends on data generated by the checkout page. The Wallet & Coupons page depends on user account data. If the task description doesn’t specify these dependencies, the generation tool must infer them, often leading to contradictions—for example, the same user showing different balances on two different pages.

    Therefore, a qualified task description should include at least four elements: a page inventory, navigation relationships between pages, shared data (user state, shopping cart, orders), and a unified visual specification. Missing any of these makes it difficult to guarantee the completeness of the output.

    III. Two Working Modes and Applicable Scenarios

    3.1 Overall Generation Mode

    The overall generation mode refers to the tool outputting all pages and configuration files at once based on a complete description. The advantage is a unified context, where page styles and data structures often remain consistent, making it suitable for rapid prototyping. The disadvantage is concentrated errors; the first run might encounter missing dependencies, module path errors, or uninitialized states, requiring a debugging loop.

    3.2 Step-by-Step Iteration Mode

    The step-by-step iteration mode splits the task into multiple stages, such as setting up the project structure and routing first, then implementing shared components, and finally building the business pages step by step with runtime validation at each step. The advantage is that problems can be located promptly, and the scope of changes at each step is controllable. The disadvantage is that it requires more manual confirmation, and early decisions (like data structure naming) might cause consistency issues later, so shared specifications must be locked down in the first step.

    3.3 Selection Basis

    The choice of mode can be based on three factors: page scale, the team’s familiarity with the generated code, and whether a design specification already exists. For fewer pages or prototype validation, the overall generation mode is more efficient. For more pages or long-term maintenance, the step-by-step iteration mode is more reliable. Regardless of the mode, the first-round output should go through a unified inspection process and should not be treated directly as a finished product.

    IV. Evaluation Dimensions and Check Methods

    Evaluating the output of an AI coding assistant requires a fixed checklist. The following seven dimensions cover the main quality requirements for an e-commerce site.

    1. Completeness: Are all ten pages present, are all routes reachable, and does the navigation form a closed loop? Check by accessing each route one by one to confirm the page renders.
    2. Overall Consistency: Are colors, font sizes, spacing, button styles, and navigation structures unified? Check by comparing similar elements across different pages and recording differences.
    3. Runtime Correctness: After installing dependencies per instructions, can the project start? Are there console errors? Can the critical paths (browse, add to cart, checkout, view orders) be completed successfully?
    4. Form Quality: Are required field validations, format validations, error prompt positions, and text reasonable? Check by submitting empty values, incorrect formats, and boundary values to each form.
    5. Data and Assets: Are product, user, and order data centralized in a data layer? Is there a unified fallback mechanism for placeholder images? Is it easy to replace them?
    6. Responsive Performance: At different screen widths, is the layout readable, do forms deform, and are buttons clickable?
    7. Maintainability: Are shared components extracted? Is the directory structure clear? Are there large blocks of duplicated code?

    It is recommended to use the same checklist to score outputs from different tools or different rounds, recording the number of defects and fix rounds. This transforms subjective impressions into comparable records.

    V. Engineering Practices to Ensure Site Consistency

    Site consistency does not happen automatically; it requires engineering constraints. The following four practices are the most effective.

    5.1 Centralized Design Tokens

    Centralize visual variables like colors, spacing, radii, and breakpoints in a single file. All pages should reference variables rather than hardcoding values. This way, changing the theme color only requires modifying one place.

    1. // Example: Centralized design variables
    2. export const tokens = {
    3. color: {
    4. primary: '#2563EB',
    5. danger: '#DC2626',
    6. text: '#1F2937',
    7. border: '#E5E7EB',
    8. },
    9. space: { xs: 4, sm: 8, md: 16, lg: 24 },
    10. radius: { sm: 4, md: 8 },
    11. breakpoint: { mobile: 576, tablet: 992, desktop: 1200 },
    12. };

    5.2 Unified Route Table

    Use a single routing configuration to describe the paths, components, and access permissions for all pages. Navigation menus, breadcrumbs, and permission checks should all read from this configuration to avoid writing separate paths everywhere.

    1. // Example: Route configuration
    2. export const routes = [
    3. { path: '/', page: 'ProductList', auth: false },
    4. { path: '/products/:id', page: 'ProductDetail', auth: false },
    5. { path: '/checkout/:id', page: 'Checkout', auth: true },
    6. { path: '/checkout/success/:orderId', page: 'CheckoutSuccess', auth: true },
    7. { path: '/login', page: 'Login', auth: false },
    8. { path: '/register', page: 'Register', auth: false },
    9. { path: '/account/dashboard', page: 'Dashboard', auth: true },
    10. { path: '/account/orders', page: 'Orders', auth: true },
    11. { path: '/account/wallet', page: 'Wallet', auth: true },
    12. { path: '/account/settings', page: 'Settings', auth: true },
    13. ];

    The auth field in the route table marks pages that require login. The login guard only needs to read this field to uniformly handle redirect logic.

    5.3 Extract Shared Components

    Headers, footers, product cards, price displays, buttons, and form fields are high-frequency reused elements. By extracting them into shared components, the uniformity of the page style is guaranteed by the components rather than relying on the implementer of each page. Shared components should only receive data and callbacks, and should not directly access global state, making them easy to test and replace.

    5.4 Unified Data Model

    Products, users, orders, and coupons should have fixed field definitions. Field names, types, and status enumerations must remain consistent across the site, serving as the foundation for data interoperability between pages.

    1. // Example: Core data structure
    2. const product = {
    3. id: '',
    4. };