Rebuilding a Conversational Web App with Multi-Model Collaboration: Engineering Practices for a Two-Phase Workflow

    This article explains how to use multiple AI models and execution frameworks to recreate a production-quality conversational web experience using publicly available APIs. It covers legal and ethical boundaries, a five-layer architecture, a two-phase prompt workflow that separates requirement definition from key-injected integration, product feature mapping, high-fidelity implementation details (streaming rendering, mobile input handling, cross-browser share verification), enhancement design, a unified evaluation scorecard for comparing models, secure API adapter pseudocode, and a launch-ready acceptance checklist.

    Rebuilding a Conversational Web App with Multi-Model Collaboration: Engineering Practices for a Two-Phase Workflow

    1. Background: From “Open Capabilities” to “Building It Yourself”

    Once a conversational application opens up general-purpose capabilities such as chat, retrieval augmentation, file understanding, text-to-speech, and speech recognition, developers naturally ask: can we build a web client ourselves, based on these public interfaces, with an experience close to a mature product?

    The real question is not “copying a page.” It is how to string product analysis, requirement abstraction, frontend interaction, server-side adaptation, API governance, testing, and continuous optimization into a reusable engineering pipeline. Note that such replication must stay strictly within legally authorized, publicly documented, and independently designed boundaries:

    1. Do not reuse unauthorized trademarks, icons, copy, illustrations, or page assets.
    2. Do not bypass call quotas, concurrency limits, content safety policies, or billing rules.
    3. Do not obtain non-public APIs through reverse engineering.
    4. Conduct security and privacy assessments for sharing, caching, logging, and file uploads.
    5. Target a general-purpose conversational interface and your own business scenarios, not a confusing counterfeit product.

    From an engineering perspective, such a project typically has three deliverables: a product feature report with a feature structure diagram, a high-fidelity web implementation, and an experience-enhanced version for real-world scenarios. These correspond to “understanding the product,” “reproducing the behavior,” and “creating incremental value.”

    2. Overall Architecture and Delivery Boundaries

    Split the system into five layers, and avoid writing model-calling logic directly into page components.

    Presentation Layer

    Handles the conversation list, message stream, input area, attachment uploads, voice entry points, settings panel, error prompts, and mobile adaptation. The presentation layer holds only temporary interaction state and never server-side keys.

    Server-Side Adapter Layer

    Uniformly encapsulates authentication, session management, API forwarding, streaming responses, request cancellation, retries, quota accounting, and audit logs. The client communicates only with your own server, which calls the authorized public APIs.

    Capability Abstraction Layer

    Abstracts chat, retrieval, file parsing, text-to-speech, and speech recognition behind unified interfaces, making it easy to swap implementations, roll out gradually, or degrade gracefully.

    Data and Cache Layer

    Stores session metadata, message indexes, temporary files, summary context, and usage statistics. For sensitive content, apply minimal retention, expiry-based deletion, sanitized logs, and access auditing.

    Observability and Testing Layer

    Records request traces, time to first token, total latency, error codes, retry counts, usage, and frontend interaction events. Testing covers unit tests, API contract tests, end-to-end tests, visual regression, and cross-device acceptance.

    A typical request flow looks like this:

    1. Web client
    2. -> Own server API
    3. -> Capability adapter
    4. -> Authorized API
    5. -> Streaming results back
    6. -> Incremental rendering on the frontend
    7. -> Logging, usage, and quality metrics

    Keys must live in server-side environment variables or a secrets management service—never in frontend code, static assets, or browser caches. External APIs should enforce session-level authentication, origin checks, rate limiting, and retry limits to prevent key abuse.

    3. The Two-Phase Prompt Workflow

    To let multiple model execution frameworks produce comparable results against the same goal, adopt a two-phase prompt process.

    Phase 1: Requirement Definition and Artifact Generation

    Phase 1 provides no real keys and asks the executor to complete product analysis, structural design, and UI implementation. The prompt should include:

    1. Roles: a senior product manager, frontend engineer, and backend engineer working together.
    2. Inputs: public product pages, public API documentation, and permitted test assets.
    3. Outputs:
      • A product feature report covering core functions, states, boundaries, and exception paths;
      • A product feature structure diagram;
      • A high-fidelity web implementation;
      • An enhancement plan for real business scenarios.
    4. Constraints:
      • No copying of trademarks, copy, or assets;
      • No fabricated API capabilities;
      • All keys injected via server-side environment variables;
      • Local run instructions and a self-test checklist.
    5. Acceptance criteria:
      • The core chat flow runs end to end;
      • Streaming output, stop generation, regenerate, copy, and feedback interactions are complete;
      • The mobile input area is usable;
      • Error, empty, and loading states are all present;
      • The share/export flow can be verified across browsers.

    Phase 2: Key Injection and Deep Integration

    Phase 2 provides server configuration items and test keys, and requires real API integration, error handling, and regression testing. To prevent the “one simple request and declare victory” problem, bake the acceptance requirements into the prompt:

    • Cover success, authentication failure, rate limiting, timeout, empty responses, and interruptions;
    • Verify stream end markers, request cancellation, and exception recovery;
    • Check the input box position after the mobile soft keyboard opens;
    • Record defects before and after fixes;
    • Deliver a test checklist, known limitations, and a rollback plan;
    • Never write keys into commits, screenshots, or logs.

    Differences between execution frameworks become most visible here: some only run smoke tests, while others construct edge-case inputs and check scroll anchoring, cross-browser sharing, and mobile layouts. A unified workflow and unified acceptance scripts are therefore essential for fair comparison and delivery quality.

    4. Product Feature Mapping and Structure Diagram

    A conversational web app can usually be abstracted into the following feature tree:

    1. Conversational Web App
    2. ├─ Session Management
    3. │ ├─ New session
    4. │ ├─ Session history
    5. │ ├─ Rename and delete sessions
    6. │ └─ Share and export
    7. ├─ Message Interaction
    8. │ ├─ Text input
    9. │ ├─ Streaming output
    10. │ ├─ Stop generation
    11. │ ├─ Regenerate
    12. │ ├─ Copy and quote
    13. │ └─ Feedback and error reporting
    14. ├─ Enhanced Capabilities
    15. │ ├─ Retrieval augmentation
    16. │ ├─ File upload and parsing
    17. │ ├─ Image or multimodal input
    18. │ ├─ Voice input
    19. │ └─ Voice playback
    20. ├─ Input Area
    21. │ ├─ Multi-line auto-resize
    22. │ ├─ Quick commands
    23. │ ├─ Attachment entry
    24. │ ├─ Send and interrupt
    25. │ └─ Length and context hints
    26. ├─ System Capabilities
    27. │ ├─ Login and identity
    28. │ ├─ Quota and rate-limit prompts
    29. │ ├─ Error recovery
    30. │ └─ Settings and preferences
    31. └─ Quality Assurance
    32. ├─ Accessibility
    33. ├─ Performance monitoring
    34. ├─ Security audit
    35. └─ Cross-device adaptation

    The report must not merely list “which buttons exist”—it must describe state transitions. For example: sending a message enters a generating state; tapping stop enters a canceled state; an API timeout produces a retryable error block; file-parsing failures must distinguish unsupported formats, size limits, and network failures. Only a clearly described state machine prevents the replica from staying at the static-page level.

    5. Key Details for High-Fidelity Implementation

    Visual Fidelity

    Start by defining design variables: colors, font sizes, line heights, spacing, radii, shadows, borders, breakpoints, and animation durations. Reuse these variables across all components to avoid unmaintainable “this button is two pixels off” implementations.

    Visual regression testing can establish baseline screenshots across multiple viewports, covering desktop, narrow screens, soft keyboard open, long messages, code blocks, tables, quotes, error blocks, and empty sessions. Set reasonable comparison thresholds that catch layout drift without false positives from font rendering differences.

    Input Area and Mobile Adaptation

    The input area is where experience differences show up fastest. Verify specifically:

    • Whether multi-line input grows with content and respects a maximum height;
    • Whether the input box is obscured when the soft keyboard opens;
    • Whether safe areas, bottom gesture zones, and fixed toolbars conflict;
    • Whether the send button state is correct for empty input, generation in progress, and uploading attachments;
    • Whether pasting long text triggers a length hint;
    • Whether scrolling to the latest message keeps a stable anchor on mobile.

    The position, size, and keyboard avoidance of the mobile input box often matter more than desktop behavior for “feeling like the original product.” Acceptance should therefore use a real mobile browser or emulation for interaction testing, not static screenshots alone.

    Message Stream and Streaming Rendering

    Streaming output must handle incremental content, end markers, request cancellation, and abnormal interruptions. Avoid triggering full reflows on every character; update message blocks incrementally and defer or segment rendering for rich content such as code blocks, tables, and links.

    Key interactions include:

    • Show a stop button during generation;
    • Preserve already-generated content after user interruption;
    • Show a retryable error block on network failures;
    • Keep the original message version when regenerating;
    • Copy raw text rather than rendered styling;
    • Don’t force-scroll back to the bottom during long sessions if the user has scrolled away.

    Cross-Browser Acceptance of the Share Flow

    Sharing is often underestimated. In practice, share links may depend on login state, local caching, CORS policies, browser history state, or temporary storage. Verifying only in your own browser is not enough. At minimum, verify:

    1. Prompts and redirects when an unauthenticated user opens a share link;
    2. Permission checks after login when opening a share link;
    3. Layout and content consistency across different browsers;
    4. Whether shared content contains sensitive information;
    5. Handling of expired, deleted, and repeatedly visited links.

    This deserves an explicit entry in the acceptance checklist: share links require secondary verification in a different browser or an independent session.

    6. Enhanced Version Design: From “Looks Like It” to “Works Well”

    After completing the high-fidelity version, the enhanced version should not just add more buttons—it should fill gaps around real development and business scenarios.

    Context Management

    Provide summaries, pinned context, manual cleanup, and key-message markers for long sessions. Users should see roughly how much context is in use and get warned before exceeding limits, rather than discovering a failure after sending.

    Traceable Results

    When retrieval augmentation is enabled, results should show citation sources, fetch times, and summaries. For file Q&A, display the file name, page number, or paragraph location so users can verify.

    Failure Recovery and Degradation

    The server should support timeout retries, idempotent requests, rate-limit queuing, and degradation prompts. For asynchronous capabilities such as voice and files, expose task status and cancellation entry points to prevent duplicate submissions.

    Cost and Quota Governance

    Record per-session usage, request latency, and error rates. Apply rate limits and budget alerts by user, tenant, and API dimension to avoid waste from abnormal retries or scripted calls. Clearly surface limits such as free quotas, maximum input length, and concurrent sessions in the UI.

    Security and Compliance

    File uploads require type, size, and content-safety checks; avoid logging full keys, ID numbers, contact details, or other sensitive information; shared content should support permission control and expiration. The server must also guard against prompt injection, unauthorized access, and malicious file parsing.

    Accessibility and Efficiency

    Support keyboard navigation, focus management, screen reader labels, contrast, and adjustable font sizes. For power users, provide quick commands, draft auto-save, message export, and bulk deletion.

    7. Unified Evaluation Across Multiple Models

    When multiple models and execution frameworks tackle the same replication task, it is easy to conflate “model capability” with “execution framework strategy.” Use a unified scorecard instead of judging only by final screenshots.

    Reference dimensions:

    Dimension Focus
    Product analysis Whether the feature tree is complete and states/exception paths are covered
    Fidelity Whether layout, spacing, interactions, and the mobile input area are stable
    Functional correctness Whether sessions, streaming, cancel, retry, attachments, and sharing work
    Engineering quality Whether layering is clean, keys are secure, and error handling is complete
    Test depth Whether edge inputs, cross-browser behavior, rate limits, and timeouts are covered
    Maintainability Whether configuration, adapters, logs, and documentation are complete
    Enhancement value Incremental capabilities like context management, citations, quota governance, and accessibility

    In practice, the most consistently strong combination is usually not the one that “generates code the fastest,” but the one that:

    1. Produces a structured product report before coding;
    2. Defers real key integration to phase 2 and proactively runs deep integration testing;
    3. Pays attention to details like the mobile input box and cross-browser share verification;
    4. Leaves fix records and self-test checklists for failure scenarios;
    5. Decouples the capability adapter layer from page components for future API swaps;
    6. States known limitations instead of showing only the happy path.

    8. API Adapter and Security Pseudocode

    Here is a generic capability adapter example showing how the server hides keys and uniformly handles streaming responses:

    1. interface ChatService {
    2. stream(request): AsyncIterator<Chunk>
    3. cancel(requestId): Promise<void>
    4. }
    5. type ChatRequest = {
    6. sessionId: string
    7. messages: Message[]
    8. attachments?: AttachmentRef[]
    9. maxTokens: number
    10. capability: "chat" | "search" | "file" | "speech"
    11. }
    12. function handleChat(req, ctx) {
    13. assertSession(ctx)
    14. assertRateLimit(ctx.userId)
    15. assertInput(req)
    16. const requestId = createTraceId()
    17. const adapter = selectAdapter(req.capability)
    18. return streamResponse(async (emit) => {
    19. try {
    20. for await (const chunk of adapter.stream({
    21. ...req,
    22. requestId,
    23. key: readServerSecret()
    24. })) {
    25. emit(chunk.delta)
    26. recordUsage(chunk.usage)
    27. }
    28. emitDone()
    29. } catch (err) {
    30. emitError(toUserSafeError(err))
    31. recordFailure(err, requestId)
    32. }
    33. })
    34. }

    This pseudocode emphasizes three principles: keys are read only on the server; every request carries a trace ID; and errors return user-friendly messages while detailed errors go into controlled logs.

    9. Acceptance Checklist

    Before launch, confirm item by item:

    • The core chat flow supports send, streaming receive, stop, retry, and regenerate;
    • Empty input, oversized input, rate limits, timeouts, and auth failures all have clear prompts;
    • File uploads have type, size, and content-safety validation plus a deletion mechanism;
    • Share links pass acceptance in different browsers and independent sessions;
    • The mobile input area is not obscured when the soft keyboard opens;
    • Keys never enter frontend bundles, logs, screenshots, or commit history;
    • Key events have monitoring and alerting, and sensitive fields are sanitized;
    • A degradation plan and rollback instructions exist;
    • Accessibility basics pass inspection;
    • Data retention periods and user deletion paths are clearly defined.

    10. Conclusion

    Open APIs make “building your own conversational web app” more feasible, but the real difficulty is not sending a single request. It lies in whether the product analysis is complete, interaction states are rigorous, keys and quotas are secure, testing is deep enough, and the enhanced version solves real problems.

    Multi-model and multi-framework collaboration can boost throughput, but only with unified requirement templates, acceptance scripts, and scoring standards. Only by closing the loop between the product report, feature structure, high-fidelity implementation, enhancement plan, and quality assurance can a one-off “replication experiment” become reusable engineering capability.