Architecture × developer experience · Lead Software Engineer, Apna.co

NX Monorepo Migration

I drove the frontend-wide move to an NX monorepo: one toolchain, 120K+ lines of dead code deleted, and cold builds cut from 42 minutes to under 2.

minutes per cold build
42 → 2minutes per cold build
faster builds
95%faster builds
lines of code removed
120K+lines of code removed
faster hot reload
5×faster hot reload

Cold build · race

SBefore · separate repos
FAfter · NX monorepo

Proportional replay: 42 min shown as 8 s. The fast train gets in 21× sooner.

Cold build time went from 42 minutes to under 2 minutes after the NX monorepo migration.

01 · Problem

What was wrong

Every frontend change waited on a 42-minute build. Apps had drifted apart — duplicated utilities, divergent configs, code nobody used but everyone compiled. The cost wasn't one broken thing; it was a tax on every ticket on its way to production.

02 · Ownership

What I owned

  • Drove the migration across the frontend: plan, sequencing, rollout, and buy-in.
  • Removed 120K+ lines of dead code as part of the move.
  • Unified build tooling onto one NX workspace.
  • Kept feature delivery running while the migration landed.

03 · Decisions

Choices and why

  1. Decision 1

    A monorepo with task caching, not faster machines

    Most of the 42 minutes was rebuilding things that hadn't changed. Caching and affected-only builds remove the work instead of running it faster.

  2. Decision 2

    Delete before you move

    Migrating code nobody uses is pure cost. Cutting dead code first shrank what had to move and showed which apps were still alive.

  3. Decision 3

    Migrate incrementally

    A big-bang switch would have frozen feature work. Moving piece by piece kept product teams shipping throughout.

04 · Evidence

Measurements

Measured results
Cold build42 min → under 2 min
Hot module reload5× faster
Codebase120K+ lines removed

05 · Results

What changed

  • Builds 95% faster — the slowest step of the day became a non-event.
  • Hot reload 5× faster, so the edit-and-see loop is short enough to stay in flow.
  • A smaller, single codebase with one set of tools to maintain.
  • NX
  • TypeScript
  • React
  • Next.js
  • Webpack
  • CI/CD

← Back to the platform