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:
- Completeness: Can every page be accessed from an entry point, and can the main flow form a closed loop?
- 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:
- Goal and Background: What the project is and its use case.
- Technical Constraints: Frontend framework, language version, styling solution, directory conventions.
- Page Checklist: Routes and functions for each page.
- Data Structure: Field definitions for core entities.
- Interaction and Validation Rules: Format requirements for form fields and error prompt methods.
- Acceptance Criteria: What state constitutes completion.
Example:
Goal: Implement a 10-page e-commerce frontend prototype for functional demonstration.Technical Constraints: Use a component-based frontend framework, separate styles from logic, place mock data in a unified mock directory.Page Checklist: See attached table, each page needs a clear corresponding route.Data Structure: Product {id, name, price, image, stock, category}Validation Rules: Phone number must be valid digits; password must be at least 8 characters and contain both letters and numbers.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.
// theme/tokens.jsexport const theme = {colors: {primary: '#1e6fd9',danger: '#e5484d',text: '#333333',muted: '#8a8f98',surface: '#ffffff',},radius: 8,spacing: [0, 4, 8, 16, 24],};
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.
// router/routes.jsexport const routes = [{ name: 'home', path: '/', page: 'ProductList', auth: false },{ name: 'detail', path: '/product/:id', page: 'ProductDetail', auth: false },{ name: 'checkout', path: '/checkout/:id', page: 'Checkout', auth: true },{ name: 'success', path: '/order/success', page: 'OrderSuccess', auth: true },{ name: 'login', path: '/login', page: 'Login', auth: false },{ name: 'register', path: '/register', page: 'Register', auth: false },{ name: 'dashboard', path: '/user', page: 'Dashboard', auth: true },{ name: 'orders', path: '/user/orders', page: 'Orders', auth: true },{ name: 'wallet', path: '/user/wallet', page: 'Wallet', auth: true },{ name: 'settings', path: '/user/settings', page: 'Settings', auth: true },];
The function below checks for orphan pages—pages that have no entry links pointing to them. Link relationships are recorded by route name.
// Check for routes with no entry linksfunction findOrphanRoutes(routes, links) {const reachable = new Set(links.map((link) => link.to));return routes.filter((route) => route.name !== 'home' && !reachable.has(route.name)).map((route) => route.name);}const links = [{ from: 'home', to: 'detail' },{ from: 'detail', to: 'checkout' },{ from: 'checkout', to: 'success' },// ...other links];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
