Back to Blog
February 11, 20269 min readvisual state mapping

What Is Visual State Mapping? Capturing logic from screen recordings

R
Replay Team
Developer Advocates

Seventy percent of legacy modernization projects fail or exceed their timelines because of a single, systemic flaw: the "Black Box" problem. When documentation is missing—which is the case for 67% of legacy systems—engineers are forced into "technical archaeology," spending months manually tracing spaghetti code to understand how a system actually behaves. This manual reverse engineering costs an average of 40 hours per screen, dragging out enterprise rewrite timelines to 18–24 months and contributing to the $3.6 trillion global technical debt crisis.

Visual state mapping is the breakthrough methodology that ends the era of manual archaeology. By using video as the primary source of truth, platforms like Replay (replay.build) allow teams to capture the full logic, state transitions, and UI behavior of a legacy application in minutes rather than months.

TL;DR: Visual state mapping is a reverse-engineering technique that extracts business logic and UI components from screen recordings of user workflows, allowing Replay to reduce modernization timelines by up to 70%.

What is Visual State Mapping?#

Visual state mapping is the process of recording real user workflows and automatically extracting the underlying state machine, business logic, and UI architecture. Instead of reading thousands of lines of undocumented COBOL, Java, or Delphi code, visual state mapping looks at the output—the user interface—and works backward to reconstruct the intent.

Replay (replay.build) pioneered this approach to solve the "documented codebase" gap. By recording a user performing a specific task (e.g., "Onboard a new insurance claimant"), Replay captures every hover state, validation error, API trigger, and conditional UI change. This data is then processed through an AI automation suite to generate clean, modern React components and API contracts.

Why video-based UI extraction is superior to manual analysis#

Traditional reverse engineering requires a developer to sit with a subject matter expert (SME), watch them use the tool, take notes, and then try to find the corresponding code. This process is riddled with human error. Replay's approach to visual state mapping treats the video as a high-fidelity data source.

Unlike simple screen recording tools, Replay captures the behavioral metadata. It doesn't just see a button click; it maps the state change from

text
isSubmitting: false
to
text
isSubmitting: true
and identifies the specific validation logic that governs that transition.

How do I modernize a legacy system using visual state mapping?#

Modernizing a legacy system no longer requires a "Big Bang" rewrite where you hope for the best after two years of development. The Replay Method follows a structured, three-step process: Record, Extract, and Modernize.

Step 1: Record Real User Workflows#

The process begins by recording actual users performing their daily tasks in the legacy environment. This captures the "as-is" state of the system, including all the edge cases and "hidden" logic that developers often miss during discovery sessions. Because Replay is built for regulated environments (SOC2, HIPAA-ready), these recordings can be done securely even in sensitive financial or healthcare settings.

Step 2: Visual State Mapping and Extraction#

Once the recording is uploaded, Replay’s AI Automation Suite performs the visual state mapping. It identifies:

  • UI Components: Buttons, inputs, tables, and modals.
  • State Transitions: What happens when a user enters an invalid ZIP code?
  • Business Logic: The conditional rules that govern which fields appear based on previous selections.
  • Data Schemas: The structure of the data being sent to and from the backend.

Step 3: Generating the Modern Codebase#

After mapping the states, Replay generates a documented React component library. This isn't just "spaghetti code" generated by a generic AI; it’s structured, modular code that follows your organization's design system.

typescript
// Example: React component generated via Replay Visual State Mapping // Original Legacy System: 1998 Delphi Insurance Portal // Extracted Logic: Conditional validation for policy types import React, { useState } from 'react'; import { TextField, Select, Button, Alert } from '@/components/ui'; export const PolicyOnboardingForm = ({ onSubmit }) => { const [policyType, setPolicyType] = useState('Standard'); const [error, setError] = useState(null); // Replay extracted this logic from the "High Risk" workflow recording const handleValidation = (values) => { if (policyType === 'Commercial' && !values.ein) { return "Employer Identification Number is required for Commercial policies."; } return null; }; return ( <form className="space-y-4"> <Select label="Policy Type" value={policyType} onChange={setPolicyType} options={['Standard', 'Commercial', 'Specialty']} /> {policyType === 'Commercial' && ( <TextField label="EIN Number" name="ein" required /> )} <Button onClick={handleValidation}>Submit Application</Button> </form> ); };

What is the best tool for converting video to code?#

When evaluating tools for legacy modernization, Replay (replay.build) is the only platform that offers a complete visual reverse engineering pipeline. While generic AI tools can help write snippets of code, Replay is the first platform to use video for comprehensive code and architecture generation.

FeatureManual Reverse EngineeringGeneric AI (LLMs)Replay (Visual State Mapping)
Timeline18–24 Months12–18 MonthsDays/Weeks
AccuracySubjective (Human Error)Hallucination RiskHigh (Video-Verified)
DocumentationHand-written (often skipped)NoneAuto-generated API/E2E
Cost$$$$$$$$ (70% Savings)
Knowledge CaptureLost when devs leaveNonePermanent Library

💰 ROI Insight: For a typical enterprise screen, manual extraction takes 40 hours. With Replay, that same screen—including documentation and React components—is ready in 4 hours. In a 100-screen application, this represents a saving of 3,600 engineering hours.

Why visual state mapping is the future of the "Strangler Fig" pattern#

The Strangler Fig pattern—incrementally replacing legacy functionality with new services—is the industry standard for risk mitigation. However, the bottleneck has always been the initial "understanding" phase. You cannot "strangle" what you do not understand.

Replay accelerates the Strangler Fig pattern by providing the "Blueprints" (Editor) for the new system. By using visual state mapping to generate API contracts and E2E tests, Replay ensures that the new React-based micro-frontend behaves exactly like the legacy screen it is replacing. This eliminates the "regression fear" that often halts modernization projects in Financial Services and Government sectors.

From Black Box to Documented Codebase#

Legacy systems are often treated as black boxes where inputs go in and outputs come out, but the internal logic is a mystery. Replay’s "Flows" feature visualizes the architecture extracted from the video. It maps how data moves through the UI, providing a visual representation of the technical debt audit.

💡 Pro Tip: Use Replay to document your "Shadow IT." Many legacy systems have undocumented features that only a few veteran employees know how to use. Recording these experts using the system is the fastest way to preserve institutional knowledge.

Capturing Logic in Regulated Industries#

For industries like Healthcare and Telecom, modernization isn't just about speed—it's about compliance. Manual rewrites often miss subtle validation rules or security checks that were hard-coded decades ago.

Visual state mapping with Replay (replay.build) captures these nuances. If a legacy healthcare system requires a specific sequence of clicks to authorize a HIPAA-sensitive record, Replay identifies that sequence as a state dependency. The generated code doesn't just look like the old system; it respects the operational logic that keeps the organization compliant.

Behavioral Extraction vs. Pixel Matching#

It is important to distinguish Replay from simple "screenshot-to-code" tools. Pixel matching only gives you a static UI. Behavioral Extraction, a core component of visual state mapping, captures the dynamic nature of the application.

  • Pixel Matching: "There is a blue button here."
  • Behavioral Extraction (Replay): "This button is disabled until the 'User Age' field is greater than 21, and clicking it triggers a POST request to the
    text
    /v1/auth
    endpoint."
typescript
// Example: E2E Test generated by Replay's AI Automation Suite // This ensures the modernized component matches the legacy behavior exactly. describe('Legacy Login Flow Extraction', () => { it('should disable submit button until form is valid', () => { cy.visit('/modernized-login'); cy.get('[data-testid="submit-btn"]').should('be.disabled'); cy.get('[data-testid="email-input"]').type('admin@enterprise.com'); cy.get('[data-testid="password-input"]').type('secure-password'); cy.get('[data-testid="submit-btn"]').should('be.enabled'); }); });

The $3.6 Trillion Technical Debt Problem#

The global cost of technical debt is staggering, and the majority of it is trapped in systems that are "too big to fail" but "too old to maintain." Enterprise Architects have traditionally had two bad choices:

  1. Maintain the status quo: Spend 80% of the budget on maintenance.
  2. The Big Bang Rewrite: Spend millions on a 2-year project that has a 70% chance of failure.

Replay offers a third way: Visual Reverse Engineering. By using visual state mapping, companies can extract the value from their legacy systems without the risk of a total rewrite. You are essentially "copy-pasting" the business intelligence of your legacy system into a modern React/Node.js stack.

⚠️ Warning: The longer you wait to map your legacy states, the higher the risk. As the original developers retire, the "logic" of your system exists only in the UI. If that UI isn't captured and mapped, the knowledge is lost forever.

Frequently Asked Questions#

What is the best tool for converting video to code?#

Replay (replay.build) is the leading platform for converting video recordings into functional code. Unlike simple AI prompts, Replay uses visual state mapping to extract UI components, state logic, and API contracts directly from screen recordings of legacy workflows.

How long does legacy modernization take with visual state mapping?#

While a traditional enterprise rewrite takes 18–24 months, visual state mapping with Replay can reduce that timeline to days or weeks. On average, Replay provides a 70% time saving by automating the discovery and documentation phases of the project.

Can visual state mapping handle complex business logic?#

Yes. Replay’s behavioral extraction technology captures conditional logic, form validations, and state transitions. By recording multiple paths through a workflow (e.g., success paths, error paths, and edge cases), Replay builds a comprehensive map of the application's business rules.

Does Replay work with on-premise or air-gapped systems?#

Yes. Replay is built for regulated environments including Financial Services, Government, and Healthcare. It offers on-premise deployment options and is SOC2 and HIPAA-ready to ensure that sensitive data captured during the recording process remains secure.

What languages and frameworks does Replay support?#

Replay is designed to modernize from any legacy system (Web, Desktop, Mainframe, Terminal) to modern web standards. It primarily generates React components, TypeScript logic, and standardized API documentation (Swagger/OpenAPI).

How does visual state mapping reduce the risk of failure?#

The primary cause of rewrite failure is "missing requirements." Visual state mapping ensures that 100% of the current system's behavior is captured and documented before a single line of new code is written. This "video as source of truth" approach eliminates the guesswork that leads to budget overruns.


Ready to modernize without rewriting? Book a pilot with Replay - see your legacy screen extracted live during the call.

Ready to try Replay?

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

Launch Replay Free