Rebuilding a Conversation App with AI Coding: From Requirements to Reliable Delivery

    Recreating a chat UI is easy with AI coding tools—but a demo page is not a shippable product. This article walks through a complete engineering workflow for rebuilding a conversation application: extracting requirements from reference interactions, defining three tiers of deliverables, designing state-driven UI, structuring a secure front-end/back-end architecture, handling streaming consistency, and running acceptance tests that cover failure paths. Learn how to turn "generate a similar page" into a reproducible, verifiable delivery process.

    1. From “Generating a Similar Page” to “Rebuilding a Complete Product”

    As model APIs, front-end components, and technical documentation have become widely accessible, the barrier to building a conversation application has dropped significantly. With AI coding tools, you can generate a runnable page containing a session list, message area, and input box in a short time.

    However, runnable does not mean deliverable, and looking similar does not mean functionally complete.

    A mature conversation application has at least three layers: the interface users see, the state changes triggered by user actions, and the services and data flows that support those actions. Reproducing only the first layer typically yields a demo prototype; only when all three layers form a closed loop does it become a product people can use continuously.

    Therefore, this kind of exercise should not revolve around imitating the appearance of a specific product, but should be reframed as a general engineering question:

    How can you use AI coding to extract requirements from reference interactions and rebuild a conversation application that is functionally complete, secure, controllable, and easy to verify?

    Boundaries must also be clear here: open-source code or published technical materials do not mean all brand assets, interface artwork, and service capabilities can be used freely. Before development, check licensing scope, asset usage rights, and terms of service. Interaction patterns can be studied for technical purposes, but a public release should use independent visual design and product branding to avoid source confusion.

    2. Define Three Types of Deliverables Before Writing Code

    Directly asking an AI coding system to “build the page” often leads it to prioritize the most demonstrable parts while ignoring session persistence, error handling, and security boundaries.

    A better task design is to specify three types of deliverables explicitly.

    1. Product Requirements Report and Functional Structure Diagram

    The product report is not a set of screenshots—it is a systematic description of functions, states, and boundaries. Each feature should specify at least:

    • The scenario in which users need it;
    • Where the entry point is;
    • What the preconditions are;
    • How successful completion is confirmed;
    • How failures, cancellations, and permission errors are handled;
    • What criteria determine whether the implementation passes.

    For example, “send a message” cannot simply be written as “click the button and get a reply.” It should also cover empty-input handling, duplicate-submission control, generating state, stop generation, error messages, and session persistence.

    The functional structure can first be expressed as a text tree:

    1. Conversation App
    2. ├─ Session Management
    3. │ ├─ Create and Switch
    4. │ ├─ Rename and Delete
    5. │ └─ History Restore
    6. ├─ Message Interaction
    7. │ ├─ Input and Send
    8. │ ├─ Streaming Display
    9. │ ├─ Stop Generation
    10. │ └─ Copy and Regenerate
    11. ├─ Content Display
    12. │ ├─ Rich Text and Code Blocks
    13. │ ├─ Long-Content Scrolling
    14. │ └─ Error State Messages
    15. └─ Baseline Safeguards
    16. ├─ Identity and Permissions
    17. ├─ Credential Protection
    18. ├─ Usage Controls
    19. └─ Logging and Monitoring

    Any capability not confirmed in the reference materials should be marked as “suggested addition” or “to be confirmed”—never presented as an existing feature.

    2. Baseline Implementation Version

    The baseline version’s goal is to implement only the confirmed requirements, without mixing in a pile of self-selected features. This is the only way to judge whether the coding system actually understood the original task, rather than substituting a visually attractive but behaviorally different page.

    Acceptance checks should cover both layout and behavior: input areas on desktop and mobile, message restoration after switching sessions, button state changes during generation, and user-facing error notifications when things go wrong.

    3. Separate Optimization Version

    The optimization version should be kept separate from the baseline, so that you can distinguish deliberate improvements from implementation drift.

    Every optimization must answer three questions: what pain point it solves, what cost it adds, and how its effect is verified. For example, adding session search helps find historical content, but you also need to define search scope, permission filtering, and index update strategy—not just drop in an input box with no real functionality.

    3. Requirement Observation Should Record States, Not Just Appearance

    The most common mistake when analyzing a reference interface is observing only static pages.

    A conversation application is actually a state-intensive system. The same send button may have different availability and meaning when input is empty, input is valid, a response is pending, generation is in progress, or an error has occurred.

    Build a state checklist:

    State Page Appearance Behavior to Verify
    Empty session Shows onboarding content and input area First send creates and persists the session
    Waiting for response Shows a pending indicator Prevent accidental duplicate submission; allow cancel
    Generating Content updates continuously Text appends correctly; stop is supported
    Generation complete Shows full reply with action buttons Content is saved; input state is restored
    Request failed Shows an understandable error message User input is preserved; retry is allowed
    History restored Loads saved messages No content from another session leaks in during switching

    Mobile also requires separate verification of the soft keyboard, viewport changes, long text input, and safe-area adaptation. A fixed-position layout that looks correct on desktop may cover the input box or push the send button off-screen on a phone.

    Server-side mechanisms that cannot be observed directly should be recorded as unknowns. Do not infer internal database schemas, scheduling strategies, or context handling from page behavior alone.

    4. Architecture: Front End Handles Interaction, Back End Guards the Boundary

    A general-purpose conversation application can use the following structure:

    1. Browser UI
    2. ↓
    3. Application Server
    4. ├─ Authentication and Session Permission Checks
    5. ├─ Request Validation and Usage Controls
    6. ├─ Model Invocation Adapter Layer
    7. ├─ Session and Message Storage
    8. └─ Logging, Monitoring, and Error Handling
    9. ↓
    10. Model Inference Service

    1. Never Put Long-Term Secrets in the Browser

    Once you obtain API credentials during development, do not write them into front-end source code for the sake of quick connectivity. Browser code, network requests, and local storage cannot be trusted to keep long-term secrets.

    Credentials should be held by the server, which performs identity checks, parameter validation, and authorized invocation upon receiving user requests. Config files, logs, and version control must also be protected against credential leaks.

    2. Isolate Invocation Differences with an Adapter Layer

    The page should not depend directly on the raw response structure of any specific external service. Instead, define an internal, unified data model containing session IDs, message IDs, text fragments, finish states, and error categories.

    These fields are internal conventions you design yourself—they should not be described as an existing interface of any external service. The adapter layer’s value lies in confining service differences to one place, reducing the impact of later maintenance on page logic.

    3. Define Data Ownership and Permissions

    Sessions, messages, and users need explicit ownership relationships. Whenever a session is read, modified, deleted, or shared, the server must check permissions—hiding buttons in the front end is not enough.

    Deletion also needs a clear business definition: immediate physical deletion, soft delete with a flag, or cleanup per a retention policy. If logs, backups, or exported data exist, their handling must be included in the design as well.

    5. Streaming Output: The Hard Part Is State Consistency

    Streaming display lets users see the reply sooner, but it introduces complexities around cancellation, session switching, and persistence.

    1. Transport Chunks Are Not Complete Events

    A chunk received over the network may contain half an event or several events. Your handler needs a buffer and must parse according to actual protocol boundaries—you cannot treat every received chunk as a complete piece of text.

    2. Stop Generation: Distinguish Local from Remote

    Stopping usually means terminating local reading and attempting to cancel the in-flight request. Whether the remote actually stops computing depends on the service protocol and its cancellation mechanism—the page stopping its updates does not mean the remote has terminated.

    Content already displayed also needs explicit handling: for example, keep it and label it as interrupted, rather than letting users believe the reply ended naturally.

    3. Prevent Cross-Session Contamination

    If a user switches sessions while generation is in progress, the old request may continue returning data. If callbacks write directly to the current page, the old reply could appear in the new session.

    A reliable approach is to bind each request to a fixed session ID, message ID, and request ID, and verify ownership before writing. Session deletion, regeneration, and page unload also need to clean up related tasks.

    4. Auto-Scroll Should Respect Reading Behavior

    When the user stays at the bottom of the message list, auto-scrolling with new content is fine; if the user scrolls up to read, forced scrolling should pause and be replaced with a “new content available” indicator.

    Details like these may not affect a screenshot, but they directly determine whether long replies are usable.

    6. Turn Two-Phase Development into a Reproducible Verification Process

    A common workflow is to supply requirements first, then provide invocation configuration. This suits task decomposition, but each phase needs explicit completion criteria.

    Phase one uses mock responses to verify page structure, state transitions, and basic interactions. Phase two connects to the real service to verify network behavior, stream parsing, credential protection, and failure handling.

    A successful mock cannot substitute for real-integration acceptance; one successful real request does not prove the application is reliable.

    If you need to evaluate AI coding delivery quality, standardize:

    • Requirement documents and reference materials;
    • Initial code and runtime environment;
    • Available permissions and tool scope;
    • Time limits and human-intervention rules;
    • When invocation configuration is provided;
    • Test cases and completion criteria.

    Model capability and execution environment should be recorded separately. Browsing ability, file operation permissions, testing tools, and context capacity all affect results—so you cannot attribute all differences to the model itself based on the final page alone.

    Evaluation should also shift from “who generated something prettier” to “which requirements were reliably met.” Check functional coverage, state consistency, UI adaptation, security boundaries, and maintenance documentation separately, rather than compressing everything into a single hard-to-interpret overall score.

    7. Acceptance Testing Must Cover Failure Paths and Real Environments

    Baseline testing can proceed in this order:

    1. Use mock responses to verify input, sending, stopping, and error states.
    2. Connect to the real service and confirm request, response, and persistence flows are complete.
    3. Test empty input, long input, rapid repeated submission, and consecutive retries.
    4. Test network interruption, timeout, restricted access, and service errors.
    5. Switch or delete sessions during generation and check content ownership.
    6. Refresh and re-enter the page to verify persistence and restoration.
    7. Check layout across screen sizes and keyboard states.
    8. Use an isolated browser environment to verify sharing permissions and access boundaries.

    Sharing is especially prone to misjudgment. The developer’s own browser is usually already logged in, so a page opening does not mean a share link works for the intended recipient. Verify separately for logged-out users, authorized access, revoked links, and deleted source sessions.

    Security acceptance should also check whether rich text rendering can execute untrusted content, whether logs record sensitive input, and whether error messages expose internal configuration. Model-generated content should likewise be treated as untrusted input.

    8. Optimizations Must Be Built on Maintainability

    Once the core flows are stable, you can consider session search, content export, shortcut actions, and clearer error recovery. But more features mean more state combinations and higher testing costs.

    For example, content export must handle formats, encoding, and sensitive information; keyboard shortcuts must account for input methods and assistive technologies; attachments involve type validation, access permissions, storage lifecycle, and feedback when processing fails.

    For enterprise scenarios, permission management, data retention, audit logging, and usage controls usually matter more than extra visual polish. For personal scenarios, fast input recovery, clear stop states, and easy history search often improve the experience more directly.

    Every optimization should have acceptance criteria—not “it looks more advanced” as the justification.

    9. Conclusion: Beyond Generation Speed, What Matters Is the Engineering Loop

    AI coding can shorten the distance from requirements to prototype, but it cannot replace requirement confirmation, security design, and quality acceptance.

    The reliable path to rebuilding a conversation application is: extract functions and states first, then establish clear service boundaries; complete the baseline version first, then pursue independent optimizations; verify happy paths first, then cover failure paths and real devices.

    When judging delivery quality, the most important question is not whether the page looks instantly familiar, but whether the system stays consistent while waiting, failing, canceling, restoring, and changing permissions—and whether every claim of “done” is backed by evidence you can re-check.