Multi-Model Web App Replication: A Technical Practice Guide
This article presents a practical engineering approach to replicating and enhancing a conversational web application using multiple LLMs and agent frameworks. It covers task decomposition into information, interaction, data, and quality layers, two-round prompt injection to separate design from integration, state-machine-driven UI restoration, secure API proxying to keep credentials off the frontend, scripted self-testing, and a multi-dimensional evaluation matrix. Readers will learn how to turn vague requirements into verifiable engineering and move generative prototypes toward maintainable systems.
1. Background and Problem Definition
As generative coding enters practical use, a common task pattern has emerged: given a live conversational web application and an API specification, the model is asked to produce three deliverables in a short time—a functional description with a structure diagram, a runnable web replica, and an improved version that enhances the original experience. This kind of task looks like “just copy it,” but it actually tests six capabilities at once: requirement understanding, information extraction, UI restoration, API integration, test validation, and iterative optimization.
The original practice used six combinations of “model + agent runtime framework,” injecting requirements and access credentials in two separate prompt rounds. It observed how each combination differed in delivery quality, validation depth, and defect discovery. This article strips away specific product attributes and abstracts the problem into a general engineering question: how to reliably replicate and enhance a medium-complexity frontend application under multi-model collaboration, and evaluate output quality in a verifiable way.
2. Task Breakdown: Turning “Replicate a Web Page” into an Executable Checklist
Most failures in replication tasks are not about “being unable to write the page,” but about vague requirement boundaries. It is recommended to break the task into four layers first:
- Information layer: what regions, components, states, and copy exist on the page; which requests, responses, and error codes the API documentation defines.
- Interaction layer: paths such as session creation, streaming message output, stopping generation, history, parameter settings, and attachment upload.
- Data layer: fields and lifecycles of the three entity types—sessions, messages, and configuration.
- Quality layer: usability, accessibility, performance, security (credentials never shipped to the frontend), and testability.
A schematic functional structure can be expressed as a pseudo-config, making it easy for models and humans to align:
app:routes: ["/", "/chat/:id", "/settings"]components:- Sidebar(session list, new, delete, rename)- ChatWindow(message list, input box, stop button)- SettingsPanel(model params, theme, shortcuts)states: [empty, streaming, error, done]apis:- chat.completions(streaming)- conversation.history
Once the checklist is clear, model output shifts from “looks similar” to “actually usable.”
3. Prompt and Context Design: The Purpose of Two-Round Injection
The key design of the original method is round-based injection: the first round provides only the role, goal, reference page, and API specification; the second round adds access credentials. The benefit is isolating “design capability” from “integration capability,” preventing the model from fabricating API behavior when credentials are missing.
A recommended prompt skeleton:
Role: Senior product manager + frontend architectGoal: Replicate the conversational web app and produce an improved versionConstraints: Deliver the functional doc and structure diagram first, then code; never hardcode secretsDeliverables: 1) docs 2) runnable page 3) improvement notesRound 2 addition: credentials are ready, complete integration and self-testing
For context management, a long context is not the same as an effective context. Compression should be proactive: keep the API contract, component tree, state machine, and acceptance criteria; discard verbose logs. For overly long histories, use summarization plus retrieval of key snippets for injection.
4. UI Restoration: From Visuals to State Machine
The difficulty of replication lies in “state completeness.” A usable chat interface must at least cover: empty state, loading state, streaming output, error state, and done state. Define the state machine before writing components:
type Msg = { id: string; role: 'user'|'assistant'; content: string };type State = { status: 'idle'|'streaming'|'error'|'done'; msgs: Msg[] };
Streaming output must handle interruption and reconnection; the error state must provide a retry entry point. For accessibility, the input needs a label, buttons need readable names, and color contrast must meet standards. The improved version can add session search, message edit-and-resend, export, shortcuts, and theme switching on top of this, but only under the premise of “not breaking the original information architecture.”
5. API Integration and the Security Baseline
API documentation usually specifies the authentication method, request body, streaming protocol, and error codes. Engineering practice must ensure: credentials exist only on the server or in a local proxy, and are never written into frontend artifacts. A lightweight proxy layer is recommended to forward requests, with the frontend only accessing a same-origin path:
Browser -> /api/chat (same-origin) -> Proxy(injects credentials) -> upstream API
Also implement timeouts, retry limits, error-code mapping, and rate-limit backoff to avoid throwing upstream errors directly at users.
6. Validation Loop: Why Some Combinations Only “Run” While Others “Find Defects”
The most valuable original observation: after receiving credentials, different combinations showed significant differences in self-test depth. Some only verified “it returns something,” while others constructed boundary inputs, simulated stream interruptions, checked error messages and state rollback, and thus discovered and fixed defects.
An actionable self-test checklist:
- Does normal streaming output render token by token and support interruption?
- Are empty input, overly long input, and special characters handled correctly?
- Does the app degrade gracefully and allow retry on upstream timeout or rate limiting?
- Can sessions be restored after refresh?
- Do credentials appear in the network panel or build artifacts?
- Do key controls have accessibility labels?
Scripting this checklist turns “model self-testing” into a repeatable quality gate.
7. Evaluation and Selection: Use a Matrix Instead of Intuition
Evaluation should use multi-dimensional scoring rather than a single-point conclusion. The recommended matrix includes: requirement coverage, UI fidelity, API correctness, number of defects found, code maintainability, and delivery completeness. The value of running multiple combinations in parallel is horizontal comparison of strategy differences: long context favors overall structural consistency, while strong toolchains favor integration and validation—the two are complementary.
8. Engineering Implementation: From Prototype to Maintainable
In a general cloud environment such as Baidu AI Cloud, artifacts can be hosted on object storage and a content delivery network, the proxy service can run on a container platform, and logging and monitoring/alerting services can track error rates and latency; keys can be injected via environment variables or a key management capability. In CI, a pipeline of “build—static checks—self-test scripts—preview” can be fixed so that every replication is traceable and rollback-able.
9. Conclusion
The essence of multi-model web replication is turning vague requirements into verifiable engineering. Round-based prompting isolates design from integration, the state machine guarantees interaction completeness, the proxy layer holds the security baseline, and scripted self-testing plus multi-dimensional evaluation determine the output ceiling. With this method, teams can use general infrastructure such as Baidu AI Cloud to steadily advance generative prototypes into maintainable, extensible real business systems.
