Rebuilding a Chat App with LLMs: A Full Pipeline from Requirements to Deployment

    This article walks through a practical exercise in rebuilding a full-featured conversational application using a general-purpose chat API under resource constraints. It breaks the work into three deliverables, explains a two-round prompting setup with controlled variables, and outlines a layered architecture, five essential prompt elements, a four-layer verification system, and common pitfalls with concrete acceptance criteria. Developers will find a transferable approach for turning generative coding into reliable, production-ready output.

    1. Background and Problem Definition

    A notable trend has recently emerged in the industry: a model provider opened up its application-side API capabilities—covering deep reasoning and retrieval, file input, speech synthesis, and speech recognition—while publicly stating that developers could use them to build functionally equivalent conversational applications. This moved “rebuilding a mature chat product” from a gray area into a legitimate technical exercise.

    However, the subsequent quota adjustments (limits on daily conversations and single-input length) are a reminder that there is an inherent tension between opening up API capabilities and delivering a complete product experience. Rather than getting stuck on commercial strategy, it is better to treat this as a high-quality technical drill: under constrained resources, how can you use the model’s own capabilities to “generate” a complex front-end application and verify that it works?

    This article abstracts away the specific product and defines the problem as follows: given the interaction patterns of a reference site and the documentation for a general-purpose chat API, produce a runnable front-end application along with product documentation and an improvement plan.

    2. Task Breakdown: Three Deliverables Determine Evaluation Validity

    The original exercise required the model to produce three types of artifacts. This design is well worth borrowing, because it breaks the vague task of “generating code” into dimensions that can be scored separately:

    1. Product feature documentation and structure diagram: Assesses requirement understanding and abstraction, outputting the information architecture, page modules, and state transitions.
    2. Replicated pages of the reference site: Assesses fidelity, including layout, components, and interaction details.
    3. An experience-based improved version: Assesses critical thinking—whether the model can propose genuinely valuable optimizations beyond replication.

    The weights of the three should be explicit. If only the second is considered, the model will tend to “paint the skin” (reproduce surface appearance only). Adding the first and third allows the evaluation to distinguish “understanding-based generation” from “imitation-based generation.”

    3. Experimental Design: Variable Control and Two-Round Prompting

    The original exercise selected six combinations of “model + execution framework (harness),” covering different strategies such as long-context, strong-reasoning, and general-purpose chat models. The key methodology here is variable control: model capability and execution framework strategy are two different kinds of variables, and the framework determines whether the model proactively runs tests and iterates on fixes.

    The prompts were delivered in two rounds:

    • Round one: role setting + target site + API documentation + available browsing tools, asking the model to start working.
    • Round two: supplementary key information, observing how model behavior diverges.

    The divergence was highly instructive: some combinations performed only minimal connectivity verification after receiving the key; others constructed multi-scenario test cases, proactively discovered boundary defects, and revised the code. This is not a capability gap but a strategy gap—whether the “verify-and-fix” loop is enabled by default.

    Under a unified operating standard, the reusable round-two prompt pattern is as follows:

    1. The key is configured in the environment variable API_KEY. Do not hardcode it.
    2. Please complete: 1) minimal connectivity verification; 2) boundary cases
    3. covering empty input, oversized input, stream interruption, and error codes;
    4. 3) directly fix the issues found and explain the root cause; 4) output a
    5. verification record.

    4. Architecture Recommendations: Layered Design for Replication Apps

    Regardless of which type of model generates the output, the final artifact should follow clear layering; otherwise it cannot be maintained later:

    • Presentation layer: conversation list, message stream, input area, attachment upload, voice entry points. Componentization with centralized state management is recommended.
    • Conversation state layer: message array, streaming fragment buffer, interruption flag, retry queue.
    • Capability adapter layer: encapsulate reasoning retrieval, file parsing, speech synthesis, and speech recognition behind a unified interface, hiding the differences.

    Illustrative encapsulation:

    1. interface Capability {
    2. chat(stream: AsyncIterable<string>): Promise<void>;
    3. transcribe(file: Blob): Promise<string>;
    4. synthesize(text: string): Promise<Blob>;
    5. }

    The value of the adapter layer is that when upstream quotas or protocols change, you only need to replace the implementation without touching business code.

    5. Prompt Engineering Essentials

    To get a model to reliably produce usable engineering output, a prompt needs five elements: role, constraints, reference materials, deliverables list, and acceptance criteria. Among these, acceptance criteria are the most easily overlooked, yet they are the watershed of quality. For example, explicitly require that “error messages must be retryable,” “streaming rendering must not cause whole-block reflow,” and “a truncation strategy must be provided under long context.”

    Security boundaries should also be explicitly constrained: keys are read only from environment variables, never exposed on the front end, and masked in logs. Writing these constraints into the prompt is far cheaper than reviewing them after the fact.

    6. Verification System: From “It Runs” to “It’s Trustworthy”

    A four-layer verification system is recommended:

    1. Static checks: types, build, dependency integrity.
    2. Connectivity verification: one successful conversation is enough.
    3. Boundary verification: empty input, oversized text, concurrent requests, network interruption, authentication failure.
    4. Experience verification: streaming output smoothness, scroll behavior, attachment and voice pipelines.

    In general engineering practice on platforms such as Baidu AI Cloud, this kind of verification is typically implemented alongside logging services and monitoring alerts, turning “intermittent failures” into observable metrics rather than relying on manual spot checks.

    7. Common Defects and How to Avoid Them

    • Reproducing visuals but not state: input is lost after switching conversations.
    • Hardcoded keys: written directly into the front-end artifact, creating a leak risk.
    • No interruption capability: streaming output cannot be canceled, breaking the user experience.
    • No fallback path: a blank screen when the quota is exhausted, instead of a friendly message and queuing.
    • Vague improvements: the third deliverable ends up as “add a theme color,” lacking information gain.

    The way to avoid these is to map each type of defect to an executable acceptance item and include it in the round-two prompt.

    8. Conclusion

    “Rebuilding a conversational application” may look like a front-end task, but it is actually a combined assessment of requirement abstraction, architectural layering, prompt constraints, and a verification loop. What truly sets results apart is not the model’s parameter count but whether verification and iteration are enabled by default. For developers, the transferable conclusion is a single sentence: break deliverables into fine-grained pieces, hard-code the acceptance criteria, and automate verification—only then can generative tools truly enter the production workflow.