Skip to content

    Frontend System Design

    Large-Scale Migration and Modernization

    Plan a front-end migration that ships while it runs: a routing facade, slices, parallel change, codemods, a stable ramp, rollback and a date to delete old code.

    By Published 13 min read

    • frontend-system-design
    • migration
    • modernization
    • strangler-fig
    • codemods
    Share

    Standard lessonadvancedFrontend System Design

    Before this: Enterprise Frontend Architecture, Micro-Frontend Anti-Patterns and Migration From a Monolith

    What you'll learn: By the end of this lesson you will be able to explain why a front-end rewrite is usually done as a sequence of small, reversible steps, choose slices by user journey rather than by component, put a routing facade in front of two stacks, change a shared component's API with expand, migrate and contract, use codemods and deprecation warnings to move code in bulk, ramp traffic to a migrated slice with a stable per-user bucket, track progress, and plan the day the old code is deleted.

    Think of replacing the plumbing in an apartment block where people live. You cannot shut the building for a year. You replace one riser at a time, put a temporary connection between old and new pipes, test that floor, move the tenants' taps over, and only then cut out the old pipe. The hardest part is not the new pipe: it is the temporary connection, and remembering to remove it. A large front end is that building. Teams ship into it every week while you change its framework, its build or its structure.

    The running example is the customer dashboard of an online shop: a product page, an orders area, a help centre and an account area, in one old single-page application with about forty routes and several teams. Every number below is illustrative. This lesson uses the strangler fig and parallel change as working definitions and spends its time on what is specific to a browser. The micro-frontend side of the same move is in Micro-Frontend Anti-Patterns and Migration From a Monolith; the back-end version is Strangler Fig Migration. This lesson builds on the planned lesson on enterprise front-end architecture, named here in plain text because it has no page yet.

    The core idea

    1. A migration is a long period of coexistence, not an event. Martin Fowler writes that the simple-sounding plan of building a replacement that does what the old system does has "gone down in flames most of the time". The old and the new run side by side, so the design of the join matters more than the design of either side.
    2. Every step must be small and reversible. Fowler says that early small pieces carry less risk and bring value to the business sooner. Reversible means a flag or a routing change brings the old behaviour back without a redeploy of code that took weeks to write.
    3. The finish line is deletion. Fowler calls the code that lets old and new coexist "code that will go away once the modernization is complete". If nobody owns the deletion, you keep both systems and pay for both.

    Choosing a strategy

    The four approaches below are not exclusive: most real programmes mix them.

    Strategy Idea Fits when Main risk
    Big-bang rewrite Build the new app, switch once Small app, freeze acceptable Feature drift; one risky cutover
    Strangler fig by route A facade sends each path to old or new Routes are independent journeys A long period of two stacks and visible seams
    In-place upgrade Keep one codebase, raise versions and patterns together The framework offers an upgrade path and codemods Large pull requests that block every team
    Parallel change on a shared API Expand, migrate, contract A shared component or function has many callers The contract step never happens

    Figure 1. Choosing how to migrate

    flowchart TD accTitle: Choosing a front-end migration strategy accDescr: A decision tree. If the app is small and a freeze is acceptable, a rewrite may be fine. Otherwise, if the framework offers an in-place upgrade path with codemods, upgrade in place. If the change crosses framework or routing boundaries, put a facade in front and migrate slice by slice. Shared component or function changes inside any path use expand, migrate and contract. A{"Small app, freeze
    acceptable?"} A -->|"yes"| R["Rewrite, then cut over"] A -->|"no"| B{"Upgrade path
    and codemods exist?"} B -->|"yes"| U["Upgrade in place,
    in small steps"] B -->|"no"| S["Facade plus slices
    (strangler fig)"] U --> P["Shared API change:
    expand, migrate, contract"] S --> P

    How to read this: the question is how big the unit of risk is. The rewrite makes it the whole app; the others shrink it to a version step or a slice, and the last box applies inside whichever path you chose.

    Microsoft's Azure Architecture Center says the strangler fig may not suit a system when requests cannot be intercepted, when you cannot change the legacy system, when the system is small enough to replace whole, or when you must retire the original quickly. For a browser app, interception means a CDN, edge function or reverse proxy in front of the app, or a router inside a shell, sending each URL to a different build.

    The routing facade

    Microsoft describes the pattern's first step as a facade between the client, the old system and the new one, initially routing most requests to the old system and then shifting more to the new one as migration progresses. For a front end the facade is a route table:

    Figure 2. One facade, two stacks, shared contracts

    A routing facade in front of a legacy app and a new appVisitor to Routing facade; Routing facade to Legacy app (most paths); Routing facade to New app (migrated paths); Legacy app to Shared contracts; New app to Shared contractsVisitor: browserVisitorbrowserRouting facade: route table, flagsRouting facaderoute table,flagsLegacy app: unmigrated routesLegacy appunmigrated routesNew app: migrated slicesNew appmigrated slicesShared contracts: session, APIsSharedcontractssession, APIsmost pathsmigrated paths

    How to read this: the facade is the only place that knows which stack serves a path. Both stacks use the same session, design tokens and APIs, which is what keeps the seam invisible. Microsoft's caution applies: the facade must not become a single point of failure or a performance bottleneck.

    Two properties make a facade work for a user (both judgement). Stable URLs: the address does not change when a slice moves. Stable identity: the session cookie, stored preferences and analytics ids mean the same thing in both stacks. Microsoft's guidance is to plan for cross-system dependencies and for resources both systems use at the same time.

    Illustration 1: the minimal example

    A route table and a stable per-user bucket. The bucket makes a user's answer repeatable, so ramping a slice from 25 to 50 per cent only adds users. Run in Node (v26.13.1):

    const routes = [
      { prefix: "/help", stack: "new", ramp: 100 },
      { prefix: "/orders", stack: "new", ramp: 25 },
      { prefix: "/", stack: "legacy", ramp: 0 },
    ];
    
    function bucket(userId) {
      let h = 2166136261;
      for (const ch of userId) {
        h ^= ch.charCodeAt(0);
        h = Math.imul(h, 16777619) >>> 0;
      }
      return h % 100;
    }
    
    function serve(path, userId, table = routes) {
      const rule = table.find((r) => path.startsWith(r.prefix));
      if (rule.stack === "legacy") return "legacy";
      return bucket(userId) < rule.ramp ? "new" : "legacy";
    }
    
    for (const [path, user] of [["/help/returns", "ana"], ["/orders/42", "ana"], ["/orders/42", "ben"], ["/orders/42", "chen"], ["/orders/42", "dev"], ["/orders/42", "ana"], ["/cart", "dev"]]) {
      console.log(path.padEnd(14), user, "->", serve(path, user));
    }
    
    for (const ramp of [0, 10, 25, 50, 100]) {
      const table = [{ prefix: "/orders", stack: "new", ramp }, { prefix: "/", stack: "legacy", ramp: 0 }];
      let inNew = 0;
      for (let i = 0; i < 1000; i++) if (serve("/orders/1", `user-${i}`, table) === "new") inNew++;
      console.log(`ramp=${String(ramp).padStart(3)}  users in new stack: ${inNew} of 1000`);
    }

    Output, from running it in Node 26.13.1:

    /help/returns  ana -> new
    /orders/42     ana -> legacy
    /orders/42     ben -> legacy
    /orders/42     chen -> new
    /orders/42     dev -> legacy
    /orders/42     ana -> legacy
    /cart          dev -> legacy
    ramp=  0  users in new stack: 0 of 1000
    ramp= 10  users in new stack: 102 of 1000
    ramp= 25  users in new stack: 246 of 1000
    ramp= 50  users in new stack: 492 of 1000
    ramp=100  users in new stack: 1000 of 1000

    ana gets the same answer on both /orders/42 requests, and /cart, which no migrated rule covers, always goes to the legacy app. A hash gives roughly, not exactly, the percentage asked for (246 of 1000 for 25 per cent). In production your CDN, edge or flag service does this job; Blue-Green, Canary and Rollbacks for Front Ends covers keeping each visitor on one version.

    Slicing: by journey, not by component

    A slice is the unit you migrate and ramp. Choose it so that a user can finish a task inside one stack.

    • A route or a flow (the help centre, the order list and detail) is the best slice: a clear URL, a clear owner, a clear way back.
    • A layer (the design system, the date library, the HTTP client) is a second kind of slice, done first, because both stacks can use the result. See Design System Governance and Versioning.
    • A component inside a page is the worst slice: both stacks render in one page and share state. If you must, keep the contract to props and events. Micro-Frontend Composition Approaches compares the ways to mix stacks in one page.

    Pick the first slice for learning, not for value: small, visited often enough to give data, and without a payment or login in it (judgement). Then pick by value. Fowler's activities include understanding the outcomes you want and changing the organisation to support continual change: the migration is as much about people as about code.

    Parallel change: moving a shared API

    Inside either stack, a shared component or function with many callers cannot change in one pull request. Fowler's parallel change has three phases: expand (the interface supports both the old and the new versions), migrate (update all clients to the new version; for external clients he says this is the longest phase) and contract (remove the old version so the interface supports only the new one).

    Figure 3. The life of one slice or API

    stateDiagram-v2 accTitle: Lifecycle of a migration slice or shared API accDescr: A slice starts planned, then expand where old and new coexist, then migrate where callers or traffic move, then verify with a ramp and rollback, then contract where the old path is deleted, ending done. A failed verify goes back to migrate by rolling back. [*] --> Planned Planned --> Expand: add the new next to the old Expand --> Migrate: move callers or traffic Migrate --> Verify: ramp and watch Verify --> Migrate: roll back, fix Verify --> Contract: all moved, quiet Contract --> [*]: old path deleted

    How to read this: only the last arrow removes code. The loop between Verify and Migrate is the reversible part: it exists so that going back is a normal move.

    Illustration 2: the realistic example

    On the dashboard, a Button component is used in hundreds of places and its variant values must change. A sketch of the expand phase (not run; it shows the shape):

    type OldVariant = "primary" | "secondary";
    type NewVariant = "solid" | "outline";
    
    // Expand: accept both. Old values map to new ones in one place.
    const aliases: Record<OldVariant, NewVariant> = { primary: "solid", secondary: "outline" };
    
    export function resolveVariant(v: OldVariant | NewVariant): NewVariant {
      if (v in aliases) {
        if (process.env.NODE_ENV !== "production") console.warn(`Button variant "${v}" is deprecated`);
        return aliases[v as OldVariant];
      }
      return v as NewVariant;
    }

    The migrate phase is a codemod over the callers; the contract phase deletes aliases once no caller uses an old value. The warning gives a measurable list meanwhile.

    Moving code in bulk: codemods and version steps

    A codemod rewrites source by program. jscodeshift describes itself as a toolkit for running codemods over multiple JavaScript or TypeScript files, with a dry-run option that makes no changes to files and a print option that shows transformed files on stdout. Frameworks publish their own: React's 19 upgrade guide says its team worked with codemod.com to publish codemods that update code to many of the new APIs and patterns, notes that the TypeScript changes need a separate codemod, and recommends upgrading first to react@18.3, which it describes as identical to 18.2 but with warnings for deprecated APIs and other changes needed for React 19.

    Two habits follow. Step up one major version at a time, deprecation-warning release first, so each step has a short list of fixes. Run a codemod per directory after reviewing a sample, so each pull request is small enough to revert. A codemod rewrites syntax, not behaviour: tests and visual regression checks decide whether the result is right.

    Illustration 3: a failure, state that does not cross the seam

    A new slice stores the visitor's cart filter in localStorage under the key the legacy app used, but in a different format. Nothing fails in the new slice. The legacy cart page reads the same key, parses it, finds an unexpected shape and shows an empty filter bar. This is hypothetical but common in kind: every shared store (cookies, storage keys, URL parameters, global events) is an interface with two readers. List them before you ramp, and version their formats.

    Measuring progress and finishing

    Choose a measure that goes to zero: routes still served by the legacy app, callers of the old API (from the deprecation warnings), legacy bundle share of page views. A burn-down of that number, reviewed monthly, is the main tool against the eternal migration. Two rules help (judgement): no new features in the legacy app except by exception, and every migrated slice has a deletion ticket with an owner and a date.

    The other side of this topic. On the back end the same move puts a proxy in front of services; the data is the hard part, and Microsoft's pattern describes copying it with change data capture and validating consistency before cutover. On the front end the browser's storage, cookies and URLs play that role. See Strangler Fig Migration.

    Trade-offs

    Choice Gain Cost
    Facade with routes Small, reversible steps Two stacks and a join to run, secure and test
    Slice by journey A user finishes tasks in one stack Needs shared navigation, tokens and session
    Slice by component Fine-grained moves Shared state and version skew inside one page
    Codemod everything at once Fast Large, hard-to-review changes
    Step one major version at a time Short fix lists More releases

    Build it

    This lesson has no lab. The Node snippet in Illustration 1 was run unedited in Node 26.13.1 and its output is shown as captured. The TypeScript in Illustration 2 is a sketch and was not run. No browser or routing platform was tested.

    In practice: moving the dashboard to a new stack

    NOTE

    This is a realistic scenario, not a case history. It is a composite built from common production patterns. It describes no specific company or product, and every number in it is an illustrative assumption.

    The situation

    The customer dashboard is about forty routes in one old application. Four teams ship to it every week. The framework version is two majors behind, the build takes long enough to slow reviews, and one team wants the new framework for the orders area. Leadership has proposed a six-month rewrite with a freeze.

    Starting architecture

    Figure 4. One application, one release train

    Starting point: one legacy application behind one CDNVisitor to CDN; CDN to Legacy SPA; Legacy SPA to APIsVisitor: browserVisitorbrowserCDN: one originCDNone originLegacy SPA: about 40 routesLegacy SPAabout 40 routesAPIs: sharedAPIsshared

    How to read this: the warning box is the unit of risk today: any change, however small, ships the whole application.

    Options considered

    Option What it fixes What it costs Risk
    Six-month rewrite with a freeze Clean slate Freeze, no features, one cutover The plan "goes down in flames" if scope grows
    In-place upgrade one major at a time Framework gap, with codemods Several releases Large pull requests if not split
    Facade plus slices, orders first Independent delivery for one team A join to build and own A second stack that lasts

    The decision

    Field Decision record
    Context An old framework, a slow shared build and one team ready to move.
    Decision Upgrade in place one major at a time with codemods, in parallel with a facade at the CDN. Migrate the help centre first (low risk), then orders, ramping by stable user bucket with a flag. Share session, tokens and APIs. No new features in legacy routes except by exception.
    Consequences, good Features keep shipping; each step can be reverted; the old stack shrinks measurably.
    Consequences, bad Two stacks for a while; a facade and shared contracts to maintain.
    Revisit when The burn-down stalls for two quarters, or the facade becomes a bottleneck.

    Rollout and verification

    1. List the shared stores (cookies, storage keys, URL parameters, events) and their formats, and make both stacks read and write the same ones.
    2. Add the facade with every route still pointing at the legacy app. Verify nothing changes for users.
    3. Move the help centre behind a flag, internal staff first, then a small ramp with stable buckets.
    4. Watch error rate, latency and task completion for the slice against the legacy numbers before each ramp step; roll back by setting the ramp to zero.
    5. Contract: delete the legacy route and its tests, and move the burn-down number.

    The 2 a.m. failure

    After the orders slice reaches half of users, support sees "my filters vanished" on legacy pages. First three checks: (1) which storage keys both stacks write; (2) whether the format changed in the new slice; (3) whether affected users moved between stacks mid-session. Mitigation: set the orders ramp to zero, which sends everyone back to the legacy route. Follow-up: version the stored format and add a test that both stacks read each other's data.

    Architect's notes

    • Design the join first. The facade, the shared session and the shared tokens decide whether users notice.
    • Make every step reversible. If rollback needs a redeploy, the step is too big.
    • Budget the deletion. The contract step needs an owner, a date and time in the plan.

    Common mistakes

    • A freeze with a rewrite, then drift when the old app keeps changing.
    • Slicing by component, so two stacks share state in one page.
    • No stable bucket, so users bounce between stacks.
    • Forgetting shared stores such as storage keys and cookies.
    • Running a codemod across the repo in one pull request.
    • Never deleting the legacy path.

    Key takeaways

    • Do a large migration as small, reversible steps behind a facade; the finish line is deletion.
    • Slice by journey; share session, tokens and APIs so the seam is invisible.
    • Use expand, migrate and contract for shared APIs, and codemods plus version steps for bulk change.
    • Ramp by a stable per-user bucket and keep a way back.
    • Track a number that goes to zero and give deletion an owner.

    Practice exercises

    Exercise 1: Starter (30 min). List five shared stores two stacks of your app would both touch, with the format and owner of each.

    Exercise 2: Intermediate (2 hours). Extend the Node snippet so a flag can force a user into the new stack, and test that forcing does not change anyone else's bucket.

    Exercise 3: Advanced (half day). Take a real shared component in your app, write the expand step with a deprecation warning, and count callers from the warnings for one week before planning the contract.

    In this course:

    Official documentation

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments