StoicBuilder

HandbookXV the PantheonModules and boundaries

XVthe Pantheon, Design the system

Modules and boundaries

1 min readUpdated 28 November

In plain words

A module boundary is a line inside one codebase where a part, such as billing, exposes a small public interface and keeps its tables and internals private, so other parts can't reach in.

Where you see it

In Harbor's codebase, the deploys code imports billing's database models to check a customer's plan. When billing renames a column, deploys break. Giving billing one exported function, getPlanFor(accountId), and banning other imports stops that happening again.

modules/billing/index.tsserver
// the only door into billingexport { getPlanFor, startCheckout } from "./service";export type { Plan } from "./types"; // eslint config: other modules may import billing, never its insides"no-restricted-imports": ["error", { patterns: ["@/modules/billing/*"] }]
Billing chooses what to expose. The lint rule turns the boundary from a convention into a check that fails CI.

What goes wrong

  1. Sharing tables across modules

    When deploys queries billing's subscriptions table directly, billing can't change its own schema without breaking someone. Each module owns its tables, and others ask through its interface.

  2. Boundaries that exist only as folder names

    Folders called billing and deploys mean little if any file can import any other. Enforce the rule with a lint or dependency check in CI.

  3. A shared utils folder that knows everything

    A common folder that slowly collects business rules becomes the thing every module depends on and nobody owns. Keep shared code generic, such as dates and formatting, and move business rules to the module they belong to.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Map which modules in this codebase import from which, and list every place one module reads another's tables or internal files. Propose a public index file for each module, route cross-module calls through it, and add a lint rule in CI that fails on imports into another module's internals.

Quick check

Sign in to earn +10 XP for it

Harbor's deploys module reads billing's subscriptions table directly. Billing renames a column and deploys break. What's the lasting fix?

Got a prompt that touches modules and boundaries?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.