AI-Assisted E-Commerce Frontend Development: Engineering Practices from Scratch

    This article explores engineering practices for using AI to develop e-commerce frontend applications from scratch. It addresses core challenges such as ensuring page completeness and maintaining site-wide consistency. Topics include breaking down requirements into acceptance checklists, designing effective prompts, and verifying consistency across visual specs, routing, and state management.

    1. Background and Problem Definition

    Automating frontend project scaffolding with AI tools has become a daily practice for many teams. However, fast generation does not guarantee usable results. For an e-commerce site, a complete shopping flow typically includes over a dozen pages, such as the homepage product list, product details, checkout, order success, login/register, and user center. These pages share the same navigation, user state, and product data. Any inconsistency will be exposed during demos or integration.

    This article focuses on two core issues:

    1. Completeness: Can every page be accessed from an entry point, and can the main flow form a closed loop?
    2. Consistency: Are the visual style, interaction methods, data structures, and code organization unified?

    These issues are harder to manage than the aesthetics of a single page and better reflect the actual quality of the generated results.

    2. Breaking Down Page Requirements into an Acceptance Checklist

    Before submitting generation tasks, requirements should be written as a structured checklist. Each page should include at least four pieces of information: route path, core functions, dependent data, and navigation relationships. The table below is a reference example.

    Page Core Functions Dependent Data Primary Navigation
    Home Product list, category filter Product list Product detail page
    Product Detail Images, specs, price, add to cart Single product Checkout page
    Checkout Shipping info, quantity, confirm order Product, shipping address Order success page
    Order Success Order number, follow-up entry Order info Orders page
    Login Account password, form validation User credentials User center
    Register Registration fields, format validation User info Login page
    User Center Overview Account summary data User stats Sub-pages
    Orders Order list, status filter Order data Order detail
    Wallet Balance, coupon list Coupon data None
    Settings Edit profile User profile None

    The checklist serves two purposes. First, it provides a clear baseline for comparing generated results. Second, it allows for item-by-item verification during acceptance, rather than judging by the impression that it “looks about right.”

    3. Prompt Design Principles

    Prompts determine the lower bound of generated results. In practice, providing complete constraints in a single prompt is usually more stable than asking questions across multiple turns. A usable prompt generally includes the following six parts:

    1. Goal and Background: What the project is and its use case.
    2. Technical Constraints: Frontend framework, language version, styling solution, directory conventions.
    3. Page Checklist: Routes and functions for each page.
    4. Data Structure: Field definitions for core entities.
    5. Interaction and Validation Rules: Format requirements for form fields and error prompt methods.
    6. Acceptance Criteria: What state constitutes completion.

    Example:

    1. Goal: Implement a 10-page e-commerce frontend prototype for functional demonstration.
    2. Technical Constraints: Use a component-based frontend framework, separate styles from logic, place mock data in a unified mock directory.
    3. Page Checklist: See attached table, each page needs a clear corresponding route.
    4. Data Structure: Product {id, name, price, image, stock, category}
    5. Validation Rules: Phone number must be valid digits; password must be at least 8 characters and contain both letters and numbers.
    6. Acceptance Criteria: All pages reachable from the homepage; checkout flow forms a closed loop; no console errors at runtime.

    For larger projects, the task should be split into multiple stages, such as completing routes and the skeleton first, then the data layer, and finally page details. Acceptance checks should be performed after each stage to prevent errors from compounding in subsequent stages.

    4. Four Dimensions of Site Consistency

    Consistency issues typically occur at four levels: visual specs, routing navigation, state and data flow, and code organization. The checking methods for each are explained below.

    4.1 Visual Specs

    Style values such as colors, spacing, and border radii should be centrally defined. Pages should only reference variables rather than hardcoding values. This ensures a unified site style and makes it easier to adjust themes later.

    1. // theme/tokens.js
    2. export const theme = {
    3. colors: {
    4. primary: '#1e6fd9',
    5. danger: '#e5484d',
    6. text: '#333333',
    7. muted: '#8a8f98',
    8. surface: '#ffffff',
    9. },
    10. radius: 8,
    11. spacing: [0, 4, 8, 16, 24],
    12. };

    Button text and background must have sufficient contrast. For normal text, common accessibility standards (WCAG AA) require a contrast ratio of at least 4.5:1. The common white-on-white issue in generated results is a manifestation of failing this check.

    4.2 Routing and Navigation

    Routes should be declared centrally to facilitate verifying the number of pages and access permissions.

    1. // router/routes.js
    2. export const routes = [
    3. { name: 'home', path: '/', page: 'ProductList', auth: false },
    4. { name: 'detail', path: '/product/:id', page: 'ProductDetail', auth: false },
    5. { name: 'checkout', path: '/checkout/:id', page: 'Checkout', auth: true },
    6. { name: 'success', path: '/order/success', page: 'OrderSuccess', auth: true },
    7. { name: 'login', path: '/login', page: 'Login', auth: false },
    8. { name: 'register', path: '/register', page: 'Register', auth: false },
    9. { name: 'dashboard', path: '/user', page: 'Dashboard', auth: true },
    10. { name: 'orders', path: '/user/orders', page: 'Orders', auth: true },
    11. { name: 'wallet', path: '/user/wallet', page: 'Wallet', auth: true },
    12. { name: 'settings', path: '/user/settings', page: 'Settings', auth: true },
    13. ];

    The function below checks for orphan pages—pages that have no entry links pointing to them. Link relationships are recorded by route name.

    1. // Check for routes with no entry links
    2. function findOrphanRoutes(routes, links) {
    3. const reachable = new Set(links.map((link) => link.to));
    4. return routes
    5. .filter((route) => route.name !== 'home' && !reachable.has(route.name))
    6. .map((route) => route.name);
    7. }
    8. const links = [
    9. { from: 'home', to: 'detail' },
    10. { from: 'detail', to: 'checkout' },
    11. { from: 'checkout', to: 'success' },
    12. // ...other links
    13. ];
    14. console.log(findOrphanRoutes(routes, links));

    Note that this check only verifies static link relationships and cannot replace runtime click testing. Its value lies in early detection of structural issues where “a page was written but has no entry point.”

    4.3 State and Data Flow

    Global information such as user login state, shopping cart, and order data should be managed centrally. Pages should read and write through a unified interface. A common mistake is each page maintaining its own copy of user information, causing the data displayed in the user center to mismatch the actual state after login.

    During inspection, you can start from a user action and track which pages’ data it affects. For example, placing an order on the checkout page