All writing

Rewrite or refactor: how to change your architecture without losing momentum

A plain guide to rewrite vs refactor: signs you need a technical pivot, safer middle paths, moving data, cutting over and explaining the cost to your team.

This guide is for founders and product leads whose product works and has users, but whose codebase is starting to hold the business back. It covers how to tell whether you need a technical pivot, how to choose between a rewrite and a refactor, the options in between, and how to plan, migrate and cut over without stopping the product.

A technical pivot is a deliberate change to the foundations of your product: its architecture (how the parts of the system are organised and talk to each other), its database, its main framework or its hosting. What you sell stays the same. What it runs on changes.

Signs you need a technical pivot, and signs you do not

Early on, you build fast and cut corners to learn what customers want. That is the right call. Later, the shortcuts can cost more than they saved. Look for patterns that last, not one bad week.

Signs the foundations are the problem:

  • Every change is slow and risky. A small feature touches many unrelated parts, and each release breaks something unexpected.
  • The same bugs keep coming back. Fixes do not hold because the design invites the same mistake.
  • You cannot grow in the direction you need. A new market or a large rise in users needs something the current design cannot do.
  • A core tool is no longer supported. A framework or service you depend on has reached end of life, so it gets no more fixes or security updates.

Signs you may not need one:

  • The code is ugly but works. Untidy code that rarely changes costs you little. Leave it alone.
  • Your engineers want something newer. That is a reason to look, and it is not yet a reason to move.
  • The real problem is process. Unclear priorities or no tests will follow you into any new system.

Rewrite vs refactor

A rewrite means building a new system and replacing the old one. A refactor means reorganising the existing code in small steps, without changing what it does for users, while it keeps running.

RewriteRefactor
What it isBuild a new system, then switch overImprove the existing system in place
RiskHigh: the new system must match everything the old one does, including behaviour nobody wrote downLower: each step is small and can be undone
When it fitsThe technology cannot do what you need, or the code is too tangled to improve safelyThe design is sound but the code is messy, slow or hard to change

A rewrite is tempting because a clean start feels fast. But the old system holds years of small decisions: edge cases, fixes for odd customer situations, rules that live only in the code. A rewrite has to rediscover all of them, while the old product still needs fixes and competitors keep shipping.

The options in between

Two approaches sit between the extremes, and they suit most real products.

  • Replace piece by piece behind the same interface. Put a thin layer in front of your system, such as an API gateway, a single entry point that receives requests and decides where to send them. Then replace one capability at a time. Users and other systems keep calling the same interface, so they notice nothing. This is often called the strangler pattern, after a vine that grows around a tree until it replaces it. The old system shrinks until you can switch it off.
  • Run old and new side by side. Both versions run at once, and a small share of real traffic goes to the new one. You can also feed the new version the same requests in the background and compare its answers with the old one, without showing users anything. This is sometimes called shadow mode. It finds differences before customers do.

How to plan it

Start by writing down what the system does today: features, integrations, scheduled jobs, reports, and every place another tool reads your data.

Then set the order:

  1. Start with a small, low-risk piece. Pick something contained and away from revenue. It proves the method and teaches the team.
  2. Move the most painful part next. Once the method works, tackle what blocks you most.

Decide early how feature work continues. You have two broad choices:

  • Full feature freeze. The team works only on the migration. It is simpler and faster, but customers see nothing new, and a long freeze is hard on sales and morale.
  • Partial freeze. Pause changes only in the area being moved and carry on elsewhere. Most small teams do best here.

Moving data safely

Data is the part you cannot easily undo, so treat it with the most care.

  • Take backups and test restoring them. A backup you have never restored is unproven. Practise the restore before you need it.
  • Choose a migration style. With dual writes, your application writes every change to both the old and new database during the transition. With a staged migration, you copy existing data first, catch up on later changes, then switch. Dual writes can drift if one write fails, so you need a check that compares the two.
  • Rehearse on a copy. Run the whole migration on a copy of real data as many times as it takes, and time it. The final run should feel boring.
  • Keep a way back. Keep the old database current, or at least recoverable, until you are confident. Decide in advance what would trigger a return and how you would do it.
  • Change structure in two steps. When a database layout (its schema) must change, first add the new shape beside the old one, move the code over, and remove the old shape later. Each step stays reversible and needs no downtime.

Cutting over and what to watch after

Cutover is the moment real users rely on the new system. With the earlier steps done, it can be gradual.

Use a feature flag, a switch that turns behaviour on or off without a new release, to send a small group to the new path first. Your own team is a good first group. Widen it in steps, pausing to check results. If something goes wrong, the switch sends people back in moments.

After the switch, watch:

  • Errors and failed requests, compared with before.
  • Business signals, such as sign-ups and payments. A technical success that quietly lowers conversions is a failure.

Keep the old system available for an agreed period.

What it costs, and how to explain it

A technical pivot costs time and attention, even when done well. Engineers spend hours on work customers cannot see. Leaders spend attention on decisions and check-ins. Some features arrive later. Say so from the start, because a surprise does more damage than the cost.

With a board, investors or a sales team, speak in outcomes:

  • The problem in business terms. For example, new features take far longer than they should, or the system cannot support the customers you want.
  • What will be different afterwards. Faster delivery, lower running costs, or a new market you can serve.
  • What it will cost. Give a range and say what the range depends on.
  • What customers will notice. Usually the honest answer is nothing, and that is the aim.

If your team lacks senior technical leadership to plan this, a part-time expert can help, as we describe in fractional CTO vs full-time CTO.

Common mistakes

  • Changing too many things at once. Moving the language, the database and the design together makes every fault hard to trace.
  • Having no date to switch the old system off. Running two systems forever doubles your cost and confusion.
  • Skipping tests on current behaviour. Write tests that capture what the system does now. They are your proof that the new one matches.

If part of the reason for change is to make room for AI, our post on adding AI to an existing product explains how to start without a large rebuild.

What to do next

Write down the one thing your architecture blocks, what it costs you each month, and the smallest piece you could move to fix it. If that piece can be replaced behind the same interface, you have a safe first step.

If you want an outside view before you commit, a Second Opinion review of your plan or build costs $99 and is described in the services section.

Questions founders ask

Is a full rewrite ever the right choice?

Sometimes. It fits when the technology cannot do what you need, when the product is small enough that little would be lost, or when the old code is too tangled to change safely. Even then, move in stages and keep the old system running until the new one has proven itself.

How do I keep shipping features during a migration?

Agree on a rule for new work and write it down. A partial freeze on the area being moved, with normal work elsewhere, suits most small teams. Build new features on the new system once the part they depend on has moved.

How do I know the migration is working?

Define checks before you start. Compare old and new data, watch errors and speed, and track the business actions that matter, such as sign-ups and payments. If those hold steady as more users move across, it is working.

What if the migration goes wrong halfway?

That is why you keep a way back. If you replace the system piece by piece and use switches to control who sees what, you can return one piece to the old path without losing the rest. Decide in advance what would trigger that, so the choice is not made under stress.

Have something to build? Tell us your idea and we will tell you what it takes.

Book a free 30-min call