← All chapters

Chapter 02 · Technical

Building for the Weight of Scale

202610 min

Not long ago I read the story of a fintech platform that had to declare bankruptcy. What struck me was not that it failed, but why it failed. It wasn't for lack of customers. Customers were the one thing they had. They failed because they scaled up too much, too quickly, on top of an architecture that was never built strong enough to carry that weight. The demand arrived, and the foundation buckled under it.

I have thought about that story more than once while building StockLens. It is, in a strange way, the perfect cautionary tale for everything I believe about building infrastructure: that the ability to handle scale, and the trustworthiness a serious platform demands, cannot be things you bolt on later, once the users show up. They have to be inherent properties of the design from the very first night. This chapter is about that year, the design decisions behind it, and the lessons I carry from them.

The confession most AI builders won't make

Let me start with something that might sound strange coming from someone building an AI-native finance platform.

StockLens is roughly a year old now. It spans thousands of code files, and I mean files, not lines of code. And in all that time, I have not put a single model I trained myself into production. I experimented, of course. I trained a few things to test whether certain capabilities were even possible. But nothing I trained has gone live. For those of us who come from the AI world, training your own models is the juiciest part of the craft. It's the part we love to talk about. So to build an AI-native platform for a year and not lean on that is, in its own way, a design decision, and one of the most important ones I made.

Because the truth I kept running into is this: intelligence is cheap to invoke and expensive to trust. The hard problem was never "can the model produce an answer." The hard problem was building an architecture around that intelligence robust enough that the answer could be trusted, retrieved instantly, and reproduced under scale. That is where the year actually went.

The first night, and a wall called 403

When I started, I had no idea how much design complexity this would demand. I found out fast.

The very first night, sitting down to build the thing that would feed the entire platform (the parsers that pull data from the sources that matter), I hit a wall. Most government websites simply refuse to let a parser through. They throw a 403 back at you. Anyone who has worked close to the network layer knows exactly what that means: the server could not identify you as a credible, legitimate source of the request, so it shut the door before the conversation even began.

That first night I hit the wall. The next day, the same. The day after that, the same again. And somewhere in that third day of getting the door slammed in my face, I decided I wasn't going to keep improvising around it. I was going to roll up my sleeves and solve it properly, at the level of architecture rather than as a patch.

That is where the three-stage handshaking architecture came from. Instead of pretending to be something I wasn't, or brute-forcing my way past the gate, I designed a structured, staged handshake that establishes credibility the way a legitimate client is supposed to. It plays a critical role in every parsing engine StockLens runs today. And I'll admit something: I enjoy problems like that. The kind where the obvious approaches all fail and you have to sit with the problem long enough to see the shape of a real solution. That first wall set the tone for everything after it.

Probabilism filling determinism

Once the data could actually get in, the deeper question emerged, and it followed me through every layer of the system: how do you make something built on probabilistic intelligence behave in a way you can depend on?

My answer became a principle I now design around everywhere: determinism as the frame, probabilism as the fill.

I made a deliberate choice to build StockLens as a system of deterministic engines. From data ingestion to cross-server communication, from data processing to the data foundation, up through the engines and the agents (hundreds of layers, each with its own custom architecture), the backbone is deterministic. Predictable. Reproducible. And then, at the precise points where genuine intelligence is needed, probabilism fills the gaps that determinism alone can't reach.

I find this genuinely fascinating. Probabilism, when poured into a deterministic frame rather than left to run loose, can solve some of the most complex problems there are, because the determinism guardrails the intelligence. It gives the intelligence somewhere to stand. Left unbounded, a probabilistic system drifts and surprises you. Bounded inside a deterministic structure, that same intelligence becomes something you can build a platform on.

But I won't pretend this was easy. Working with deterministic engines has its own hard failure modes. Drift is common: the slow divergence of behavior from what the design intended. Missing concept linkage is common too: the places where one layer's understanding fails to connect cleanly to the next. The determinism has to be carried deliberately across every layer; it isn't something you establish once and forget. Let your attention slip at one boundary and the guarantee you thought you had quietly evaporates.

The nights that became v3

Carrying that discipline across the whole system came at a cost, and I paid it in nights and in weeks.

There were stretches where I had to completely revamp the core of these engines, not tune them, not patch them, but tear the center out and rebuild it because I could see it would not hold the way I needed it to hold. That is not comfortable work. It's the work of undoing something that already functions because you know "functions" is not the same as "will survive scale." Today, StockLens's core architecture stands at v3. The two versions behind it are the record of every time I chose to rebuild rather than paper over.

Through all of it I kept two things at the very top: correctness and robustness. And I kept them there even before launch, which I know isn't the fashionable order of operations. The pressure is always to ship first and harden later. But I had that bankrupt fintech in the back of my mind. I knew that when a platform like this scales, the architecture has to embrace the scale rather than break under it, and you cannot retrofit that property once the load is already on top of you. So every design decision, from the very beginning, was made as if the scale had already arrived.

Millions of artifacts, answered in under a second

That patience is now visible in the numbers, and the numbers are where the design proves itself.

Across multiple on-site and cloud servers, StockLens has produced somewhere north of 18 million intelligence artifacts. It has processed hundreds of thousands of cards. And here is the part I'm proudest of: a user still gets their answer, drawn from those millions of artifacts, in under a second.

That is not an accident, and it is not the database being generous. It's what I designed The Heart Retrieval Protocol for. Its entire job is to keep retrieval time complexity linear and sub-second even as the artifact count climbs into the millions. Scale is supposed to punish you here: the more you have, the slower it gets, in the naive design. The Heart Retrieval Protocol is my refusal to accept that trade. The system can hold millions of artifacts and still find the right one for you as if it were holding a handful.

Underneath that sits the problem of moving heavy data across the infrastructure I built, between my secondary and primary servers. Big payloads over a network pipeline are their own kind of fragile: they stall, they fail halfway, they choke the pipe. So I built the OSAMA protocol (Oversize Split And Merge Algorithm) to handle exactly that. It splits oversized data on one side, moves it cleanly across the pipeline, and merges it faithfully on the other, so that heavy transfers stay smooth instead of becoming the weakest link in the system.

Built by hand, on purpose

There's a thread running through all of this that I want to name directly: I designed and built these systems myself, with no external dependency.

The security system is the clearest example. StockLens's security is designed so that it becomes genuinely difficult for bots to harvest its data, which, for a data platform, is not a feature, it's a matter of survival. And like the rest of it, I built that myself rather than reaching for something off the shelf. That choice costs more up front. It costs the nights. But it means I understand every layer of what protects the platform, and there's no black box in the critical path that I can't reason about or repair.

The point of the story

So why tell all of this?

Because the lesson underneath every one of these decisions is the same one that fintech learned too late. When you are building an infrastructure platform, trustworthiness and the ability to handle scale are not features you add once the users arrive. They are inherent properties of the design, or they are absent, and no amount of later effort truly puts them back. The three-stage handshake, determinism filled with probabilism, the rebuilds down to v3, the Heart Retrieval Protocol, OSAMA, a security system built by hand: none of these were reactions to a crisis. They were bets placed early, at real cost, on the day the scale would come.

There is no shortcut around that cost. It takes the nights, the revamps, the discipline of carrying a design principle across hundreds of layers without letting it slip. But that is exactly the point. The platforms that survive their own success are the ones that were built, from the first night, to embrace the weight, not to discover, once the weight is already on them, that the foundation was never poured deep enough.

A year in, that's the lesson I'd hand to anyone starting the same kind of climb. Build for the weight before you can feel it. By the time you can, it's already too late to change the foundation.

One year on

A year on, I watch this beast eat thousands of documents, produce millions of intelligence artifacts, and run as smooth as a lion. When I look back (the thousands of code files, the hundreds of layers of deterministic engines, the verification layers, the self-evolving data foundation, the SL Newton and its OS), I know we are pointed in the right direction.

From here on, I'll share the story each time we reach another milestone. Because today StockLens is not a single product; it is a data foundation that can power countless products. It is still improving, and you will see the wonders of this technology soon.