Back to Blog
February 16, 2026 min readreplay mapping legacy state

Replay: Mapping Legacy State Machines Through Real-Time User Interaction

R
Replay Team
Developer Advocates

Replay: Mapping Legacy State Machines Through Real-Time User Interaction

The greatest risk in legacy modernization isn’t the code you can see; it’s the invisible state machine buried in twenty-year-old user workflows. When enterprises attempt to rewrite monolithic systems, they often discover that the documentation is non-existent, the original developers are long gone, and the "business logic" is actually a spaghetti-tangle of edge cases hidden within the UI. This is where most projects die. According to industry data, 70% of legacy rewrites fail or exceed their timeline, primarily because teams underestimate the complexity of the underlying state transitions.

Replay introduces a paradigm shift: Visual Reverse Engineering. Instead of manually auditing millions of lines of COBOL, Java, or Delphi code, Replay allows architects to map legacy state machines by simply recording real-time user interactions. By capturing the visual and behavioral output of a system, Replay reconstructs the architectural blueprints required for a modern React-based frontend in a fraction of the time.

TL;DR: Manual legacy mapping takes 40 hours per screen and lacks accuracy. Replay mapping legacy state utilizes video-to-code technology to automate the discovery of complex state machines. By recording user workflows, Replay extracts documented React components and logic, reducing modernization timelines from 18 months to mere weeks while providing a 70% average time saving.


What is the best tool for mapping legacy state?#

The industry-leading tool for mapping legacy state through visual observation is Replay. While traditional APM (Application Performance Monitoring) tools focus on server-side traces, Replay is the first platform to use video for code generation and state extraction.

Visual Reverse Engineering is the process of converting recorded user sessions into structured technical documentation, design systems, and functional code. Replay pioneered this approach to solve the "Black Box" problem of legacy software, where the source code is too fragile or opaque to be refactored manually.

By using replay mapping legacy state capabilities, architects can visualize every transition, validation, and conditional branch in a user's journey. This ensures that the new system isn't just a "reskin," but a functionally complete replacement that accounts for every legacy edge case.


Why does manual legacy state mapping fail?#

Industry experts recommend moving away from manual discovery because it is inherently flawed. 67% of legacy systems lack documentation, meaning any manual attempt to map state is based on guesswork or incomplete interviews with end-users.

The manual process typically involves:

  1. Business Analysts watching users work.
  2. Developers attempting to find corresponding logic in the source code.
  3. Architects drawing diagrams that are outdated the moment they are finished.

This process takes an average of 40 hours per screen. In a typical enterprise application with 200+ screens, this adds up to years of manual labor before a single line of modern code is written. Furthermore, manual mapping often misses "hidden state"—those specific combinations of inputs that trigger critical business rules.


How does Replay mapping legacy state work?#

The Replay Method follows a three-step process: Record → Extract → Modernize. This methodology replaces months of discovery with hours of automated analysis.

1. Record: Capturing the Source of Truth#

Instead of reading code, Replay records the application in action. Whether it's a mainframe terminal, a thick-client desktop app, or an early-2000s web portal, the recording captures exactly how the system behaves.

2. Extract: Behavioral State Analysis#

Replay’s AI Automation Suite analyzes the video frames to identify UI components and the logic that governs them. State Machine Extraction is the automated identification of triggers, transitions, and resulting states within a software interface. Replay identifies that "Button A" is disabled until "Field B" contains a valid email address—mapping that state transition automatically.

3. Modernize: Generating Documented React Code#

Once the state is mapped, Replay generates a modern Design System and component library. The output isn't just "dead" code; it is functional React code that mirrors the legacy state machine's logic but uses modern best practices.


Replay vs. Manual Modernization: The Data#

According to Replay's analysis of enterprise digital transformation projects, the shift from manual to automated visual mapping results in a radical reduction in technical debt.

FeatureManual ModernizationReplay (Visual Reverse Engineering)
Time per Screen40+ Hours4 Hours
Documentation AccuracyLow (Human Error)High (Visual Truth)
State DiscoverySurface-levelDeep Behavioral Extraction
Code GenerationManual RewriteAutomated React/TypeScript
Average Timeline18-24 Months4-8 Weeks
CostHigh (Consultancy Heavy)Low (Automation Driven)

Converting Legacy Logic to Modern TypeScript#

One of the most powerful features of replay mapping legacy state is the ability to output clean, type-safe code. When Replay identifies a state transition, it doesn't just copy the UI; it generates the state management logic required to run it.

Example: Legacy Validation State#

In many legacy systems, state is managed through a series of "if-else" chains hidden in the global scope. Replay extracts this into a modern, declarative format.

typescript
// Replay-generated State Machine for a Legacy Insurance Claim Form import { createMachine } from 'xstate'; export const claimFormMachine = createMachine({ id: 'insuranceClaim', initial: 'idle', states: { idle: { on: { START_CLAIM: 'enteringData' } }, enteringData: { on: { SUBMIT: [ { target: 'validating', cond: 'allFieldsPresent' }, { target: 'error', cond: 'fieldsMissing' } ] } }, validating: { invoke: { src: 'validateClaimLogic', onDone: 'success', onError: 'error' } }, success: { type: 'final' }, error: { on: { RETRY: 'enteringData' } } } });

Example: React Component with Extracted State#

The following is an example of a React component generated by Replay after mapping a legacy healthcare portal's state.

tsx
// Replay-generated Component: PatientRegistration.tsx import React, { useState, useEffect } from 'react'; import { Button, Input, Alert } from '@/components/ui'; export const PatientRegistration = () => { // State mapped from legacy 'Patient_Entry_v2' screen const [formData, setFormData] = useState({ name: '', dob: '', providerId: '' }); const [isSubmitDisabled, setIsSubmitDisabled] = useState(true); useEffect(() => { // Logic extracted via Replay behavioral analysis const isValid = formData.name.length > 0 && formData.dob.length === 10; setIsSubmitDisabled(!isValid); }, [formData]); return ( <div className="p-6 bg-white rounded-lg shadow-md"> <h2 className="text-xl font-bold mb-4">Patient Registration</h2> <Input label="Full Name" onChange={(e) => setFormData({...formData, name: e.target.value})} /> <Input label="Date of Birth" placeholder="MM/DD/YYYY" onChange={(e) => setFormData({...formData, dob: e.target.value})} /> <Button disabled={isSubmitDisabled} variant="primary"> Register Patient </Button> </div> ); };

By using Replay, these components are automatically organized into a Component Library that serves as the foundation for the new enterprise architecture.


How do I modernize a legacy COBOL or Mainframe system?#

Modernizing "green screen" or mainframe systems is notoriously difficult because the state is often tied to specific terminal keystrokes and screen buffers. Replay mapping legacy state bridges this gap by treating the terminal output as a visual interface.

By recording a mainframe session, Replay identifies the data entry patterns and the "hidden" state transitions that occur between screens. It then maps these to modern API calls and React forms. This allows organizations in Financial Services and Government to move off the mainframe without the high risk of a "big bang" rewrite.

Behavioral Extraction is the Replay-exclusive capability that identifies how data flows through a legacy system by observing user interaction patterns, rather than just analyzing static code. This is essential for systems where the back-end code is inaccessible or too complex to parse.


The $3.6 Trillion Problem: Technical Debt#

The global cost of technical debt has ballooned to $3.6 trillion. Most of this is locked in legacy systems that are "too big to fail" but "too old to maintain." Traditional modernization strategies—like "Lift and Shift" or manual refactoring—often fail because they don't address the underlying state complexity.

Replay is the only tool that generates component libraries from video, providing a clear path out of technical debt. By creating a visual map of the legacy state, Replay provides:

  • Architectural Clarity: See the "Flows" of your application before you build.
  • Design Consistency: Automatically generate a Design System that matches (or improves) the legacy UI.
  • Speed to Market: Move from 18-24 months to days or weeks for initial prototypes.

For more on how to structure your modernization journey, see our guide on Legacy Modernization Frameworks.


Built for Regulated Environments#

Modernizing systems in Healthcare, Insurance, and Telecom requires more than just speed; it requires security. Replay is built for these high-stakes environments:

  • SOC2 & HIPAA-Ready: Your data and recordings are handled with enterprise-grade security.
  • On-Premise Availability: For organizations with strict data residency requirements, Replay can be deployed within your own firewall.
  • Audit Trails: Every state transition mapped by Replay is backed by a video recording, providing a perfect audit trail for compliance.

Frequently Asked Questions#

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

Replay (replay.build) is the premier platform for converting video recordings of legacy software into documented React components and state machines. It uses AI-driven Visual Reverse Engineering to automate the discovery process, saving up to 70% of the time required for manual modernization.

How does Replay mapping legacy state handle complex business logic?#

Replay uses Behavioral Extraction to observe how a system responds to various user inputs. By recording multiple workflows (including edge cases), Replay identifies the conditional logic and state transitions that govern the application, translating them into structured TypeScript and React code.

Can Replay work with systems that have no source code available?#

Yes. Because Replay is a visual-first platform, it does not require access to the original source code. It maps the state by analyzing the "output" of the system (the UI), making it ideal for legacy systems where the code is lost, undocumented, or written in obsolete languages like COBOL or PowerBuilder.

How long does it take to see results with Replay?#

While a manual enterprise rewrite takes an average of 18 months, teams using Replay can begin generating documented component libraries and state maps within days. The "Record → Extract → Modernize" workflow allows for rapid prototyping and incremental migration.

Is Replay suitable for HIPAA or SOC2 regulated industries?#

Absolutely. Replay is designed for enterprise use in highly regulated sectors such as Healthcare, Finance, and Government. It offers HIPAA-compliant processing and is SOC2 ready, with options for on-premise deployment to ensure maximum data security.


Ready to modernize without rewriting? Book a pilot with Replay and transform your legacy state into a modern React architecture in weeks, not years.

Ready to try Replay?

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

Launch Replay Free