Clean-Room Replication of Mobile Apps: A Five-Step Framework and Cost Breakdown

    This article presents a practical framework for replicating a mobile app's behavior through clean-room methods, without reverse engineering or packet capture. It defines a six-level fidelity scale, explains how to connect a physical device for direct debugging, and shows how to combine UI control-tree dumps with screenshot analysis to reconstruct interfaces. It also covers turning observations into engineering inputs such as per-screen UI diff tables and behavior audit tables, rebuilding the native client and server, and running same-device acceptance checks. Four effect-level assertions, a breakdown of the low-cost workflow, common pitfalls, and a reusable knowledge pack structure are included.

    1. Background: Why App Replication Needs a Methodology

    In real development work, a common request comes up: you see a mobile product with smooth interactions and complete features, and you want to build a similar app quickly for learning, validation, or further development. The source material describes an approach that uses AI coding tools and terminal automation to fully rebuild a mobile product with image generation, video generation, video editing, and video extension capabilities within a very low budget and a short time window, while also delivering the server side and a reusable knowledge pack.

    The hard part of this kind of work is not writing code. It comes down to three things:

    1. Explaining how a black-box app behaves: what the UI looks like, how state transitions work, and how errors are surfaced.
    2. Turning visible results into acceptance-ready specifications: you cannot just reproduce a static appearance; you also have to reproduce dynamic output.
    3. Controlling the cost of trial and error: repeated screenshots, comparisons, reinstalls, and tuning consume a lot of time and money.

    That is why a structured method is needed, rather than a pile of scattered tips.

    2. Key Prerequisite: Clean-Room Replication and Compliance Boundaries

    This article focuses on clean-room replication: observe only publicly visible UI and interaction results, with no decompilation, no packet capture, and no access to any non-public implementation. All native code and server logic is written from scratch.

    The engineering value of this approach is threefold:

    • Lower legal risk: you never touch protected implementation details.
    • Lower technical barrier: no reverse engineering or protocol analysis is required.
    • Better maintainability: the output is code and specification documents you fully control.

    One point should be clear: the goal of replication is to understand and implement similar capabilities, not to copy someone else’s product for commercial release. Engineering practice should stay at the level of learning, prototype validation, and building your own product.

    3. The Five-Step Framework: Turning a Black Box into Executable Specifications

    The overall flow is: define the level → connect a physical device directly → parse semantics and screenshots → produce a specification checklist → rebuild and run same-device acceptance.

    Step 1: Define the level, and decide how far the replication should go

    A vague notion of “replication” is the root cause of projects going out of control. Six levels are suggested:

    • L0 Visual similarity: only the layout is close.
    • L1 Interaction similarity: the main click paths work.
    • L2 Structural consistency: page hierarchy and navigation match.
    • L3 Effect consistency (default target): the same input produces the same kind of output.
    • L4 Boundary consistency: branches such as errors, empty states, timeouts, and permission denials match.
    • L5 Performance consistency: response latency and resource usage are in the same range.

    Lock the default at L3, and explicitly reject static fake data: all lists, detail views, and generation results must come from a real server, so you do not end up with a shell that only works in a demo.

    Step 2: Connect a physical device for direct debugging and let the tools drive it

    Once device debugging mode is enabled and the device is connected over a data cable, AI coding tools can call terminal commands to operate the device directly. The key here is to establish a stable observe–act–observe loop:

    1. # Install the app to be replicated (illustrative)
    2. install_app ./target.apk
    3. # Launch a specific screen (illustrative)
    4. launch_app --package <package_name> --activity <main_screen>
    5. # Export the current UI control tree
    6. dump_ui --out ./snap/page_001.xml
    7. # Capture the current screen
    8. capture_screen --out ./snap/page_001.png

    Practical points:

    • Fix the device resolution and OS version to reduce comparison noise.
    • Collect a control tree and a screenshot immediately after each action, forming a traceable timeline.
    • Create a separate directory for each path so states do not contaminate one another.

    Step 3: Parse the semantic tree and screenshots through two channels

    Screenshots alone cannot give you precise coordinates and control types, while the control tree alone makes it hard to judge colors and visual hierarchy. Both channels must run in parallel:

    • Control tree channel: control type, text, clickability, bounding coordinates, and hierarchy.
    • Screenshot channel: primary and secondary colors, corner radius, font size hierarchy, spacing rhythm, and icon style.

    The alignment method uses control bounding coordinates as anchors, backfilling the visual attributes from the screenshot onto the corresponding controls to form a merged view of structure plus visuals.

    1. {
    2. "screen": "Home",
    3. "nodes": [
    4. {
    5. "id": "tab_generate",
    6. "type": "Button",
    7. "text": "Generate",
    8. "bounds": [48, 1520, 1032, 1640],
    9. "style": { "radius": 24, "fontSize": 30, "primaryColor": "#2B6CF0" }
    10. }
    11. ]
    12. }

    Step 4: Produce a specification checklist that turns observations into engineering input

    This step determines whether the project stays under control. It produces two core documents:

    (1) Per-screen UI diff table

    Screen Control Target behavior Current implementation Diff type Priority
    Home Primary action button Radius 24, primary color fill Radius 8 Visual High
    Projects Card list Waterfall layout, spacing 16 Single column Structural High

    (2) Behavior audit table

    Trigger action Precondition State transition Feedback Failure branch
    Tap Generate Model selected, reference image uploaded Enters task-in-progress Progress bar text Timeout message with retry
    Extend video A completed clip exists Adds duration and keeps the original New version added to the list Duration limit message

    The behavior audit table is the key to effect consistency. It constrains invisible server-side behavior into testable assertions.

    Step 5: Rebuild the native client and server, then run same-device acceptance

    • Native client: write pages with a declarative UI paradigm and centralize state management, avoiding coupling between UI and business logic.
    • Server: use a task queue to drive asynchronous generation, with a unified task state machine of queued–running–succeeded/failed, while retaining artifact ownership and version information.
    1. Client → submit task → task queue → generation executor
    2. ↑ ↓
    3. Poll/subscribe to status ← state store ← artifact object storage

    Acceptance must be done on the same device with a same-device comparison: same input, same operation sequence, checking each item against the UI diff table and the behavior audit table. If any item fails, go back to the corresponding step and fix it.

    4. Effect-Level Validation: Four Assertions to Test

    1. Real invocation: the generation path returns results from a real model service, not preset assets.
    2. Complete playback: the extended clip plays continuously end to end, with the expected duration.
    3. Multiple versions retained: each generation produces a new version, and historical versions are not lost.
    4. Source image ownership: editing results can be traced back to the source asset, with a clear provenance relationship.

    5. Cost Control: Breaking Down 7 Hours and 21 Yuan

    The low cost is not accidental; it is the result of process optimization:

    • Batch collection instead of repeated trial and error: traverse multiple screens in one pass to reduce device operation rounds.
    • Specifications first: produce the checklist before writing code to avoid large-scale rework.
    • Diff-table-driven changes: only modify items marked “High”.
    • Reuse common server capabilities: use general cloud service categories for generation and storage (such as object storage, message queues, container platforms, log services, and monitoring and alerting) instead of building infrastructure yourself.

    If you use an AI coding tool with agent capabilities, together with general cloud services on Baidu AI Cloud to host asynchronous tasks and artifact storage, you can further reduce the effort needed for environment setup and operations.

    6. Common Pitfalls and How to Avoid Them

    • Dynamic content causing misjudgment: turn off animations and recommendation feeds before parsing, and fix test account data.
    • Self-drawn controls missing from the control tree: fall back to screenshot coordinate positioning for nodes without semantics.
    • Residual state: clear app data before each validation round and rebuild the initial state.
    • Async timing mismatch: poll based on the state machine rather than relying on fixed delays.
    • Drifting acceptance criteria: every change must be written back to the diff table to keep documentation and implementation in sync.

    7. Suggested Structure for a Reusable Knowledge Pack

    Consolidate the method into a deliverable knowledge pack with four parts: the level definitions, collection and parsing scripts, specification checklist templates, and an acceptance test set. A new team member can pick it up and run the same process on a similar app, turning individual experience into team output.

    8. Conclusion

    Fast replication of a mobile app is essentially an engineering loop of observe → specify → rebuild → accept. Obtaining public information in a clean-room way, constraining the target with a level scale, reconstructing the UI through two-channel parsing, locking down effects with a behavior audit, and ensuring quality with same-device acceptance is what makes it possible to produce a maintainable and extensible similar product at very low cost, and to lay a solid foundation for later secondary development.