Back to Blog
January 4, 20267 min readTechnical Deep Dive:

Technical Deep Dive: How Replay AI generates the API calls for the UI from video

R
Replay Team
Developer Advocates

TL;DR: Replay AI reverse-engineers UI logic from video recordings by intelligently inferring user interactions and translating them into functional API calls, enabling rapid prototyping and code generation.

Technical Deep Dive: How Replay AI Generates API Calls for UI from Video#

The holy grail of UI development has always been bridging the gap between design and implementation. Traditional methods rely on static mockups and manual coding, leading to discrepancies and time-consuming iterations. Replay offers a revolutionary approach: behavior-driven reconstruction. Instead of relying on static images, Replay analyzes video recordings of user interactions and reconstructs the UI, complete with functional API calls. This article delves into the technical intricacies of how Replay achieves this feat.

The Problem with Screenshot-to-Code#

Screenshot-to-code tools offer a seemingly quick solution, but they are fundamentally limited. They treat the UI as a static image, failing to capture the underlying logic and dynamic behavior. This results in code that is visually similar but functionally incomplete, requiring significant manual effort to integrate with backend systems.

FeatureScreenshot-to-CodeReplay
InputStatic ImagesVideo Recordings
Behavior Analysis
API Call Generation
Dynamic UI Reconstruction
Understanding User Intent

Replay overcomes these limitations by analyzing video as the source of truth. This allows it to understand the user's intent and reconstruct the UI with functional API calls.

Behavior-Driven Reconstruction: The Replay Approach#

Replay's core innovation is its Behavior-Driven Reconstruction engine. This engine leverages Gemini to analyze video recordings, identify user interactions, and infer the corresponding API calls. The process involves several key steps:

  1. Video Segmentation and Feature Extraction: The video is segmented into individual frames, and features such as button clicks, form inputs, and page transitions are extracted.
  2. Interaction Recognition: The extracted features are analyzed to identify specific user interactions, such as clicking a button, entering text in a form, or navigating to a new page.
  3. Intent Inference: Replay uses a sophisticated intent inference engine to understand the user's goal. For example, if the user enters their email and password and clicks the "Login" button, Replay infers that the user is attempting to log in.
  4. API Call Generation: Based on the inferred intent, Replay generates the appropriate API calls. This involves identifying the relevant API endpoint, constructing the request body, and handling the response.
  5. UI Reconstruction: Finally, Replay reconstructs the UI, complete with the generated API calls. This results in a functional UI that accurately reflects the user's interactions in the video.

Diving Deeper: API Call Generation in Action#

Let's illustrate this process with a concrete example. Suppose a user records a video of themselves logging into a website. Here's how Replay would generate the API call:

Step 1: Video Analysis#

Replay analyzes the video and identifies the following interactions:

  • The user enters their email address in the email field.
  • The user enters their password in the password field.
  • The user clicks the "Login" button.

Step 2: Intent Inference#

Replay infers that the user is attempting to log in.

Step 3: API Call Generation#

Replay identifies the login API endpoint (e.g.,

text
/api/login
) and constructs the request body:

typescript
// Example API call generated by Replay const login = async (email: string, password: string) => { const response = await fetch('/api/login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email, password }), }); if (!response.ok) { throw new Error('Login failed'); } return await response.json(); };

💡 Pro Tip: Replay leverages metadata from the video, such as the website's domain and page structure, to improve the accuracy of API call generation.

Key Technologies Behind Replay's API Generation#

Replay's API call generation engine is powered by a combination of cutting-edge technologies:

  • Gemini: Gemini's powerful video understanding capabilities are used to analyze the video and extract relevant features.
  • Natural Language Processing (NLP): NLP techniques are used to understand the user's intent and identify the relevant API endpoint.
  • Machine Learning (ML): ML models are trained on a vast dataset of user interactions and API calls to improve the accuracy of API call generation.

Integrating with Supabase#

Replay seamlessly integrates with Supabase, a popular open-source Firebase alternative. This allows you to quickly connect your reconstructed UI to a backend database and authentication system.

Here's how you can integrate Replay with Supabase:

  1. Connect to Supabase: In the Replay interface, connect your project to your Supabase instance by providing your Supabase URL and API key.
  2. Define Data Models: Define the data models that correspond to your UI. For example, if your UI displays a list of products, you would define a
    text
    Product
    data model with fields such as
    text
    name
    ,
    text
    description
    , and
    text
    price
    .
  3. Generate API Calls: Replay automatically generates the API calls for interacting with your Supabase database. This includes API calls for creating, reading, updating, and deleting data.
typescript
// Example Supabase integration generated by Replay import { createClient } from '@supabase/supabase-js'; const supabaseUrl = 'YOUR_SUPABASE_URL'; const supabaseKey = 'YOUR_SUPABASE_ANON_KEY'; const supabase = createClient(supabaseUrl, supabaseKey); const getProducts = async () => { const { data: products, error } = await supabase .from('products') .select('*'); if (error) { console.error('Error fetching products:', error); return []; } return products; };

📝 Note: Replay automatically handles authentication and authorization when generating API calls for Supabase.

Style Injection#

Replay not only generates functional code but also preserves the visual style of the original UI. It achieves this through style injection, which involves extracting the CSS styles from the video and applying them to the reconstructed UI.

Product Flow Maps#

Replay automatically generates product flow maps, which provide a visual representation of the user's journey through the UI. This helps you understand how users interact with your product and identify areas for improvement.

FeatureDescriptionBenefit
Product Flow MapsVisual representation of user journeysUnderstand user behavior, identify drop-off points
Style InjectionPreserves original UI stylingFaster prototyping, consistent design
Supabase IntegrationSeamless backend connectivityRapid data integration, authentication

⚠️ Warning: While Replay strives to accurately reconstruct the UI, there may be minor discrepancies due to variations in screen resolution and browser rendering.

Benefits of Using Replay#

  • Rapid Prototyping: Quickly generate functional prototypes from video recordings.
  • Code Generation: Automate the process of writing UI code, saving time and effort.
  • Improved Collaboration: Easily share UI designs and prototypes with stakeholders.
  • Behavior-Driven Development: Develop UIs based on real user behavior.
  • Reduced Development Costs: Reduce the time and effort required to develop UIs.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited features. Paid plans are available for users who need access to more advanced features and higher usage limits.

How is Replay different from v0.dev?#

While both tools aim to accelerate UI development, they differ significantly in their approach. v0.dev relies on AI to generate UI code from text prompts, while Replay analyzes video recordings of user interactions to reconstruct the UI. Replay focuses on capturing real user behavior and translating it into functional code.

Can Replay handle complex UIs?#

Yes, Replay is designed to handle complex UIs with multiple pages and interactions. Its Behavior-Driven Reconstruction engine can analyze even the most intricate user flows.

What types of videos can Replay analyze?#

Replay can analyze any video recording of a UI, regardless of the platform or device used to create the recording. This includes videos of web applications, mobile applications, and desktop applications.

How accurate is Replay's API call generation?#

Replay's API call generation is highly accurate, thanks to its sophisticated intent inference engine and machine learning models. However, the accuracy may vary depending on the quality of the video recording and the complexity of the UI.


Ready to try behavior-driven code generation? Get started with Replay - transform any video into working code in seconds.

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free