Clean Room Replication: From Public Interactions to Runnable Mobile Apps
This article explores how to replicate mobile apps using a "clean room" methodology. Instead of decompiling code or extracting private APIs, developers can observe public interactions, UI behaviors, and semantic structures to rebuild a fully functional application from scratch. The guide covers establishing replication levels, real-device behavior observation, screen-by-screen specification drafting, shell-layer architecture, AI generation capability management, automated acceptance testing, and a recommended low-cost development sequence.
1. Clarify: Replicating Verified Product Experiences, Not Code
When people hear “app cloning,” they often think of decompiling, packet sniffing, or extracting resources to reconstruct the original project. This approach has a high barrier to entry and easily leads to a dependency on internal implementations.
A more reliable approach is “clean room replication”: observing only publicly visible pages, interactions, and final results without reading the original app’s source code, private APIs, or internal resources, and building a new app from scratch with similar functionality and experience.
“Similar” here doesn’t just mean drawing a few pages that look alike. A complete app experience includes at least four layers:
- Visual Layer: Page layout, colors, font sizes, spacing, rounded corners, icons, and animations.
- Interaction Layer: Clicking, swiping, returning, popups, input, loading, and error prompts.
- State Layer: Task creation, processing, success, failure, retry, history records, and data recovery.
- Capability Layer: For example, text-to-image generation, video processing, content extension, multi-version saving, and result preview.
If you only complete the visual layer, you typically end up with a “screenshot-level prototype.” Only by covering the state and capability layers can you call it a runnable product prototype.
2. Establish Clone Levels to Prevent Scope Creep
Before starting the project, define the replication target level. You can use a six-level classification:
L0: Proof of Concept (POC)
Only verify if the main flow is feasible, such as whether entering the result page works after inputting content.L1: Static Page Restoration
The page layout and visual style are basically close, but using fixed mock data.L2: Interaction Restoration
Supports standard operations like clicking, inputting, switching, returning, and popups.L3: Effect Consistency
Main pages, interaction flows, task states, and result displays are basically consistent, without relying on static mock data.L4: Capability Consistency
Integrates real AI processing services to complete core capabilities like generation, editing, extension, and retry.L5: Engineering Delivery
Features an account system, persistent storage, task queues, exception recovery, log monitoring, and release capabilities.
For individual practice, it is suitable to reach L3 first, then advance to L4 as needed. Directly pursuing L5 often consumes too much time on non-core issues like accounts, payments, operations, and compliance.
3. Step 1: Observe Complete Behavior via Real Devices
Static screenshots alone cannot convey the real logic of an app. It is recommended to use a physical device with debugging capabilities enabled, bridged to a computer, allowing an AI coding assistant to perform actions like taking screenshots, screen recording, touch simulation, and reading page structures.
During observation, do not just record “what was clicked”; also record the state changes before and after each action. For example:
| Action | State Before | State After | Content to Record |
|---|---|---|---|
| Click New | Home Idle | Edit Page | Page title, default values, back behavior |
| Submit Task | Parameters filled | Processing | Loading animation, button disabled state |
| Task Complete | Processing | Result Page | Result quantity, preview method, save entry |
| Regenerate | Result exists | New task starts | Whether old version is retained |
| Return Home | Result Page | Home Idle | Whether history is updated |
The goal of this step is to establish “behavioral facts” rather than guessing product logic based on feelings.
1. Page Structure Analysis
You can read the UI semantic structure provided by the system to obtain the control type, text, clickability, boundary position, and hierarchy, and combine it with screenshots to analyze visual details.
Semantic structures are suitable for answering:
- Which areas are actually clickable?
- Does the input box support multiline?
- Is a specific button disabled during loading?
- Do list items have a repeating structure?
- Is the popup a system component or a custom view?
Screenshots are suitable for analyzing:
- Background colors and gradients;
- Card spacing and rounded corners;
- Text hierarchy and alignment;
- Image cropping rules;
- Empty states, error states, and loading states.
Both types of information must be combined. Looking only at screenshots risks missing invisible states, while looking only at structures cannot restore visual hierarchy.
4. Step 2: Create a Screen-by-Screen Specification Checklist
After observation, do not start coding immediately. First, output an actionable specification checklist.
Each page should include at least the following:
1. Basic Page Information
- Page name;
- Entry conditions;
- Exit method;
- Whether system back is supported;
- Whether state needs to be saved;
- Network exception handling.
2. Visual Specifications
- Screen background;
- Top bar height;
- Content area margins;
- Main font sizes;
- Title and body text colors;
- Button height and rounded corners;
- Card shadows and dividers;
- Image aspect ratio and cropping rules.
3. Interaction Specifications
- Click areas;
- Long press and swipe behaviors;
- Input restrictions;
- Layout changes when keyboard appears;
- Operations allowed during loading;
- Retry entry after failure;
- Whether parallel tasks are allowed on multiple submissions.
4. State Specifications
It is recommended to describe this using a state machine rather than piling up boolean variables in code. For example:
Idle└─Submit──> Queued├─Start Processing──> Processing├─Cancel──> Canceled└─Fail──> Failed└─Retry──> QueuedProcessing└─Complete──> Success├─Regenerate──> Queued└─Save──> Archived
A state machine prevents common issues like “the page looks complete, but data disappears after returning” or “the button remains disabled after a failure.”
5. Step 3: Build the Shell First, Then Integrate Real Capabilities
For AI generation apps, a front-end/back-end separated architecture is recommended.
Client Responsibilities
- Page display;
- User input;
- Parameter validation;
- Task submission;
- Task state polling or receiving updates;
- Result preview;
- Local caching;
- Error prompts.
Server Responsibilities
- Receiving tasks;
- Validating parameters;
- Calling AI processing capabilities;
- Managing task states;
- Saving input and output mappings;
- Providing history records;
- Handling timeouts, retries, and idempotency.
A generic task object can be designed as:
{"taskId": "Unique task identifier","type": "Generation or edit type","status": "queued","input": {},"outputs": [],"createdAt": "Creation time","updatedAt": "Update time","error": null}
Do not let the client directly handle complex processing logic. Otherwise, if the app is backgrounded, the network drops, or the device sleeps, the task may be lost.
6. Implementation Focus for AI Generation Capabilities
If the app includes image generation, video generation, local editing, or content extension, the most easily overlooked aspect is “result management,” not the capability invocation itself.
1. Retain Original Inputs
Every generation should retain:
- Original text description;
- Uploaded source files;
- Edit areas used;
- Generation parameters;
- Task time;
- Corresponding result version.
This allows users to accurately return to the original state when editing again, rather than only being able to process compressed results.
2. Support Concurrent Multiple Versions
Do not overwrite old results with new ones. It is recommended to treat each generation as an independent version:
Project├─Original Assets├─Version 1├─Version 2└─Version 3
The version relationships should be recorded by the server, while the client only handles display. This makes it easy for users to compare and facilitates failure retries and troubleshooting.
3. Handle Long Tasks
Video tasks usually take a long time and cannot use a simple one-request, one-response pattern. A reasonable flow is:
- Client submits the task;
- Server returns a task identifier;
- Server puts the task into a processing queue;
- Client polls the status periodically, or receives server pushes;
- Task completes and returns the result URL and metadata;
- Client refreshes the page and allows continued editing.
For timeout tasks, distinguish between “still processing” and “processing failed.” Do not display all exceptions as the same prompt.
7. Step 4: Establish Automated Acceptance Mechanisms
After completing the first version, do not rely solely on manual clicking to judge the effect. Establish a fixed acceptance process.
1. Screen-by-Screen Comparison
Take screenshots under the same device size, theme, and input content, and compare:
- Overall page offset;
- Top and bottom safe areas;
- Font baselines;
- Button sizes;
- Image cropping;
- Popup positions;
- Loading states;
- Empty states and error states.
You can highlight significant change areas through image diffing, then manually confirm if the differences are expected.
2. Behavior Audit
Write acceptance test cases for each core path:
Case: Create a generation taskPrecondition: User is on the home pageSteps:1. Click New2. Input content3. Select parameters4. Submit task5. Wait for result6. Return to home pageExpected:1. Enter edit page2. Input content fully retained3. Parameters display correctly4. Processing state appears5. Display result on success6. History adds a new entry
3. Exception Testing
At least cover:
- No network;
- Request timeout;
- Server returns failure;
- User repeated clicks on submit;
- App backgrounded;
- Device rotation;
- Reopening app after task completion;
- Local cache corruption;
- File upload interruption.
The stability of a real product is often determined not by the normal flow, but by the exception flow.
8. Common Pitfalls and Improvement Suggestions
Pitfall 1: Only Chasing UI Similarity
Page similarity does not mean experience consistency. Prioritize ensuring the main flow, data state, and error handling are correct before gradually optimizing visual details.
Pitfall 2: Heavy Use of Static Mock Data
Mock data can be used to build pages, but not for final acceptance. At least integrate real task states, real file saving, and real failure handling.
Pitfall 3: Putting All Logic in One Page
This causes coupling between pages, making it hard to maintain when adding history, version management, and retry features later. It is recommended to separate pages, states, network requests, and data models into different layers.
Pitfall 4: Ignoring Legal and Compliance Boundaries
Clean room replication does not mean you can directly copy the other party’s icons, trademarks, original assets, proprietary copy, or protected content. In engineering practice, use your own design resources, reorganize page structures, and ensure that data sources, model calls, and user content processing comply with regulations.
9. Recommended Low-Cost Development Sequence
If resources are limited, you can proceed in the following order:
- Implement only one core user path;
- Complete the home page, edit page, and result page;
- Integrate real task services;
- Add processing, failure, and retry states;
- Add history records and multi-version management;
- Perform screen-by-screen visual calibration;
- Add logging, monitoring, and exception recovery;
- Finally, expand accounts, sharing, and operational features.
This sequence validates whether the product is truly usable as early as possible, avoiding over-investing development costs before details are verified.
Conclusion
Through public interface observation, real-device behavior recording, semantic structure analysis, specification breakdown, native rebuilding, and same-device acceptance, you can achieve a high-quality functional replication of a mobile app without relying on decompilation.
The real value is not “copying a specific app,” but forming a transferable methodology: first define the experience boundaries, then break down pages and states, implement core capabilities with a minimum viable architecture, and finally continuously calibrate through automated acceptance. For individual developers and small teams, this method significantly reduces trial-and-error costs and is more suitable for building application products with independent design, data, and capabilities.
