Email copiado — support@tuurt.com
Cargando experiencia
consultoria · October 27, 2026 · 7 min

Rewrite or extend: the technical signals we check before telling an SMB to rewrite its backend

The instinct is always to rewrite everything. We explain which concrete technical signals -not opinions- justify extending, rewriting a single module, or, in specific cases, rewriting the whole system.

By Tuurt Team

Rewrite or extend: the technical signals we check before telling an SMB to rewrite its backend

When an SMB shows us an old, slow backend, the first reaction is almost always the same: "throw it out and start over." It's an understandable reaction -the code has variable names in three different languages, business logic is buried inside controllers, and nobody on the current team wrote half of what's in there- but a full rewrite is the most expensive and riskiest thing you can propose, and most of the time it isn't necessary. The real work isn't choosing between "rewrite" or "don't rewrite" as if those were the only two options. It's identifying which concrete technical signals justify which level of intervention, because between an untouched backend and a full rewrite there's a wide space that's usually where the right answer actually lives.

The signal that matters most isn't the code's age, it's coupling

An old backend with clear boundaries between its modules -where billing code doesn't know the internal details of inventory code, even if both live in the same process- is a strong candidate for extending, no matter how many years it's been running. The real problem that pushes toward a rewrite isn't that the code is old, it's that you can't change one part without risking breaking another part that has no apparent relationship to it. That signal shows up very concretely when you try to estimate the impact of a small change: if adding an optional field to an entity means manually tracing through fifteen files because there's no layer isolating that entity from the rest of the system, the problem isn't the code's age, it's the absence of boundaries.

We check this by looking at circular dependencies between modules and how many classes or files need touching for an isolated change. If the internal dependency graph has cycles -the orders module imports from the users module and the users module imports back from the orders module- there's no real boundary between the two, even if they live in separate folders. That signal, more than any generic code-quality metric, is what makes us think about a serious intervention. But a serious intervention isn't synonymous with a full rewrite.

When extending is still the right call

If the system works, has reasonable boundaries between its main parts, and the problem is specifically slow to develop or fragile in a bounded area, extending still wins. The tool we reach for most often here is an adapter layer between the old code and the new code, instead of touching the old code directly:

public interface IInventoryRepository
{
    Task<Product> GetBySku(string sku);
    Task UpdateStock(string sku, int quantity);
}

// Adapter that wraps legacy data access without modifying it
public class LegacyInventoryAdapter : IInventoryRepository
{
    private readonly LegacyDataAccess _legacy;

    public LegacyInventoryAdapter(LegacyDataAccess legacy)
    {
        _legacy = legacy;
    }

    public async Task<Product> GetBySku(string sku)
    {
        var record = await _legacy.QueryLegacyProduct(sku);
        return new Product(record.Code, record.Desc, record.Stock);
    }

    public async Task UpdateStock(string sku, int quantity)
    {
        await _legacy.UpdateLegacyStock(sku, quantity);
    }
}

This pattern lets new code -an API, a service, a whole feature- get built against a clean interface, without the old system needing to be touched or fully understood. The cost of this approach is that the adapter introduces an extra layer, and if the legacy system changes its internal behavior in unexpected ways, the adapter can hide that change instead of surfacing it. That's why we cover the adapter with integration tests against the real legacy system, not against a mock, before building anything on top of it.

When a full rewrite is actually justified

There's one case where a complete rewrite stops being an overreaction and becomes the right call: when the system depends on a platform or language that no longer has support, maintenance, or available talent to work with it, and that dependency runs through the entire system without exception. In that scenario there's no module you can isolate with an adapter, because the problem isn't one fragile module, it's the entire foundation everything else is built on. At that point the question stops being technical and becomes one of business continuity: if nobody in the market can maintain that platform in the medium term, continuing to extend it just accumulates risk without resolving it.

The other legitimate case is when the original data model doesn't represent the current business and every new feature requires working against the model instead of with it -tables that mix concepts the business already split apart long ago, relationships that force you to duplicate information just to make the application work. There, an adapter solves nothing, because the problem isn't on the system's surface, it's in the foundation.

Partial rewrite of a single module: the middle ground that solves more cases than it seems

Between extending everything and rewriting everything is rewriting the specific module where the problem is concentrated, leaving the rest of the system untouched. This works when you can identify a real boundary of responsibility -not a file, a whole domain- that can be replaced without the rest of the system noticing the difference, as long as the contract that module already exposes outward is respected.

The pattern we use here is the strangler fig: put traffic behind a single entry point, route to the old module by default, and move specific routes to the new implementation one at a time, without an abrupt cutover:

app.use('/api/billing', (req, res, next) => {
  const usesNewImplementation = alreadyMigratedRoutes.has(req.path);
  if (usesNewImplementation) {
    return newBilling(req, res, next);
  }
  return legacyBilling(req, res, next);
});

This lets you measure the new implementation's behavior in production against real traffic, route by route, before switching off the old implementation entirely. If something goes wrong with a migrated route, rolling back is changing one entry in alreadyMigratedRoutes, not a full deployment rollback.

What didn't work the first time

The first time we applied this strategy, we assumed the old module's contract was fully documented in its public API, and we wrote the new module against that documentation. It wasn't: the old module had an undocumented edge case -a field that, when it arrived empty, was interpreted as "use the default value from the last saved configuration" instead of as the absence of a value- that none of the current developers knew about, because it had gone untouched for years and nobody had ever questioned it. The new module treated that empty field as a genuine absence, and a migrated route started behaving differently for a subset of cases without any test catching it, because the tests didn't know about that edge case either. We found it by reviewing discrepancy logs between the old module's response and the new one's for the same request -a comparison we started running in parallel precisely because of this experience, before trusting a migrated route.

What we check before proposing a rewrite

Before proposing that a client rewrite any part of their backend, we first confirm whether the problem is coupling or platform, because a coupling problem is almost always solved with an adapter layer, not a rewrite. If the problem really is platform or data model, we first look for whether it can be scoped to a module with a real boundary of responsibility, because there a strangler fig resolves the risk without the cost of a full rewrite. And in any partial rewrite, we run the new implementation in parallel with the old one against real traffic before switching the old one off, comparing responses, because the legacy system's documentation never tells the full story of what that system actually does.

backend architecture legacy smb
← Back to blog