All posts
Architecture

One question decides where code lives

21 Sept 20263 min read4 views
One question decides where code lives

This note is about modular architecture and the one question that keeps it. In a platform with many capabilities, the hardest technical question usually isn't "how do I write it" but "where does it go". However, without a clear answer, a year later everything depends on everything and no capability can be sold or switched off on its own.

In fact, in SimaCMS the answer to that question is another question.

"Could a site be without it?"

If yes, it's a separate capability (a module): store, bookings, online courses, restaurant, attendance. Therefore each has its own Go package under internal/ and its own frontend under web/modules/. If no, it belongs to the chassis, what every site needs: sign-in, payments, wallet, notifications, media, and knowing which site a request belongs to.

The line that keeps a modular architecture

The main rule: a capability never imports another capability. The store doesn't know bookings exist. If two capabilities need the same thing, it's a contract the chassis declares and the capabilities register with.

For example, the store, bookings and courses all take money. None implements a payment gateway itself, and none names the others. The chassis has a payment contract; each capability says "I have something to sell, here's the amount, call this when it's paid".

In addition, the reverse matters: the platform never names a module. The core must never say "if the store is on, do this". Modules keep their own settings, notifications, permissions and page-builder blocks in their own folder and introduce them to the platform.

A guard that catches it

These rules aren't just on paper. A CI guard reads every Go package's imports, and if one capability reaches another the PR is refused. Besides, another guard checks that the core names no module. A third rule: every database table has one writing package, and the rest use that package's API.

Why it pays

  • Sold separately: a site that bought only bookings runs without the store, with no dead store code in its path.
  • Piece-by-piece rewrites: when I moved the backend from Laravel to Go, capabilities moved one at a time, because they weren't tied together.
  • Agents in parallel: two agents can work on two capabilities at once without stepping on each other.
  • Quick decisions: when a new capability arrives, "where does it go" takes a minute, not a meeting.

In fact, whenever a piece of code has no obvious home, it usually means we don't yet know whose it really is. That one simple question usually makes it clear.

A modular architecture does not last without a guard; Static guards instead of endless tests shows how. For the same line in data, read site_id everywhere. The underlying idea is classic modular programming.

Comments

Sign in to leave a comment.

Sign in

Loading…

Related posts