The Quest Begins (The "Why")

I still remember the first time I opened a legacy repository and saw a singleProcessOrder.js218 lines long, had nestedifs, a couple offor` loops, and comments that read “TODO: fix this later” from 2015. I needed to add a new loyalty‑points feature, and the moment I touched that file I felt like Neo staring at the green code rain — except instead of seeing the underlying truth, I saw a tangled mess that made my brain hurt.

Every time I tried to understand what the function did, I had to keep a mental stack of what state variables were being mutated where. A tiny change to the tax calculation forced me to scroll up and down, hunting for the right block, and I still managed to introduce a bug that gave customers a 100 % discount on their first order. Yeah, that was a fun production incident.

The pain point was clear: the function did too many things, and its intent was hidden behind a wall of procedural noise. If I kept working like this, I’d spend more time debugging than delivering value. I needed a way to turn that monolith into something I could reason about, test, and actually enjoy working with.

The Revelation (The Insight)