Our step-by-step flow for modernizing a legacy application: read it first, add tests, upgrade, replace one piece at a time, move data safely, release in stages.
Your application still earns money. Customers log in every day. Your team knows its quirks by heart. But every change takes longer than it should, the framework is out of support, and nobody wants to touch the billing code.
Many companies answer this with a full rewrite. We rarely do. This article walks through how we modernize a legacy application at Dapton, phase by phase. For each phase you will see what we do, what we check, what you receive, where AI helps and where a person decides. The examples are illustrative, not client results.
Why not just rewrite the legacy app from scratch?
A full rewrite stops new features for a long time and still has to match years of hidden behavior. Replacing one piece at a time keeps your business running and shows results early.
Martin Fowler, who named the strangler fig approach, says the simple replacement plan usually goes badly. The old system holds rules nobody wrote down. Some of its behavior is not even wanted, so rebuilding it is wasted work. Meanwhile your users keep asking for features that wait behind the rewrite.
A gradual approach spreads both the cost and the payoff. Each new piece goes live on its own and starts paying back. The price is some temporary code that lets old and new run side by side. We think it is worth paying.
Phase 1: What do we look for when we assess a legacy application?
We read the code, map how the parts depend on each other, and find what is slow, risky, expensive or blocking the business. Then we pick an option for each part, in writing, before any build starts.
We start with the product itself, used the way your customers and staff use it. We ask your team which changes always break something. Then we go through the code, the hosting, the database and every integration with another system, such as payments or your CRM.
We write a dependency map, a picture of which parts call which, and which outside services they rely on. Next to it sits a risk map. It shows, for each part, how much it holds you back and how risky it is to change. A part can be slow, unsafe, expensive to run, or simply in the way of a feature you need.
- Runtime and framework versions, and whether each one still gets security fixes.
- Packages with known vulnerabilities, using the audit tools your language provides.
- Where the business rules live, including rules hidden in database procedures or scheduled jobs.
- Which pages and requests are slow, measured on the live system where possible.
- How code reaches production today, and who can deploy.
- Where backups are kept, and when a restore was last tried.
Then we choose an option for each part. On our modernization page we use seven: keep, move, upgrade, clean up, re-architect, rebuild and retire. For most buyers they fold into four plain questions.
- Keep it. This fits when the part works, people like it, and nothing new depends on changing it.
- Upgrade it. This fits when the design is sound but the framework, runtime or packages are out of date.
- Rebuild that piece. This fits when one part is past saving and slows every release, while the rest is fine.
- Replace or retire it. This fits when an off-the-shelf product already does the job, or when nobody uses the part any more.
AI helps a lot here. We use tools such as Claude and Cursor to summarize unfamiliar modules, find where a function is called, and draft the dependency map. A person decides which summaries are right, which parts are risky, and which option each part gets.
What you receive: a product assessment, the dependency and risk maps, an option for each part, and a written migration scope. The scope says what moves, what stays and what is left out. Nothing is built until you approve it.
The mistake we avoid: deciding to rebuild before anyone has read the code. A rebuild is sometimes right. We recommend one only when the review supports it.
Phase 2: Which safety net goes in before we touch a line of code?
Before we change a line, we add tests that record what the system does today, plus error tracking, logging, tested backups and a written rollback plan. These make every later step safe to try.
Legacy code often has few tests. So we write characterization tests. A characterization test records what the code does now, right or wrong. Michael Feathers, who coined the term, points out that a live system becomes its own specification. Users may depend on behavior that looks like a bug. If a later change alters that behavior, the test fails and a person looks at it.
We write these tests around the journeys that matter most: sign-up, checkout, invoicing, reports. For web journeys we use browser tests in Playwright. For code-level rules we use the test tools your stack already has, such as Vitest for TypeScript or the Laravel and Django test runners. The tests live in your repository and run in your pipeline on every change.
We also add monitoring before we change anything. Sentry tracks errors per release. Logs and health checks show what is normal today. OpenTelemetry, an open standard for traces, metrics and logs, can send that data to whichever tool you use. Without a starting point, nobody can say later whether the new version is better or worse.
- Each characterization test fails at least once on purpose, so we know it really checks something.
- Backups exist and a restore has been tried on a copy, with the result written down.
- Error rates and response times have a recorded starting point.
- The rollback plan names who decides, what triggers it and the exact steps.
AI drafts many of these tests quickly. It can read a messy function and suggest inputs worth trying. The risk is that a drafted test guesses the expected answer instead of recording the real one. An engineer checks every assertion, the line that decides pass or fail, against what the system actually does.
What you receive: a test suite in your repository, monitoring dashboards and alerts, a tested backup and a rollback plan you have read and agreed.
The mistake we avoid: starting the upgrade first and adding tests later. By then you can no longer tell an old quirk from a new bug.
Phase 3: How do we upgrade an old framework without breaking it?
We upgrade one layer at a time, one major version at a time, with automated code changes where the framework provides them. An engineer reviews every change before it merges.
The runtime is the engine your code runs on, such as Node, PHP or Python. Each has a support window. The Node.js project, for example, says production apps should only run its long-term support releases. Once a version leaves support, security fixes stop. That alone is often the strongest reason to modernize.
Frameworks publish upgrade guides, and we follow them closely. React shipped a bridge release, 18.3, that warns about APIs removed in React 19. Django advises clearing deprecation warnings before moving to the next version. Laravel and Angular publish step-by-step guides for each major release. We go one major version at a time, so each step stays small and each failure points at one cause.
Many upgrades come with codemods. A codemod is a script that rewrites code patterns automatically, like a very careful find and replace. React publishes codemods for its upgrade. OpenRewrite does the same for Java with ready-made recipes. We run them on a separate branch, then read the result.
- We automate: version bumps, codemods, formatting, dependency audits, and the test run on every pull request in GitHub Actions.
- A person reviews: anything that changes behavior, security settings, authentication, payments, and any spot where a codemod gave up.
AI is useful for the long tail: deprecated calls the codemod missed, small API changes across many files, and first drafts of release notes. Every AI-written change goes through the same review and tests as human code. AI never approves its own work.
What you receive: current, supported versions, a list of fixed security issues, and a pull request history that shows every change and who reviewed it.
The mistake we avoid: jumping several major versions in one go. When it breaks, nobody knows which step caused it.
Phase 4: How does the strangler fig pattern replace a legacy app piece by piece?
We put a routing layer in front of your application and rebuild one piece behind it. Traffic moves to the new piece while the old one keeps running. Piece by piece, the new system grows around the old one.
The routing layer, sometimes called a facade, is a single front door for requests. It sends each request to the old system or the new one. At first everything goes to the old system. When the first new piece is ready, the routing layer sends that piece's traffic to it. Your users see the same address and the same product.
For the first piece we pick a part that is visible, low risk and fairly separate, such as content pages or a report screen. It proves the routing, the pipeline and the release process before the harder parts follow.
Inside the code we use a related technique called branch by abstraction. We put an interface in front of the module we want to replace. The rest of the code calls the interface, not the module. Then we build the new version behind the same interface and switch over when it is ready. The system builds and runs correctly the whole time.
Old and new parts must talk to each other during the move. Microsoft's guide to this pattern suggests an adapter, which it calls an anti-corruption layer. It translates between the two, so the new code does not inherit old naming and habits. We write the API contract first: the requests, responses and errors each side expects. Then both sides build against it.
- The routing layer is monitored, because it must never become a single point of failure.
- Each new piece returns the same results as the old one for the same input, checked with tests and, where useful, by comparing live responses.
- Every move has a switch back to the old piece.
What you receive: the routing layer, written API contracts, and each new piece live in staging and then in production, one at a time.
The mistake we avoid: building the whole new system out of sight and switching on one day. That is a rewrite with extra steps.
Phase 5: How do we move legacy data with a way back at every step?
We change the database in reversible steps called expand and contract. We add the new structure, write to both, copy and check old records, switch reads, and only then remove the old one.
Data is the riskiest part of a modernization. Code can be redeployed quickly. A lost or wrongly converted record may never come back. So we plan the data early.
- Expand. We add the new table or column next to the old one. Nothing reads it yet.
- Write to both. The application writes every change to the old and the new structure.
- Backfill and check. A script copies the older records across. We compare counts and key values between old and new.
- Switch reads. The application reads from the new structure, behind a switch we can turn off.
- Contract. Once everything has run cleanly, we stop writing to the old structure and remove it.
This pattern is also called parallel change. Its value is simple: at every step before the last one, the application still works with the old data. If something looks wrong, we turn the switch back. Fowler's writing on evolutionary database design adds two habits we follow. Every schema change is a script in version control. Every developer works against their own copy of the database.
When data moves to a different database or a new service, we keep the two in sync during the move. Sometimes the application writes to both. Sometimes a sync job copies changes across. We rehearse the full migration on a copy of production data first, time it, and check the result before anyone plans the real run.
- Row counts match between old and new, table by table.
- Key values match on samples, such as totals, balances, dates and statuses.
- Records the old system treated in odd ways, such as empty fields and old formats, come through unchanged or are fixed on purpose.
- The rehearsal ran end to end on a copy, with a written result.
AI can draft migration scripts and the queries that compare old and new data. It can also spot odd values in a sample. A person reviews every script before it touches real data, and a person signs off the comparison results.
What you receive: versioned migration scripts, a rehearsal report, comparison results and a fallback plan. Your current data stays untouched until the new setup passes its checks.
The mistake we avoid: leaving the data until the end, then moving it all in one night with no way back.
Phase 6: When is moving a legacy app to the cloud worth it?
We move hosting only when it pays off, for cost, security, speed or ease of release. What we almost always add is a repeatable pipeline, so every release follows the same tested path.
AWS describes a set of cloud migration strategies, including rehost (move as is), replatform (move with small changes) and refactor (change the code itself). They are useful words, but the order matters. Moving and rewriting at the same time stacks two risks. AWS itself advises rehosting or replatforming first for large moves, then modernizing after.
We start with delivery, because it helps every other phase. Build, test and deploy steps run in GitHub Actions from your repository. Docker packages the application with its dependencies, so it runs the same on a laptop, in testing and in production. Terraform describes servers, databases and permissions as files you can read and rebuild. Kubernetes comes in only when many services need to scale on their own.
The Twelve-Factor App, a well-known set of rules for web apps, guides small choices. Settings live in the environment. Development, staging and production stay as alike as possible.
- Secrets live in a secrets manager, one set per environment, never in the repository.
- Staging matches production closely enough that a passing test means something.
- A deploy can be repeated, and rolled back, with one step.
- Hosting cost before and after is compared, so the move is justified with your numbers.
What you receive: a pipeline in your repository, infrastructure as code, separate environments, and hosting on AWS, Google Cloud, Vercel or your current provider, whichever fits.
The mistake we avoid: moving to the cloud because it sounds modern. If the old servers are fine, the money is better spent elsewhere.
Phase 7: How do we release modernized pieces without surprising your users?
Every change passes the regression suite, then goes live in small releases behind feature flags. A small group sees it first, then everyone, while we watch error rates and speed.
A regression suite reruns earlier checks to prove old features still work. Ours grows through the project. The characterization tests from phase 2 are part of it, and every fixed bug adds a new test. A failing required check blocks the merge until it is fixed.
A feature flag is a switch in the code that turns a feature on or off without a new deploy. It lets us separate putting code in production from showing it to users. Fowler's guide calls these release toggles and warns they should be short-lived. So every flag we add has an owner and gets removed after the full rollout.
With a flag in place, we release in stages. First our own team uses the new version, then a small group of users, then more, then everyone. Some teams call this a canary release, after the canary once used to warn miners early. Each stage widens only when the last one looks healthy.
- Error rate per release in Sentry, compared with the starting point from phase 2.
- Response times, including the slowest requests.
- Business signals your team cares about, such as completed orders or sign-ups.
- Support tickets and user reports for the area that changed.
What you receive: a release plan for each piece, flags you can see and switch, and release notes. Every production release is signed off by a named person on your project.
The mistake we avoid: switching every user over at once and finding problems from customer complaints.
Phase 8: What happens on cutover day, and what do you get after?
Cutover is the moment the old part stops serving users. We run it from a written checklist, keep the old part on standby until the new one proves itself, and then remove it properly.
With a staged approach, cutover day is usually quiet, because most traffic has already moved. Here is the checklist we start from, adjusted for each project.
- The release window is agreed with you and your support team.
- Everyone on the release knows who decides to go ahead or roll back.
- A fresh backup is taken and its restore has been tested.
- All required checks in the pipeline are green for the exact version going out.
- The data rehearsal result is signed off and the final sync is ready.
- Monitoring dashboards and alerts are open, with a named person watching.
- The feature flag or routing rule for the switch is ready, and so is the switch back.
- Redirects are in place for any URL that moves, so links and search results still work.
- Integrations with payments, email and your CRM are pointed at the right environment.
- Secrets and settings for production are checked against the list.
- The switch is made, and the key journeys are tested by hand right after.
- Row counts and key values are compared again after the final sync.
- Error rates and response times are compared with the starting point.
- Your team and support staff are told what changed and where to report issues.
- The old part stays on standby until the agreed checks pass.
- Only then is the old part switched off, with its data archived as agreed.
Decommissioning is real work. We remove old code, old flags, the routing rules that are no longer needed, and unused servers. Leftover pieces cost money and confuse the next developer. Where the routing layer still helps, for example for older clients, we keep it on purpose and write down why.
What you receive: up-to-date documentation, an architecture diagram, runbooks for common jobs such as deploying and restoring, and access for your team to everything. The code lives in your repositories from day one, so handover is about people and knowledge.
The mistake we avoid: leaving the old system running forever next to the new one, so you pay for both.
Where does AI speed up legacy modernization, and where does a person decide?
AI speeds up reading old code, drafting tests and writing repetitive migration changes. It does not decide what the business rules are, and an engineer reviews everything it writes.
Legacy work has a lot of reading in it, and AI tools are good at that. They summarize modules, explain strange queries and make repetitive edits across many files. In a published Google study of internal code migrations, an LLM generated most of the code changes, and developers still reviewed and submitted each one.
- AI helps: summarizing legacy modules, drafting characterization tests, suggesting upgrade fixes, drafting migration and comparison scripts, and writing first drafts of documentation.
- A person decides: what is a rule and what is a bug, the option for each part, the order of work, and every merge and release.
The biggest risk is a confident misreading. An AI summary may describe what the code seems to do, while missing a rule hidden in a database trigger or a nightly job. A drafted test can pass while checking very little. So we treat AI output as a draft from a fast new colleague. Tests prove it. A person reads it. When we are unsure what a rule means, we ask your team, because they know why it exists.
AI tools only get the access they need, work in their own branch, and never touch production data directly. You can read more about this in our process for checking AI-built work.
Which legacy modernization mistakes do we refuse to make?
The most common mistakes are big-bang rewrites, changing code with no tests, and moving data last. Each one turns a manageable project into a risky one.
- A big-bang rewrite. Everything changes at once, nothing can be checked on its own, and your users wait.
- No tests before changes. Without them, nobody can say whether a change broke something.
- Migrating data last. Data problems found at the end have no time left to be fixed.
- Copying every old behavior blindly. Some of it is no longer needed, so we ask before we rebuild it.
- Flags and temporary code that never leave. They pile up and slow the next change.
Common questions
Will our users notice the modernization?
Ideally they notice only that things get faster or easier. The current version stays live until each new piece passes its checks. We cannot promise zero interruption for every system, so any release window is agreed with you in advance.
Can we keep adding features during the project?
Usually yes, and that is a big reason we replace one piece at a time. New features can be built in the new code while older parts wait their turn. We plan the order with you so the two kinds of work do not collide.
Do you need our old developers?
It helps a lot if someone who knows the system can answer questions, especially about business rules. If nobody is left, we rely more on characterization tests, the live system and your users. We say up front which unknowns that leaves.
How long does a legacy modernization take?
It depends on the size of the system and the options chosen for each part. We give an estimate after the assessment, in the written scope, not before we have read the code.
What if the assessment says we should rebuild?
Then we say so and explain why, part by part. Even a rebuild can go live in pieces behind a routing layer, so the old system keeps working until the new one is checked.
Who owns the code and the infrastructure?
You do. The code lives in your repositories and the infrastructure runs in your accounts. Your team gets access to everything, along with the documentation and runbooks.
Thinking about modernizing your application?
If your application is getting harder to change, a good first step is an honest look at what you have. We can review it with you, tell you which parts we would keep, upgrade, rebuild or retire, and agree a scope in writing. Get in touch through our contact page or book a call.
Documentation and references
- Strangler Fig, Martin Fowler ↗
- Strangler Fig pattern, Azure Architecture Center ↗
- Characterization Testing, Michael Feathers ↗
- Branch By Abstraction, Martin Fowler ↗
- Parallel Change, Danilo Sato ↗
- Evolutionary Database Design, Pramod Sadalage and Martin Fowler ↗
- Feature Toggles, Pete Hodgson ↗
- Migration strategies, AWS Prescriptive Guidance ↗
- React 19 Upgrade Guide ↗
- Node.js releases ↗
- The Twelve-Factor App ↗
- Migrating Code At Scale With LLMs At Google (arXiv) ↗
Working with Application modernization and Legacy software? Tell us what you’re building and our engineers will tell you how they would approach it.
Talk to our team →