advanced · 26 minute study
Share a contract without making everything depend on everything
A monorepo can make shared rules easier to change consistently, but a folder called packages does not automatically create good boundaries.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- Read package.json as an executable project contract — A repository is more than source files. Its runtime, dependencies, lockfile and scripts determine whether another engineer can reproduce its behavior.
First, build a mental model
An application assembles behavior for users. A package exports a cohesive contract for consumers. Dependency direction tells you what must be understood or changed together.
- npm workspaces let one repository declare related local packages. Each package still needs a clear purpose, public entry points and explicit dependencies.
- Prefer a domain package that accepts facts and returns results without importing application screens. Presentation and infrastructure can depend on shared rules without the rules depending on every consumer.
- Imports through stable public exports keep consumers away from accidental internals. Dependency cycles make initialization, testing and change impact harder to reason about.
- A shared change must be checked in the package and its affected consumers. Not every project needs a monorepo: a cohesive single application can retain simpler structure until real reuse justifies more boundaries.
{
"name": "synthetic-workspace",
"private": true,
"workspaces": ["apps/*", "packages/*"]
}
- Consumers
A shop interface and a CLI can call the same reviewed order-rule contract.
- Dependency direction
Both applications depend on order-rules; order-rules does not import the shop's UI state.
- Change impact
Updating the shared contract requires checking both consumers, even if only one initially requested the change.
Production thinking
Take this beyond the example.
The audited production reference uses multiple applications and shared packages; LearnLab is a useful contrasting single-application example. Teach dependency direction using synthetic contracts instead of copying private implementation.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Deploy the artifact you actually verified →