Modernising a .NET 4.6 monolith with TOGAF 10 and AI agents
About 80 REST APIs and 20 background jobs on IIS, moved to .NET 10 on Linux containers. One engineer and an AI agent had a tested, deployed system in 10 working days.
The organisation owned the code, but the source in the repository was out of date: the DLLs running on Windows Server were newer than any code anyone had. We recovered the real system from the binaries, proved its behaviour with a test baseline run against legacy, and rebuilt it as six microservices on .NET 10. TOGAF 10 kept the AI agent on a leash. Go-live took four months, and the code was not the hard part.
For client confidentiality, business domains and service names are kept generic.
An “untouchable” system
Developers had deployed builds without pushing their changes, so production ran code nobody had. Over a decade the system had picked up the usual scars. None of it is unusual: it's what years of delivery under pressure look like, and it's exactly why people are afraid to touch these systems.
- Background work spread across console apps run by hand, threads hidden inside HTTP requests, and a few Azure Functions
- Secrets in configuration files, or hardcoded
- One shared username and password for every third party calling the APIs
- Outdated libraries, many abandoned or carrying known vulnerabilities
- Inconsistent naming and no maintainable structure
TOGAF 10 kept the agent on a leash
Each step maps to a phase of the ADM. The agent did the volume; the method decided what it was allowed to do, and when.
- 01TOGAF · Preliminary · Phase A
Guardrails before code
Three principles every AI agent had to work within. They turned the agent from a code generator into a disciplined analyst.
- Zero infrastructure lock-in: no Windows Server, no IIS. Linux, Kestrel, Docker.
- Discovery before transformation: in the early phases the agent could not write any .NET 10 code. Its job was to analyse and map.
- Parity and proof as the release gate: nothing takes production traffic until its behaviour and performance are proven, in tests and then against live legacy.
- 02TOGAF · Phases B · C
Discovery from the binaries
With the client's right to do so (they own the copyright), we decompiled the DLLs with JetBrains dotPeek and pointed an AI agent in Google Antigravity at the reconstructed C#. It built the real as-is architecture: an interface inventory with routes, contracts and auth boundaries, a map of every background job and its trigger, and the implicit business rules no document described.
- 20 of 80
- APIs dead or redundant, some bundling up to 10 actions behind one route
- 10
- Public APIs with write access and file upload, never security-reviewed
- Zero
- Traffic in a year on some endpoints, plus conditions that could never be true
- 03TOGAF · Requirements management
An executable baseline
The agent turned the discovered use cases into tests, and the rule was to run them against the legacy .NET 4.6 code first. Whenever the AI misread an edge case, legacy proved it wrong, and we fixed the test, not the system. Once the old system passed 100% of the suite, we had verified facts and a regression gate for everything that followed.
- 500
- Unit tests
- 300
- End-to-end tests across logic and integrations
- 100%
- Passing against legacy before the build began
- 04TOGAF · Phase D · gap analysis
A modernisation, not a port
The gap analysis made the target clear: six domain microservices on Linux containers, real partner security, monitored background work and a hard performance budget. The detail is below.
- 05TOGAF · Phases F · G
Staying compatible with the outside world
Third parties depended on these APIs, so keeping them working became a second project, delivered in three stages. That's where most of the four months went.
What changed
Security
- Secrets moved into Azure Key Vault
- The shared login became OAuth client credentials with JWT and per-partner scopes
- A dynamic access layer: admins grant each partner access by scope and by endpoint, with full visibility
- Base64 uploads became secured multipart uploads, resumable and de-duplicated
Architecture and operations
- Kestrel on Linux in Docker, split by business domain into 6 microservices
- Every background job moved into a monitored .NET hosted service
- Monitoring, structured logging and DevOps pipelines as standard
- No more swallowed exceptions: errors are traceable and clearly described
Data and performance
- Whole-table loads filtered in memory became single SQL queries
- Normalised data, and analytics moved to a read-only replica
- A hard budget of 250 ms per HTTP call
Dependencies
- Outdated and vulnerable libraries removed or replaced
- Packages pulled in for a few lines of work replaced by a small in-house utility library
Measured side by side
Both stacks ran under the same workloads, so these are measurements, not estimates.
From query fixes, caching, cleaner code and dropping IIS.
Against 2 to 2.5 seconds worst case on legacy over the same period.
Resumable multipart uploads, no duplicates, safe to retry.
Consistent naming and endpoints that follow REST conventions.
What the last 1% taught us
The first formal QA run matched legacy 99%. None of the remaining differences were logic bugs.
Behaviour built on workarounds
Quirks that only made sense in context and only showed up at runtime, invisible to static analysis.
Wrong data types
Numbers and dates stored as text.
Time zones
Legacy compensated by adding and subtracting offsets in code, and in places in frontend JavaScript.
We fixed time at the source: dates stored in UTC, date-only fields stored as dates, a few columns migrated. The offset arithmetic was then deleted from backend and frontend alike.
From SharePoint to a progressive web app
The internal website sat on SharePoint and nobody wanted to touch it. We rebuilt it in React as a PWA with a cleaner, brighter design. The bigger win was what employees could suddenly do, after years of juggling email and separate ticketing tools for the same work.
- Works offline
- Push notifications for new, due and late tasks
- One task list ordered by due date
10 days to build, 4 months to go live
Rewriting the code was the easy half. The rest was proving parity, fixing security partner by partner, and moving every external system to the new API.
- 10 working daysBuild
- 1 monthQA and parity
- 1 monthSecurity and permissions
- 2 monthsPartner transition
- Live in productionEvery partner on the new API
Prove parity
The new system ran beside production on fully separate infrastructure, against live data. Each day, pure T-SQL compared both databases down to column level across the ~20 active tables.
Fix security, one partner at a time
A new security layer went in front of the old APIs and each partner moved to client ID and secret. Partners turned out to reach endpoints and data they were never meant to. Refining that took a month and produced the dynamic access management.
Move partners to the new API
Paths renamed to follow best practice and multipart upload made mandatory. The hardest stage, because every external system had to comply.
What we'd tell anyone starting a similar project
- 01
AI compresses the build, not the coordination
The 10 days were engineering. The 4 months were people.
- 02
Discovery first
Most of the value, from dead APIs to open endpoints, came before any new code existed.
- 03
Run the tests against legacy first
That's what makes AI output trustworthy.
- 04
Security cleanup reveals what you were exposing
Expect surprises about who can see what.
- 05
Do it right or don't do it
The full move to the new API structure cost two extra months, and left a clean system instead of a modern runtime hiding old problems.
Rebuild or modernise? Five questions first
Teams often abandon an old system and spend a year rediscovering rules it already enforced. Rebuilding is sometimes right. The mistake is deciding before you've discovered what you have.
- Q1
Can you recover the behaviour?
Source code, or the legal right to decompile, gives you the real as-is system.
- Q2
Is the business logic still right?
If the business has changed shape, rebuild. If the rules are right and the platform is old, modernise.
- Q3
Can you prove parity?
If a test baseline passes against legacy, you can prove every later step.
- Q4
Is the debt in the platform or the design?
Runtime, hosting, security and libraries are fixable. A fundamentally wrong data model is much harder.
- Q5
Can your consumers migrate in stages?
If partners can move one at a time, the risk stays small.
Modernising doesn't mean preserving everything. We cut 20 APIs, redesigned security and changed API paths. What we preserved was the business logic, with proof.
“Enterprise frameworks aren't too heavy for AI-assisted engineering. They're what makes it safe. The conversation moved from ‘how do we replace this?’ to ‘what do we build on it?’”
Sitting on a legacy estate?
Outdated source, security debt, or partners who depend on it: we'll run discovery, prove parity and modernise with the same method.