Like home
Why I keep my code in the shape I do, from a login system I couldn’t reuse to a repository the agents can find their way around.

On the second night of Çənlibel, everything sat in one crate doing five jobs at once. So I brought in the architecture I had built before the game, and Claude sorted the code into it. I wrote about that night in The meat grinder.
I only arrived at this architecture about a year ago, but the thinking behind it goes back much further.
One thing that used to frustrate me when I started a new project was having to build something I had already built.
Authentication is the one I remember best. I had a registration and login system in another product. It worked. But so much of that product was baked into it that using it again meant spending a lot of time taking the product out.
So the next time I built one, I made it easier to reuse. Then it just kept going: the same frustration, the same fix, and new tools opening up new ways to do it.
I only realised this today, but I guess I was just trying to make my future self happier.
A place of its own
Ten years ago, reusing code for me meant copying it from one project to the next. I did that more times than I can remember, until I thought: why don’t I write reusable fucking code, something I can import into anything I do? So I made libraries out of whatever I could reuse and gave them a repository of their own, separate from the products.
But sometimes another product needed a much bigger piece than a library, and that’s how I got to microservices. For a while I loved them. Scaling wasn’t what interested me. What sold me was a piece of software that could outlive the product it was made for.
One of my products was a single NestJS app, nicely modular inside, with a folder for each module. When a second product came along, I turned those modules into microservices. Each service was generic and took its settings from outside, so both products could run the exact same image, each with its own configured instance. There were fifteen or so in the end, and each product had its own client and gateway on top, bringing those services together in its own way.
Managing all those separate services and repositories, deploying them, waiting for builds, it was exhausting. And for no reason. So I brought everything into one repository. I had a lot to bring in, so I tried Nx, for the tooling that makes a monorepo easier to manage. While I was trying it, I liked its idea of a thin apps folder with the libraries beside it.
I started with the front end and split it into libraries, data access, UI and so on, and the services were meant to follow. I was experimenting: I made every piece of the front end generic, with a product flavour on top, as if all of it would be reused one day for free, even though I was really working on one product. I had so many front-end libraries it was disgusting. But if I hadn’t tried it, I wouldn’t know I don’t want to split things that way. The services I left alone. For now, each of them found its place under apps/microservices/*, in the folder that was supposed to stay thin.
My next product got a repository of its own, and I didn’t move the old services into it. The plan had always been the front end first, then the server. The front end hadn’t worked out, but I still wanted to get the server right, so this time I started there, because that’s where the program really is.
Before I wrote it, I looked at everything the last product had: what it could do, its services, how its code was laid out, down to the kinds of files, a .service here, a .controller, a .component, a .model there. I knew the new one would grow much bigger. So I asked myself: with the same kind of building blocks, but many more of them, how would I arrange them? We wrote the answer down as a decision before the product grew, and that’s how this architecture started. What I liked in Nx grew into a thing of my own. It didn’t arrive in one go. One of the main things I was trying to avoid all along was a tangle of dependencies. I kept asking where each thing belonged: the models, the contracts the parts share, the different domains, the products on top. Somewhere along the way, the shape of those responsibilities settled. Only then did I go back to the front end. Those responsibilities weren’t about servers or clients, or about technology at all, and I could find the same ones in the front end. So the client and the server ended up in one structure.
Inside a product I’m free to do what I like. When a second product needs something the first one already has, that’s when I know what the shared code should look like, and I give it a place of its own. And if one day some of it needs to run as a separate service, I can still do that. So I got what I wanted from microservices.
At home
What I always loved about a well-organised repository was knowing where everything belonged. I didn’t have to remember where something was, because I could work out where it had to be. Most of the time I didn’t even look around. I pressed Command-P in VS Code and typed.
It felt like being at home. You know where the kitchen is, where the coffee machine is, and everything is where you expect it to be.
I don’t do that anymore. Now I just talk to the agents. But I still shape the repository the way I did when I was the one searching for files. We took those lessons and turned them into rules and checks, so I don’t have to reason through them every time, and neither do the agents.
I haven’t told you what the architecture looks like yet. That’s for another post. It isn’t perfect. It needs exceptions, like everything else, and what matters is how you deal with them.