A rewrite feels clean. That feeling is the trap.
Your app is slow, the code scares people, and every new feature takes three times longer than it should. So someone proposes the rewrite. Burn it down, start fresh, do it right this time. It sounds responsible. It usually is not.
Most teams reach for the rewrite when a refactor would do. The two have very different costs, and the gap is bigger than the demo ever shows.
What a rewrite actually costs
A rewrite is not a coding project. It is a migration project wearing a coding costume.
You think you are rebuilding the app. You are actually rebuilding every business rule your old code learned over years. Most of those rules are undocumented. They live in if-statements someone added at 2am to handle a customer edge case. The original author is gone. Nobody remembers why the discount caps at 18 percent.
Here is the part that hurts. While you build the new system, the old one keeps shipping. Bugs get fixed in prod. Features get added. Your rewrite is now chasing a moving target. Teams run two codebases for months and pour effort into both.
The classic failure mode is the 80 percent rewrite. The new app does most of what the old one did. The last 20 percent is the gnarly stuff nobody wants to port. So the cutover never happens, and you maintain two systems forever. That is the worst outcome of all.
What a refactor actually buys
A refactor keeps the app running while you fix it from the inside.
You change structure without changing behavior. Extract the tangled function. Add tests around the scary module before you touch it. Replace the bad database access pattern, one query at a time. Ship each step to production. If something breaks, you know exactly what caused it, because the change was small.
The refactor is slower per visible feature. It is far cheaper in risk. You never run two systems. You never lose the undocumented business rules, because you never threw them away. You just made them readable.
Most legacy apps do not need a rewrite. They need a few weeks of disciplined refactoring on the parts that actually hurt.
When a rewrite is the right call
Sometimes the foundation is genuinely wrong, and refactoring just decorates the problem.
Rewrite when the runtime is end-of-life and unpatched. Rewrite when the framework is dead and you cannot hire for it. Rewrite when the data model makes the features you need impossible, not just annoying. Rewrite when the app cannot scale on its current architecture no matter how clean the code gets.
Even then, rewrite in slices. Strangle the old app one route at a time. Put the new service behind the same URL and migrate traffic gradually. A big-bang cutover on a date is how rewrites die.
How we scope this
We have shipped 17 production products, 10 of them in our first 7 months as a 2-person team, and almost none of them started clean.
Most were a mix. Refactor the core, rewrite the one module that was beyond saving, move it all to AWS without a 6-month freeze. Our background is AWS Federal solution architecture, with 18 cloud certifications across the team and 13 AWS Certified. That matters here because the expensive mistakes in this work are almost always infrastructure mistakes, not code ones.
Our Web App work is fixed-price every time. You get a real scope before we start, you own the code, and we exit when it ships. No open-ended hourly bill that quietly rewards the slow path. If we think a refactor is cheaper than the rewrite you asked for, we will tell you, and we will price it that way.
Often the smartest first move is smaller than either. A focused Well-Architected Review tells you whether the foundation is actually broken or just messy. We have seen plenty of "we have to rewrite this" apps that needed two weeks of cleanup instead.
The honest version
Ask one question before you commit. Is the foundation wrong, or is the code just ugly?
Ugly code gets refactored. Wrong foundations get rewritten in slices. Confusing the two is how a 6-week fix becomes an 18-month rebuild that ships late and breaks the things that used to work.
If you are staring at an app and cannot tell which side you are on, that is a good thing to talk through with someone who has done both. Book a free 30-minute call and we will give you the straight answer, even if the straight answer is "leave it alone for now."