Evaluating LLMs on Frontend Requirement Reconstruction and the Value of Open-Source Models

    This article presents a practical framework for evaluating how well large language models reconstruct frontend requirements from product documents. It breaks evaluation into five measurable dimensions—structure completeness, feature completeness, rule fidelity, interaction fidelity, and engineering maintainability—and walks through three typical scenarios: login pages, list pages with filter conditions, and complex forms with field dependencies and validation rules. Code examples in TypeScript show how to turn filters and validation rules into structured, testable configurations.

    1. Background: From “Can Generate Pages” to “Can Understand Requirements”

    Over the past two years, large language models have drawn increasing attention for frontend code generation. Many teams have tried letting models produce runnable pages directly from product documents. The demos often look impressive, but once these tools enter real projects, the problems usually appear in requirement understanding rather than in whether the code runs.

    A product requirement document contains page structure, field definitions, filter rules, interaction states, and exception handling. If a model only captures the page skeleton, it will generate an interface that looks complete while missing filter conditions or dependencies between fields. Therefore, when evaluating these tools, “it runs” and “it’s correct” should be treated as separate questions.

    This article is based on a typical frontend requirement reconstruction practice. It summarizes the evaluation approach, common defects, and engineering countermeasures, and discusses the value of open-source models in this context. It does not rank specific products; the focus is on reusable methodology.

    2. Evaluation Framework: Breaking “Is It Good” into Testable Dimensions

    Vague statements like “it works well” or “it works poorly” cannot guide decisions. We recommend scoring along the following five dimensions.

    1. Structure completeness: Are all page modules present? Are routing, layout, and component division reasonable?
    2. Feature completeness: Are all features listed in the document implemented, such as filtering, sorting, pagination, and export?
    3. Rule fidelity: Do field constraints, validation logic, and linkage relationships match the document?
    4. Interaction fidelity: Are loading states, empty states, error messages, and state transitions before and after submission handled correctly?
    5. Engineering maintainability: Are code structure, naming, and dependency choices convenient for future maintenance?

    In practice, structure completeness is usually the easiest dimension to pass, while rule fidelity loses the most points. A reasonable explanation is that common page skeletons appear abundantly in training corpora, whereas business-specific field linkage rules depend on document details that the model must align one by one—a significantly harder task.

    3. Breakdown of Typical Scenarios

    3.1 Login Page: Static Structure Is Easy to Get Right

    A login page typically contains form inputs, buttons, and a carousel or promotional image area. These requirements are clearly described, and models generally produce a complete structure. What needs checking are the details: Does the carousel auto-rotate? Does it support manual paging? Is there a fallback display when an image fails to load?

    3.2 List Page: Filter Conditions Are the Most Common Omission

    The difficulty of a list page lies in the mapping between query conditions and data requests. A qualified implementation should meet the following requirements.

    • Every filter item has corresponding state.
    • Changing a filter condition triggers a request and resets the page number.
    • Clearing conditions restores the default query.
    • Filter parameters can be synced to the URL, so the filter state persists after a page refresh.

    The following example uses TypeScript to describe filter items as structured configuration and convert them into request parameters. The field names are fictional and serve only to illustrate the approach.

    1. type FilterType = 'text' | 'select' | 'dateRange';
    2. interface FilterItem {
    3. key: string; // request parameter name
    4. label: string; // display name in the UI
    5. type: FilterType;
    6. defaultValue?: unknown;
    7. }
    8. const productFilters: FilterItem[] = [
    9. { key: 'name', label: 'Name', type: 'text' },
    10. { key: 'status', label: 'Status', type: 'select', defaultValue: 'all' },
    11. { key: 'createdAt', label: 'Created At', type: 'dateRange' },
    12. ];
    13. // Convert filter state into request parameters, ignoring empty values and defaults
    14. function buildQuery(
    15. filters: FilterItem[],
    16. values: Record<string, unknown>
    17. ): Record<string, unknown> {
    18. const query: Record<string, unknown> = {};
    19. for (const item of filters) {
    20. const value = values[item.key] ?? item.defaultValue;
    21. if (value !== undefined && value !== '' && value !== 'all') {
    22. query[item.key] = value;
    23. }
    24. }
    25. return query;
    26. }

    Writing filter items as structured configuration has two benefits. First, it creates a one-to-one correspondence between the document and the code, so each item can be checked individually during review. Second, adding a new filter only requires modifying the configuration, not rewriting the request logic.

    3.3 Form Page: Field Relationships and Validation Rules

    The difficulty of complex forms lies in dependencies between fields. For example, when “Company Type” is set to “Enterprise,” the “Tax ID” field becomes required; the end of a “Validity Period” must be later than its start. Rules like these are easily missed when described only in natural language.

    We recommend organizing validation rules into a table, where each rule includes the triggering field, the condition, the resulting action, and the message text.

    Field Rule Type Condition Result
    Company Type Linkage When “Enterprise” is selected Tax ID becomes required
    Validity End Date Comparison Earlier than the start date Block submission and show a message
    Phone Number Format Not 11 digits Show a format error

    The following code turns the rules in the table above into executable validation functions. The example assumes dates use the ISO 8601 string format, so they can be compared directly.

    1. interface Rule {
    2. field: string;
    3. validate: (form: Record<string, unknown>) => string | null;
    4. }
    5. const rules: Rule[] = [
    6. {
    7. field: 'taxId',
    8. validate: (f) =>
    9. f.companyType === 'enterprise' && !f.taxId ? 'Tax ID is required' : null,
    10. },
    11. {
    12. field: 'endDate',
    13. validate: (f) =>
    14. f.startDate && f.endDate && String(f.endDate) < String(f.startDate)
    15. ? 'End date cannot be earlier than start date'
    16. : null,
    17. },
    18. ];
    19. function validateForm(form: Record<string, unknown>): Record<string, string> {
    20. const errors: Record<string, string> = {};
    21. for (const rule of rules) {
    22. const message = rule.validate(form);
    23. if (message) errors[rule.field] = message;
    24. }
    25. return errors;
    26. }

    Each rule is an independent function, which makes it easy to test in isolation. Tests should cover boundary values, such as the case where the start date and end date are equal.