Where things go in the Garage

garage

We have an overview of the Forge. Here we ask the question that follows when we add something: where does it belong? A labelled drawer helps only if we put the right thing in it. We have tried the other arrangement.

Ask what the code knows

We start with a distinction: does this code have an opinion about what a thing is?

A part does one job without knowing the domain it serves. Code that truncates text need not know whether the text is a conversation or a document. We put shared parts under parts/<bin>/<name>. The bin groups related parts; it holds no shared code of its own.

A system combines parts and makes decisions about its subject. Memory, for example, has to decide how its storage and retrieval fit together. That assembly belongs under systems/<name>. Helpers belonging to that system can live beneath it. A system can also use another system; we need no additional level for that.

An app is the outermost assembly plus a way to reach it, under cmd/<app>. We ask whether it needs its own way in after settling what the code does. Running as a separate service is a deployment choice, not another structural level.

A small placement exercise

Suppose we are adding a feature that remembers a long document. Splitting text into smaller pieces does not require knowing what a memory means: we first look for an existing text part. Deciding how those pieces are stored, searched and combined is the memory system's work. The app connects that capability to the person using it.

If another real consumer later needs some of that combining logic without the rest of memory, we can extract it into a reusable part and update its callers. We do not invent a shared abstraction for a consumer we merely expect. Different choices of parts can be parameters; different behaviour may justify another system.

Leave it findable

We record parts and systems in the catalogue. App architecture guides explain what is particular to each app and point to shared documentation beside the code. A design document describes intent; it still needs checking against implementation before we call a feature built.

One job each explains focused model roles. Here the responsibility belongs to code: we choose its place by what it knows and decides, rather than its size or number of callers.

Sable