Skip to content

    Frontend System Design

    Shipping Front-End Changes Safely Alongside the Backend

    Release a change that spans the front end and API without breaking open tabs or rollbacks: deploy order, expand and contract, flags and compatibility checks.

    By Published 12 min read

    Share

    Standard lessonadvancedFrontend System Design

    Before this: Version Skew and Cache-Busting Deployments, API Versioning and Contract Evolution for Clients

    What you'll learn: By the end of this lesson you will be able to list the four front-end and back-end version pairs that exist during any release, say which pairs a deploy order creates, choose a deploy order for a change that touches both sides, make the front end tolerant so the order stops mattering, use a flag to separate deploying code from releasing a feature, and say what a rollback of either side must still support.

    Imagine replacing every power socket in a building while the residents keep their old plugs. Swap them all overnight and half the residents cannot charge a phone. The workable way is a socket that takes both plugs, a long period in which residents change over, and only then retiring the old shape. A web app has the same problem with two parties who never deploy at the same moment: the front end in browsers and the API it talks to.

    The example is the checkout of the ShopStream grocery marketplace: the delivery window changes from one text field to a start and an end, and the order request gains a field for what to do when an item is out of stock. The blue-green and canary lesson covers moving traffic between front-end builds, and API versioning and contract evolution covers which changes break a client. This lesson is the choreography of one change across both.

    The core idea

    1. The front end and the back end are deployed separately, so for a while they are different versions. Version skew happens, in one engineer's words, when two or more distributed systems with a dependency between them get deployed, because the deployment is not atomic and they temporarily run at different versions.
    2. Every release creates pairs you did not test together. Each pair has to work, or be made impossible.
    3. Make each side compatible with the other's neighbouring version, and the order stops mattering. Then a rollback of either side is also safe.

    The four pairs

    At any moment some users run an older front-end build, because tabs stay open and builds are cached. The API runs one version, or two during its own rollout.

    Pair How it arises What breaks
    Old front end, old API Before the release Nothing
    Old front end, new API The API deploys first, and old tabs are still open The old tab reads a field that is gone, or omits a field now required
    New front end, old API The front end deploys first, or the API is rolled back The new code reads a field that does not exist yet
    New front end, new API After the release Nothing

    The two middle rows are the dangerous ones. Whichever side goes first creates one of them, and a rollback of the API creates the other, so no order avoids them; the fix is compatibility.

    Figure 1. Two builds, one API

    Old and new tabs meet one APIOpen tab to Checkout API (old calls); New tab to Checkout API (new calls); API deploy to Checkout API (new shape)Open tab: old buildOpen tabold buildNew tab: new buildNew tabnew buildCheckout API: current versionCheckout APIcurrent versionAPI deploy: changes the shapeAPI deploychanges the shapeold callsnew callsnew shape

    How to read this: the API deploy changes the contract under a tab that was loaded earlier. The tab cannot be told; it keeps sending and reading the shapes it was built with.

    Rules for the order

    Three rules cover most changes. They follow the expand, migrate and contract sequence that Martin Fowler calls Parallel Change: add the new form beside the old one, move clients over, then remove the old form. Fowler adds that the pattern is particularly useful with continuous delivery because it allows your code to be released in any of the three phases, and warns that if the contract phase is never run you might end up in a worse state than you started.

    1. The API expands first. It accepts and returns both shapes. Google's API design guide treats adding fields, and adding enum values to request-only enums, as compatible, and treats removing or renaming a component as incompatible. It also says new required fields must not be added to existing request messages. The version-skew article states the same rule: servers must never introduce new required fields until they know all clients are updated.
    2. The front end is tolerant. It reads whichever shape is present and does not require anything the old API lacks. Fowler's Tolerant Reader is the same idea: take only the elements you need and ignore anything you do not.
    3. The API contracts last, after you can show that no front-end build still uses the old shape.

    Figure 2. Which side goes first?

    flowchart TD accTitle: Choosing the deploy order for a change that spans front end and API accDescr: A decision tree. If the change is additive for old front ends, deploy the API first. If it is not, redesign it as an expand step. Then the front end ships tolerant code that reads either shape. The API contracts only when monitoring shows no old front-end build still uses the old shape. A{"Does the API change
    keep old front ends working?"} A -->|"yes (additive)"| B["Deploy the API first"] A -->|"no"| C["Redesign as expand:
    old and new shape together"] C --> B B --> D["Ship a tolerant front end:
    reads either shape"] D --> E{"Any old build still
    using the old shape?"} E -->|"yes"| F["Wait; keep both shapes"] F --> E E -->|"no, for the agreed period"| G["Contract: remove the old shape"]

    How to read this: the loop at the bottom is the migrate phase. It ends on evidence from monitoring, not on a date.

    Illustration 1: the minimal example

    The delivery window moves from a slot text to a delivery object. Three API versions and three front-end builds are modelled as plain objects and functions. F1 is the old build, F2 reads only the new shape, F3 reads either. Run in Node:

    const slotWindow = { start: "10:00", end: "11:00" };
    const backends = {
      B1: { slot: "Tue 10:00" },                     // old shape
      B2: { slot: "Tue 10:00", delivery: slotWindow },   // expand: both shapes
      B3: { delivery: slotWindow },                      // contract: new shape only
    };
    const fronts = {
      F1: (r) => r.slot.trim(),                      // old front end
      F2: (r) => r.delivery.start,                   // new, new-shape only
      F3: (r) => (r.delivery ? r.delivery.start : r.slot.trim()), // new, reads either
    };
    const ok = (f, b) => { try { fronts[f](backends[b]); return true; } catch { return false; } };
    const check = (label, pairs) => {
      const bad = pairs.filter(([f, b]) => !ok(f, b)).map((p) => p.join("+"));
      console.log(label.padEnd(36), bad.length ? "BREAKS " + bad.join(", ") : "ok");
    };
    console.log("Plan A: rename in one step");
    check("B3 live, open tabs on F1", [["F1", "B3"]]);
    check("F2 live, B3 rolled back to B1", [["F2", "B1"]]);
    console.log("Plan B: expand, migrate, contract");
    check("B2 live, tabs on F1", [["F1", "B2"]]);
    check("F3 live, tabs on F1 and F3", [["F3", "B2"], ["F1", "B2"]]);
    check("B2 rolled back to B1", [["F3", "B1"], ["F1", "B1"]]);
    check("F1 gone, B3 live", [["F3", "B3"]]);
    check("B3 rolled back to B2", [["F3", "B2"]]);

    Output, from running it in Node 26.13.1:

    Plan A: rename in one step
    B3 live, open tabs on F1             BREAKS F1+B3
    F2 live, B3 rolled back to B1        BREAKS F2+B1
    Plan B: expand, migrate, contract
    B2 live, tabs on F1                  ok
    F3 live, tabs on F1 and F3           ok
    B2 rolled back to B1                 ok
    F1 gone, B3 live                     ok
    B3 rolled back to B2                 ok

    Plan A breaks in both directions: the old tab fails after the API changes, and rolling the API back breaks the new front end. Plan B survives every step, including a one-step API rollback. It would not survive removing the old shape while F1 tabs exist, which is why the contract step waits for evidence. The model shows the logic only.

    Releasing is not deploying

    A feature flag lets code ship dark and be switched on later. Fowler's article on feature toggles frames release toggles as a way of separating feature release from code deployment: they allow incomplete code paths to be shipped to production as latent code that may never be turned on. For this lesson the flag does one job: the new checkout step stays hidden until the API that supports it is live everywhere.

    Two cautions from the same article: release toggles are short-lived (it says not much longer than a week or two), and toggles are inventory with a carrying cost, so add a removal task with each one.

    A client flag is not proof that the API has the capability. Read the capability from the API's response (the field is there or it is not) and let the flag decide only whether the feature is allowed. The feature flags lesson covers evaluation and targeting.

    Knowing what is live

    Compatibility you cannot observe is a hope.

    • Tag requests with the front-end build id (a header or field of your own naming) so the API can count which builds still use the old shape.
    • Check pairs, not just builds. The Pact Broker's can-i-deploy command asks whether a version is compatible with the versions already in an environment by looking for a successful verification result between them, so teams can check before deploying without a combined release. See contract testing for front ends.
    • Expect chunk skew too. An open tab may request a lazy chunk the deploy deleted. Vite emits vite:preloadError when a dynamic import fails and documents Cache-Control: no-cache on the HTML file. The blue-green lesson covers the mitigations; a lesson on version skew and cache-busting deployments is planned (plain text, not linked yet).

    Illustration 2: the realistic example

    On the ShopStream checkout, one change needs both sides: show a delivery window and send substitutionPolicy. The plan, in order:

    Step Side Change Check before moving on
    1 API Returns slot and delivery. Accepts orders with or without substitutionPolicy, defaulting it Old and new request shapes both pass in the contract tests
    2 Front end Ships tolerant code; the substitution step sits behind a release flag, off Preview build renders against the API with and without delivery
    3 Flag Enabled for staff, then a share of shoppers Orders still succeed; no spike in 4xx by build id
    4 Both Old builds age out; the API logs the old shape as unused Zero use of the old shape for the agreed period
    5 API Contract: slot removed, substitutionPolicy required Rollback target is the previous API, which still works with the front end

    Illustration 3: a failure, and a guard

    Suppose step 5 happens early. A shopper opened checkout before the release and presses Place order an hour later. The tab sends the old request shape, without substitutionPolicy. Illustrative response, using the Problem Details format from RFC 9457 (not run):

    {
      "type": "https://example.test/problems/missing-field",
      "title": "Missing required field",
      "status": 400,
      "detail": "substitutionPolicy is required"
    }

    Figure 3. The open tab meets a new requirement

    sequenceDiagram accTitle: An old tab sends an order without a newly required field accDescr: The shopper opened checkout on an old build. The API now requires substitutionPolicy. The tab sends the old request shape, the API answers 400, and the shopper sees an error although nothing they did was wrong. If the API had defaulted the field, the order would have succeeded. participant S as Shopper (old tab) participant A as Checkout API (new) S->>A: POST order without substitutionPolicy A-->>S: 400 missing field Note over S: order fails on a request that was valid when the page loaded

    How to read this: nothing in the tab changed; the API changed the rule under it. A default in the API, or keeping the field optional until old tabs are gone, would have let the order through.

    A 400 here is a defect of the release, not of the shopper, and retrying it will not help (see Client Retries and Backoff). The guard is the rule from the start: no new required fields until every client sends them.

    Rolling back each side

    Rollback of What must still work What it does not undo
    Front end The previous build against the current API Tabs already loaded; browser and service worker caches
    API Both front-end builds against the previous API Data written in the new shape; events already published

    Version locking is the other route. Vercel's Skew Protection routes framework-managed requests (assets, client navigations, prefetches) to the deployment that served the initial page. It does not pin full-page navigations, which get the latest deployment, and its maximum age defaults to 12 hours on Pro and one day on Enterprise, so a session can outlive it. The version-skew article notes that locking makes deployments substantially more complex.

    Trade-offs

    Choice Gain Cost
    Expand, migrate, contract Any order, any rollback Two shapes to maintain, and a contract step to finish
    Version locking Old tabs keep a matching API Old API versions stay deployed and patched
    Release flag Deploy now, release later A flag to remove, and a path nobody tests
    Contract tests Catch pair breakage before deploy Test upkeep; they cover only what consumers declare

    Build it

    This lesson has no lab. The Node script above is the whole model and was run to produce the output shown. Contract tests, flags and a deployment platform were not run, and no deploy, CI pipeline or browser was used.

    The other side of this topic

    The back-end view is rolling, blue-green and canary deployments of the API, with feature flags and contract tests on the provider side (back-end lessons planned in this course, so plain text, no link). The back end stays compatible with the front-end builds in the wild; the front end tolerates the API's neighbouring versions.

    In practice: the substitution preference

    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

    Two teams own the ShopStream checkout: one ships the front end several times a day, the other the API twice a week (illustrative). The next feature needs a new request field. Today they agree a release time on a call, and a rollback of either means a rollback of both.

    Starting architecture

    Figure 4. Two pipelines, no shared check

    Starting architecture: two pipelines with no compatibility checkFront-end pipeline to Shopper tabs (new builds); Shopper tabs to Checkout API (orders); API pipeline to Checkout API (deploys)Shopper tabs: builds of all agesShopper tabsbuilds of allagesFront-end pipeline: ships oftenFront-endpipelineships oftenAPI pipeline: ships weeklyAPI pipelineships weeklyCheckout API: one version liveCheckout APIone version livenew buildsordersdeploys

    How to read this: the warning boxes are the two release paths. Nothing connects them except a call, so each deploy is a bet about the other side.

    Options considered

    Option What it fixes What it costs
    Lockstep release No skew in theory Coordination; open tabs still skew
    Expand, migrate, contract with a flag Independent release and rollback Two shapes for a while
    Version locking by the platform Old tabs keep their API Old versions kept alive; age limit

    The decision

    Field Decision record
    Context Two teams, two cadences, tabs that stay open for hours.
    Decision Expand, migrate, contract. The API defaults the new field and returns both shapes. The front end ships tolerant code behind a release flag. The contract step is a ticket with an owner and a check on build-id counts.
    Consequences, good Either side can release or roll back alone; no release call.
    Consequences, bad Two shapes in the API for weeks; a flag to remove.
    Revisit when Sessions outlive the migrate window, or a change cannot be made additive.

    Rollout and verification

    1. Add a build id to checkout requests and make the API count the shapes it sees.
    2. Add contract cases for old and new shapes.
    3. Release in the order of Illustration 2, checking each gate.
    4. Rehearse the API rollback against both front-end builds before the contract step.

    The 2 a.m. failure

    After the contract step, support reports orders failing for shoppers who left checkout open overnight. The API log shows 400 errors for a missing field from one older build id.

    First three checks: (1) which build ids still send the old shape; (2) when that build was last the live one; (3) whether the contract gate counted that build. Mitigation: make the field optional again with its default. Follow-up: include the longest session length in the gate period.

    Architect's notes

    • Assume two versions of each side are live, and design the pairs.
    • A rollback is a release. Test it against every front-end build still in the wild.
    • Never add a required field in one step. Default it, then require it once evidence says it is safe.
    • Give the contract step an owner. An unfinished contract leaves you worse off.

    Common mistakes

    • Removing the old shape in the same release that adds the new one.
    • Assuming a deploy order makes skew impossible. Open tabs and rollbacks create the other pairs.
    • A front end that requires the new field, so it breaks after an API rollback.
    • No build id on requests, so "nobody uses the old shape" is a guess.
    • A migrate window shorter than the longest session.

    Key takeaways

    • Front end and API deploy separately, so old-with-new and new-with-old pairs always occur.
    • The API expands first, the front end tolerates both shapes, the API contracts last.
    • Contract on evidence (build-id counts, contract tests), not on a date.
    • A release flag separates deploying from releasing, but it is not proof the API supports the feature.
    • A rollback of either side must still work against what the other side is running.
    • Version locking helps but has an age limit and a cost.

    Practice exercises

    Exercise 1: Starter (20 min). Add a build F4 to the script that requires substitutionPolicy in its request, and a backend that rejects requests without it. Find which pairs break.

    Exercise 2: Intermediate (2 hours). Write the step table for renaming deliveryNotes to driverNotes, with a check for each step and a rollback for each.

    Exercise 3: Advanced (half day). Define the gate for the contract step: which build-id counts, over how long, and what you would do if the longest session in your data were 20 hours (an assumption).

    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