Replicating a Web Chat Application with LLMs: A Complete Engineering Practice

    This article explores an experiment using Large Language Models (LLMs) to replicate a web-based chat application from scratch. By setting a closed-loop task with minimal human intervention, the experiment evaluates the comprehensive engineering capabilities of different LLMs and execution frameworks across requirement analysis, UI fidelity, API integration, and self-testing. We detail the task breakdown, prompt design, evaluation dimensions, and technical practices for improving fidelity, concluding that replication tasks are a highly effective method for assessing LLM engineering capabilities in real-world scenarios.

    I. Experiment Background: Why This Test Matters

    Since the capabilities of open-source models became available, the community has frequently explored whether models can replicate a complete product. The true value of such experiments lies not in producing a production-ready website, but in testing the model’s comprehensive capabilities in real-world engineering tasks: requirement understanding, information retrieval, UI replication, code organization, API integration, and self-verification.

    This experiment set up a closed-loop task: using a certain web-based chat product as the reference target, the model was required to independently complete three tasks—a product feature document and structure chart, a highly faithful prototype, and an improved new version based on its own understanding. The entire process was given only two prompt rounds: the first round described the requirements, and the second round provided the API credentials. No human intervention was allowed beyond this, to observe the differentiated performance of different combinations of models and execution frameworks.

    II. Task Breakdown: Three Deliverables, Three Capabilities

    1. Product Feature Document & Structure Chart: Testing Abstraction Capability
    The model needed to first browse the target site, organize a feature list (session management, history, input area, streaming output, sharing, settings, etc.), and output a hierarchical structure diagram. The significance of this step is that if the model’s understanding of the product structure is biased, the subsequent replication will inevitably deviate. A qualified product document should include functional modules, page hierarchies, interaction states (loading, generating, error, empty), and boundary conditions.

    2. Pixel-Level Prototype: Testing Execution Capability
    The requirement was “functions and UI consistent with the original web page.” This requires the model to accurately replicate the layout grid, spacing, font sizes, border radius, color system, and mobile responsive behavior. In practice, the easiest details to lose fidelity are: the position and size of the mobile input box, scrolling behavior, dark mode color scheme, and the hierarchical relationship of message bubbles.

    3. Improved Prototype: Testing Product Judgment
    The third deliverable allowed the model to play freely, integrating common best practices from across the web, such as clearer multi-turn context management, collapsible reasoning processes, editable assistant replies, shortcut panels, and conversation exports. This step reveals whether the model is merely “imitating” or truly understands the core pain points of chat products.

    III. Prompt Design: Making the Model “Get to Work”

    To make the experiment reproducible, the prompt needed to accomplish role setting, objective definition, constraints, and output requirements simultaneously. The core elements are as follows:

    • Role Setting: A dual identity of a senior product manager and a frontend engineer to avoid outputting only design drafts without code.
    • Clear Deliverables: Product report (including structure chart), replicated web page, and improved web page.
    • Clear Reference Source: Target site URL and API documentation entry, stating that access conditions are already met.
    • Clear Execution Method: Require the model to forget existing memory and preset tools, and execute directly based on retrieval and coding capabilities, eliminating the possibility of “memorizing answers.”
    • Two-Phase Prompting: The first round only provided requirements, forcing the model to complete requirement analysis first; the second round provided API credentials, allowing the model to complete real integration, observing whether it went back to correct the assumptions from the first round.

    Example prompt structure:

    1. Role: Senior Product Manager with full-stack frontend capabilities
    2. Objective: Replicate the web chat product of [Target Site]
    3. Deliverables:
    4. 1. Product feature document + functional structure diagram
    5. 2. High-fidelity replica (UI/interaction consistent with the original site)
    6. 3. Improved version (optimize UI/UX based on your product understanding)
    7. Constraints: Do not rely on existing memory; execute directly based on browsing and retrieval results

    IV. Evaluation Dimensions: The Gap from “Runs” to “Usable”

    Different model/execution framework combinations showed obvious gradients in the experiment, which can be summarized into five dimensions:

    1. Requirement Coverage: Whether all three deliverables are complete, and whether the document addresses interaction states rather than just listing menus.
    2. Fidelity Accuracy: Whether the layout, spacing, and responsive breakpoints match the original site; details like the mobile input area position are the true touchstone.
    3. Engineering Quality: Whether the code is modular, whether styles are uniformly managed using design variables, and whether loading and error states are handled.
    4. Integration Depth: After obtaining API credentials, whether it truly runs end-to-end streaming output, rather than just writing static call code.
    5. Self-Testing & Iteration: This is the dimension with the largest variance. Some models only do the simplest connectivity test before delivery after getting credentials; others proactively construct boundary scenarios such as long text, special characters, and continuous follow-ups to discover and fix defects. The latter is closer to a real engineer.

    V. Technical Tips for Improving Fidelity

    Regardless of which model executes, the following engineering practices can significantly improve result stability:

    • Extract Design Variables: Define colors, font sizes, border radius, and spacing as CSS variables for easy fine-tuning against the original site.
    • Use Modern Layout Primitives: Use Flex/Grid for the outer skeleton, flexible scroll containers for the message area, and fix the input area at the bottom.
    • Streaming Rendering: When the API returns chunked content, use incremental parsing to update the message area while keeping the scroll bar following the bottom (pause following when the user manually scrolls up).
    • State Machine Thinking: Maintain idle/thinking/streaming/error states for each request, and explicitly present them in the UI to prevent duplicate submissions during generation.
    • Mobile-First Verification: Use browser device emulation to check touch target sizes and safe areas one by one.

    Example code (streaming output and auto-scroll):

    1. async function send(message) {
    2. const bubble = appendBubble('assistant');
    3. setState('streaming');
    4. const res = await fetch(API_URL, {
    5. method: 'POST',
    6. headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${KEY}` },
    7. body: JSON.stringify({ messages: [...history, { role: 'user', content: message }] })
    8. });
    9. const reader = res.body.getReader();
    10. const decoder = new TextDecoder();
    11. while (true) {
    12. const { done, value } = await reader.read();
    13. if (done) break;
    14. bubble.append(decoder.decode(value));
    15. if (isNearBottom()) scroller.scrollTop = scroller.scrollHeight;
    16. }
    17. setState('idle');
    18. }

    VI. Design Principles for the Improved Version

    Improvement is not about stacking features, but focusing on the high-frequency pain points of chat products:

    • Controllable Context: Display current context usage, allow deleting early messages to precisely control cost and relevance.
    • Collapsible Process: Long reasoning processes are collapsed by default, only expanding conclusions to reduce visual noise.
    • Actionable Replies: Copy, regenerate, edit and resend to reduce repetitive input.
    • Conversation Assetization: Export as Markdown, generate shareable links (note that shareable links must be verified in a logged-out environment to ensure the recipient can open them).
    • Recoverable Failures: Support breakpoint resume or at least retain generated content after network interruptions.

    VII. Retrospective & Conclusion

    This experiment provides three core conclusions:

    First, under the same task, the delivery quality of different model and execution framework combinations differs mainly in “self-testing depth” and “detail fidelity,” rather than the ability to write a basic page. Combinations that are still willing to do boundary testing and proactively fix issues after obtaining API credentials have final deliverables that are significantly closer to a usable state.

    Second, the two-phase design of the prompt is very effective: analyzing first and then integrating exposes whether the model has truly established a structural understanding of the product, rather than taking a “shortcut” by relying on API documentation in the first step.

    Third, replication tasks are a low-cost method for evaluating the engineering capabilities of models: without the need for manually annotated benchmarks, a publicly accessible target site and a clear output list are sufficient to comprehensively evaluate the model from four perspectives: requirement understanding, aesthetics, engineering, and debugging. For enterprise model selection or personal learning, this “build it and see” evaluation method is closer to real-world workloads than simply running general benchmarks.