AI-Assisted Coding in Practice: Building an E-Commerce Frontend from Scratch
This article explains how AI-assisted coding has evolved from code completion to conversational generation and task-level project generation. Using a representative React e-commerce frontend with 10 pages, it presents a six-dimension framework for evaluating AI-generated code and practical engineering methods for producing more complete, consistent, and maintainable results.
AI-Assisted Coding in Practice: Building an E-Commerce Frontend from Scratch
1. From Completion to Task-Level Generation: The Evolution of AI Coding Capabilities
Over the past few years, AI-assisted coding has gone through three clear stages. The earliest stage was code completion, which predicts the next line or function based on the context of the current file. The next stage was conversational generation, where developers describe their intent in natural language and the tool returns code snippets or explanations. The stage attracting the most attention today is task-level (Agent) generation: given a relatively complete requirement, the tool plans the steps, creates multiple files, and generates a runnable project skeleton.
This evolution brings a major productivity boost, but it also creates new problems. Generation is faster, yet output quality varies widely. The gap between “can run” and “usable” often involves completeness, consistency, and architectural soundness. As a result, the ability to evaluate and control AI coding tools is becoming a core competitiveness skill for developers.
2. Layering AI Coding Tool Capabilities (A Neutral View)
Setting specific products aside, the capabilities of intelligent coding tools can be abstracted into several general layers, making it easier to evaluate them rationally:
- Code completion layer: context-based real-time completion that improves coding speed.
- Conversational Q&A layer: explains errors, generates snippets, and offers modification suggestions.
- Task-level generation layer: accepts a requirement description, plans the work autonomously, and generates a project across multiple files.
- Multi-agent collaboration layer: breaks complex tasks into subtasks and processes them in parallel to speed up output.
- Supporting features: such as privacy mode (whether code is uploaded to the cloud), switchable models, and execution speed adjustment.
It is important to note that many tools face a trade-off between generation speed and generation quality. A faster mode may produce messy structure, while a more rigorous mode may respond more slowly. Understanding these trade-offs is more important than memorizing a product name.
3. Designing the Hands-On Task: Testing Capability with a Realistic Requirement
To evaluate tool capability objectively, this article uses a representative task: building an e-commerce frontend from scratch with React, including 10 pages—home page (product list), product detail page, purchase page, purchase success page, login page, registration page, user dashboard, orders page, wallet (coupon pack), and settings page.
This task is representative because it tests multiple capabilities at once:
- Multiple pages and routing: pages need correct navigation and parameter passing.
- Shared state: the cart, login state, and user information must remain consistent across pages.
- Forms and validation: login, registration, and checkout all involve input validity.
- Design consistency: all 10 pages must be visually unified and reuse components.
The core difficulty is not how well a single page looks. It is the overall completeness and consistency of the site—which is exactly where AI-generated large projects are most likely to fail.
4. Six Dimensions for Evaluating AI-Generated Code
In practical use, I have summarized the following evaluation framework. It can serve as an acceptance checklist for any AI-generated project.
1. Functional Completeness: Can the Shopping Flow Close the Loop?
The first thing to check is whether all pages exist and whether the main flow works: browse products → view details → add to purchase → place order successfully → perform account-related actions. Many generated results “look complete,” but one link is missing or does nothing when clicked. It is best to manually walk through the core path page by page.
2. Visual Consistency: Is the Design System Unified?
A common problem in AI-generated code is arbitrary color choices, buttons with white text on a white background, placeholder images everywhere, and inconsistent styles across pages. To truly solve consistency, you should define design tokens first during the prompting stage, and then let the AI follow them:
:root {--color-primary: #2f6fed;--color-bg: #ffffff;--color-text: #1a1a1a;--space-unit: 8px;--radius-md: 8px;}
Making all pages reuse the same variables is an effective way to avoid “mysterious design choices.”
3. Form Validation: Is Legality Actually Handled?
Login, registration, and checkout pages should include basic validation, such as format, length, and consistency checks. You can ask the AI to produce an independent validation function so it is easier to test and reuse:
function validateRegister({ email, password, confirm }) {const errors = {};if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {errors.email = 'Invalid email format';}if (password.length < 8) {errors.password = 'Password must be at least 8 characters';}if (password !== confirm) {errors.confirm = 'Passwords do not match';}return errors;}
4. Responsive Adaptation: Does It Break on Mobile?
A large share of e-commerce traffic comes from mobile devices. Generated results often have distorted mobile layouts or overflowing elements. Be sure to check every page on a narrow screen, and include “mobile-first and simple responsive adaptation” in the requirements.
5. Code Quality: Are Styles Separated from Logic?
Check whether styles are separated from component logic, whether naming is clear, and whether duplicate code exists. Inline styles and mixed logic significantly increase future maintenance costs.
6. Architecture and Structure: Is the Directory Layout Reasonable and Is Data Decoupled?
This is where the biggest differences appear. Common problems include declaring hooks and context directories but leaving them empty; hard-coding mock data into components; and even nested folders with duplicate names that prevent the project from running. A good structure should decouple data access from the view layer:
src/api/ # Data request layer; easily switch between mock and real APIscomponents/ # Reusable UI componentspages/ # Page-level componentshooks/ # Extracted reusable logic (useCart, useAuth)context/ # Global state (login state, user information)styles/ # Global styles and design variables
// api/product.js — Pages do not need to know whether data comes from mock or a real backend.export async function fetchProducts(params) {return mockRequest('/products', params);}
This way, even if mock data is used now, connecting a real backend in the future requires almost no changes to the pages.
5. Engineering Recommendations for Better Collaboration with AI
Based on the framework above, here are several practices for improving the quality of AI-assisted coding output:
- Break down requirements and generate iteratively: do not throw a giant task of 10 pages at the AI all at once. First build the skeleton, then complete pages one by one to reduce the risk of losing control.
- Define standards before generation: first determine design specifications, directory structure, and data models, then let the AI fill in the details.
- Commit in small steps and use version control: commit once each usable page is completed, making it easier to trace and roll back.
- Let humans review key paths: architecture decisions such as state management, data layer design, and routing should be led by developers rather than fully delegated to AI.
- Verify functionality with tests: add automated tests for validation logic and key interactions to avoid situations that “look runnable but actually fail.”
6. Connecting with Cloud Services: Moving the Frontend Toward Production Readiness
When a project moves from “can run” to “ready to launch,” it needs support from backend services and infrastructure. This stage can be handled by common cloud service categories: static frontend assets can be distributed through object storage + CDN; business logic can run on container platforms or serverless functions; data persistence depends on database services; and post-launch stability can be supported by logging services and monitoring alerts. Cloud providers generally provide these standard building blocks, and developers can combine them as needed without binding to any single proprietary API.
7. Conclusion
The correct positioning of AI coding tools is as an “efficient copilot,” not an “autonomous driver.” They can greatly accelerate building from zero to one, but the completeness, consistency, and architectural soundness of a project still require developers to control them with clear requirement breakdown, explicit design standards, and strict acceptance criteria. By mastering the six-dimension evaluation framework and the engineering collaboration methods in this article, you can maintain judgment amid the endless stream of tools and make AI a reliable source of productivity rather than a burden that requires repeated rework.
