Rebuilding a Conversational AI Application with AI Coding: A Complete Engineering Practice

    This article walks through the full engineering practice of rebuilding a conversational AI application with AI-assisted coding. Instead of merely replicating a UI, it covers three separate deliverables—product analysis, baseline implementation, and experience optimization—along with requirement evidence tables, feature structure diagrams, state-driven UI design, secure server-side API integration, streaming response lifecycle management, phased task execution, multi-dimensional quality evaluation, and a closed loop from requirements to acceptance. Readers will learn how to turn AI coding tools from page generators into reliable engineering partners while keeping requirement boundaries, security responsibilities, and acceptance judgment under developer control.

    Rebuilding a Conversational AI Application with AI Coding: A Complete Engineering Practice

    1. From “UI Replication” to “Product Rebuilding”

    When facing a mature conversational application, the most intuitive development task seems to be recreating the sidebar, message list, and input box. However, what truly determines whether a product is usable is often the part invisible in screenshots: how conversations are persisted, how responses are progressively displayed, how requests recover after failure, how user identities are isolated, and whether the page remains operable when the mobile keyboard pops up.

    Therefore, rebuilding a conversational application with AI coding should not pursue visual similarity alone. The work should be split into three independent deliverables:

    1. A product analysis document that records observed features, interaction rules, and items pending confirmation.
    2. A baseline implementation that verifies whether core functionality and interaction flows are complete.
    3. An optimized design version that addresses clearly defined experience problems after the baseline flow is stable.

    These three deliverables correspond to “understanding the product,” “implementing the product,” and “improving the product.” Mixing them together leads to problems such as expanding features before requirements are confirmed, or adjusting visual styles before the basic flow even works.

    It is also necessary to distinguish between open model capabilities, open APIs, open components, and fully open-sourced applications. These are not the same thing. Even if you can access a certain model capability, it does not mean you can directly obtain an existing application’s UI code, account system, session management, or deployment configuration. Open capabilities can serve as a development foundation, but they cannot replace application engineering.

    2. Establish Requirement Evidence Before Generating Code

    AI coding tools can produce code quickly, but their understanding of requirements depends on the input material. Providing only a reference page plus an instruction like “make it as similar as possible” leaves enormous room for interpretation.

    A more reliable approach is to build a requirement evidence table:

    Requirement Category What to Record Verification Method
    Page layout Navigation area, content area, input area, and their positional relationships Observe under different viewports
    Session management Create, switch, rename, delete, and history restoration Execute complete operation flows
    Message interaction Submit, cancel, retry, copy, and error feedback Test both normal and abnormal scenarios
    Input rules Empty input, line breaks, long text, and rapid consecutive submissions Boundary testing
    Identity and permissions Login state, session ownership, and access restrictions Multi-identity testing
    Sharing capability Sharing scope, access conditions, and revocation behavior Verify in an independent access environment

    The items above are general checks and do not imply that every reference application has all these features. Only observed capabilities can be listed as confirmed requirements; anything unverifiable should be marked as “to be confirmed” rather than being filled in by the development tool as assumed facts.

    For screenshots, page descriptions, and interaction recordings, the collection conditions should also be documented. For example, desktop and mobile layouts may differ, entry points may differ before and after login, and the number of historical sessions may affect the scrolling behavior of the navigation area.

    In addition, UI references should be built within the scope of legal authorization and fair use. You can learn from general layout and interaction principles, but you should not copy unauthorized logos, proprietary assets, or protected content, nor should you package the result as the original service.

    3. Define Development Boundaries with a Feature Structure Diagram

    A product document should serve implementation and acceptance, not merely list page elements. It is recommended to structure features around user tasks:

    1. Conversational Application
    2. ├─ Identity & Access
    3. │ ├─ Login state detection
    4. │ ├─ Session access control
    5. │ └─ Logout and local state cleanup
    6. ├─ Session Management
    7. │ ├─ Create session
    8. │ ├─ Query session history
    9. │ ├─ Rename title
    10. │ └─ Delete with confirmation
    11. ├─ Message Interaction
    12. │ ├─ Text input
    13. │ ├─ Request submission
    14. │ ├─ Response rendering
    15. │ ├─ Stop generation
    16. │ └─ Failure handling
    17. ├─ Content Presentation
    18. │ ├─ Plain text
    19. │ ├─ Structured content
    20. │ └─ Copy and feedback
    21. └─ System Safeguards
    22. ├─ Key management
    23. ├─ Rate limiting
    24. ├─ Logging and monitoring
    25. └─ Data retention policy

    This structure should be trimmed according to actual scope. For example, if the project is only for single-user local verification, a full account system can be deferred—but you must explicitly state that “multi-user isolation is not supported.” Omitted features must not be silently treated as completed.

    Every feature should also have acceptance criteria. Take session deletion: writing “supports deletion” is not enough. You should clarify whether confirmation is required, what is displayed after deleting the current session, whether the list is restored when the request fails, and whether other pages can still access the deleted session.

    4. The Core of UI Reproduction Is State Consistency

    A page is not a static image; it is an interaction system driven by state. A conversational application must handle at least the following states:

    1. Initial empty state: no messages yet; show onboarding content.
    2. Editing state: input content changes, and submit conditions update accordingly.
    3. Waiting state: the request has been sent, but no response content has arrived.
    4. Generating state: response content arrives continuously and the page updates incrementally.
    5. Completed state: the current response has finished; further interaction is allowed.
    6. Cancelled state: the user actively stops generation; partial content is retained and the result is labeled.
    7. Failed state: network, authentication, or service errors occur, with an understandable message provided.

    The transitions between these states must be explicit. For example: is resubmission allowed during generation? Does switching sessions cancel the current request? Does retrying create a new message record? All of these should be decided before development begins.

    Layout implementation must also cover dynamic scenarios. On mobile, the input box position is affected by the visual viewport, the soft keyboard, and safe-area insets; it cannot be handled with a fixed height alone. Long messages change the page’s scroll range, code blocks may introduce horizontal scrolling, and a growing history list can affect navigation layout.

    Auto-scrolling is especially easy to overlook. A reasonable behavior is: when the user is still at the bottom of the message list, new content can follow the scroll; when the user has scrolled up to read, they should not be forcibly pulled back to the bottom—instead, a “new content” indicator should appear. Details like this affect usability far more than matching colors and border radii.

    5. API Integration Should Establish a Security Boundary Through the Server

    Handing an API key to an AI coding tool does not equal completing secure integration. Long-term credentials should never be written directly into browser-side code, nor should they appear in publicly accessible configuration files, screenshots, or logs.

    The recommended general path is:

    1. User Interface → Application Server → Model Service API

    The application server is responsible for identity verification, request validation, key retrieval, upstream invocation, response forwarding, and error normalization. The browser only talks to the application’s own server and never holds upstream long-term keys.

    Three boundaries deserve engineering attention:

    Credential boundary. Development, testing, and production environments should use different credentials, injected through controlled configuration. During AI coding sessions, use placeholder values or restricted test credentials to keep real keys out of unnecessary contexts.

    Permission boundary. When querying, modifying, deleting, or sharing sessions, the server must verify access rights. It cannot rely solely on whether the page shows the corresponding button.

    Resource boundary. The application needs input limits, concurrency control, request timeouts, and usage quotas based on its own budget and capacity. Specific values should be determined by actual constraints, not copied from other services’ rules.

    6. Streaming Responses Require Lifecycle Management, Not Just Text Concatenation

    Progressively displaying answers improves perceived experience, but streaming responses are more complex than one-shot returns.

    A complete flow typically includes: establishing the request, reading data, parsing events, incrementally updating the UI, receiving the termination signal, and cleaning up resources. If the network drops mid-stream, the page needs to distinguish a normal completion from an abnormal interruption. If the user actively cancels, the frontend should stop consuming data and notify the server to cancel the related task through whatever mechanism is available.

    Several common pitfalls should be avoided:

    Cross-session writes. The user switches sessions after a request is sent, and the returning content gets appended to the newly visible page. The solution is to bind each request to an explicit session and message record, rather than always writing to whichever session is currently visible.

    Duplicate submissions. Disabling the button only reduces misclicks; it cannot replace server-side duplicate request detection. When message persistence is involved, a verifiable deduplication mechanism should be designed.

    Inconsistency between displayed state and stored state. The page shows partial content, but the server never saved it, so the message disappears after a refresh. The persistence strategy for incremental content, final content, and interrupted content must be clearly defined.

    Cancellation misjudged as failure. A user-initiated stop and a network failure are different events. They should produce different messages and retain traceable states.

    7. AI Coding Tasks Should Be Executed in Phases

    Asking a tool to complete product analysis, baseline implementation, and innovative design in one go easily overloads the context and makes errors hard to locate. A more effective task breakdown is:

    Phase 1: Observation and requirement organization only. Output the feature list, page structure, state transitions, and unconfirmed items—no business implementation yet.

    Phase 2: Architecture and data model. Define the relationships among sessions, messages, users, and share records, and clarify which states live on the client and which must be managed by the server.

    Phase 3: Minimum viable loop. First verify creating a session, sending a message, receiving a response, saving history, and showing failure messages—then extend to other capabilities.

    Phase 4: Interaction and adaptation completeness. Handle long content, mobile layout, keyboard operations, scroll strategy, and accessibility.

    Phase 5: Security and exception testing. Check for credential leakage, permission bypass, input boundaries, and resource cleanup.

    Phase 6: Experience optimization as a separate effort. Each new feature should state the user problem, implementation cost, and acceptance method—avoid piling up entry points just to demonstrate capability.

    Throughout the process, a tool’s claim of “done” should only be treated as a statement awaiting verification. Whether something is truly complete is determined by repeatable tests and human review.

    8. Evaluate Implementation Quality, Not Just Generation Speed

    Different AI coding workflows may emphasize planning, coding, and testing differently, but a general ranking cannot be derived from a single generation result. If evaluation is needed, keep requirements, environment, permissions, time budget, and acceptance criteria as consistent as possible, and record the number of manual fixes and the final delivery state.

    A multi-dimensional evaluation is recommended:

    • Functional completeness: Are key flows usable? Are there features that have buttons but no actual behavior?
    • Visual and interaction consistency: Do layout, state feedback, and operations across different screen sizes match requirements?
    • Engineering quality: Are code responsibilities clear, configurations separated, and error handling unified?
    • Security: Are keys protected? Are access permissions checked on the server? Do logs leak sensitive content?
    • Stability: Do abnormal interruptions, repeated clicks, page refreshes, and session switches cause state errors?
    • Maintainability: Does adding a feature require large-scale changes? Can tests cover critical behaviors?

    Test reports should also distinguish among “passed,” “failed,” and “not verified.” For example, the fact that a shared page opens in the current logged-in window does not prove the independent access scenario works; it must be verified with a different identity or a logged-out state, and the access scope must be checked against the design.

    9. Experience Optimization Should Be Built on Reliability

    An optimized version should not simply add more buttons. More valuable improvements usually reduce the user’s operational and cognitive costs.

    For example, a clearly visible generating state can reduce duplicate submissions; error messages that explain whether a retry is worthwhile can reduce futile actions; searching historical sessions helps users quickly retrieve content; and sensible keyboard operations and focus management improve the experience of continuous work.

    Every optimization should rest on a verifiable hypothesis. For instance, “adding history search reduces the steps needed to find old sessions” can be verified through task operation paths; “adjusting the input area improves mobile usability” should be validated under scenarios such as the soft keyboard opening, long-text input, and orientation changes.

    At the same time, new capabilities bring new engineering costs. File input involves format validation, content extraction, and storage lifecycle; public sharing involves permissions, revocation, and sensitive information exposure; multi-user collaboration involves authorization, conflict handling, and auditing. When the corresponding governance capabilities are not ready, keeping the baseline product reliable should take priority.

    10. Form a Closed Loop from Requirements to Acceptance

    The greatest benefit of rebuilding a conversational application with AI coding is not quickly generating a similar-looking page, but shortening the feedback cycle among requirement understanding, implementation verification, and defect fixing.

    A trustworthy delivery should contain at least: a product document backed by evidence, a clear feature structure, a runnable core flow, protected API integration, test records covering abnormal scenarios, and an explicitly listed set of known limitations.

    Only by separately verifying “looks similar,” “actually works,” and “is maintainable over time” can a one-off page demo be turned into a reliable engineering outcome. AI coding can shoulder a large share of the implementation work, but requirement boundaries, security responsibility, and acceptance judgment must remain in the developer’s hands.