If you've ever opened a file to fix a bug and spent forty minutes just figuring out where the bug lives, this post is for you.

Not because the bug was hard. Because the code had no home.

I've been the sole frontend developer on a sports data platform serving 5+ professional sports clubs. I've worked on this codebase for a few years now, across everything on the frontend — auth flows, build configuration, product features, UI design implementation. When I joined, there were other developers on the team. By the time this refactor started, it was just me.

One of the things I was working with was a file called constant.js with 7,558 lines in it. That number tells you everything you need to know about the state of things.

This is what I did about it, the decisions I made along the way, and what I'd share with anyone facing something similar.