Phase 02
The Monorepo Mental Model
Repository, workspace, package, application, dependency graph, and
why TaskFlow uses one repository without becoming one giant process.
Book 1 - Concepts
Course baseline: September 17, 2026 - Windows-first - Project-driven - Production-oriented
The Monorepo Mental Model
Before we create files, we need precise language. Most monorepo confusion comes from using repository,
workspace, project, application and package as if they mean the same thing. They do not.
One repository, multiple projects
A monorepo is one version-controlled repository that contains multiple related projects. pnpm calls the
package-management layer a workspace. Git knows about files and commits; pnpm knows which package.json files
belong to one dependency graph.
Repository vs The .git directory makes taskflow a Git repository. pnpm-workspace.yaml makes
workspace the same folder a pnpm workspace root. One folder can be both, but the
responsibilities are different.
Repository and workspace are overlapping concepts
Git repository same root pnpm workspace declares Workspace packages
contains contains
Figure 1 - Git owns history; pnpm owns the multi-package dependency workspace
Four words you must separate
Term Meaning in this course
Repository The entire taskflow folder tracked by Git.
Workspace The pnpm-managed set of packages declared by pnpm-workspace.yaml.
Application A deployable product such as apps/web or apps/api.
Package A directory with its own package.json that participates in the workspace. An app is also a
package from pnpm's perspective.
Why one repository for TaskFlow?
The frontend and backend are separate applications, but they evolve together. A single repository lets one commit
represent a coherent system change: an API contract update, the matching frontend change, and any shared
validation change can be reviewed together.
•
One version-control history for related full-stack changes.
•
One workspace lockfile for consistent dependency resolution.
•
One place for repository-wide scripts and policy.
•
Easy local linking when a real shared package appears later.
•
A clear boundary between deployable apps and reusable packages.
Why not one giant application?
A monorepo does not mean one runtime process. Next.js and NestJS will remain independent applications with
different ports, build outputs, environment variables and deployment targets. They share a repository, not a process.
Repository unity does not erase runtime boundaries
taskflow repository
contains contains
apps/web - Next.js apps/api - NestJS
build/deploy build/deploy
frontend deployment API deployment
Figure 2 - One Git history can contain multiple independently deployable applications
The root is a control plane
The root package.json should coordinate the workspace, not become a dumping ground for application
dependencies. React belongs to the web package. NestJS belongs to the API package. A formatter or
repository-wide build orchestrator may eventually belong at the root because it acts across packages.
A useful ownership question
Which package imports this dependency at runtime or build time? If the answer is apps/web, install it there. If
the answer is apps/api, install it there. If the tool genuinely coordinates the entire repository, the root may own it.
apps/ versus packages/
Directory Responsibility Examples later
apps/ Deployable or runnable applications web, api, worker
packages/ Reusable code/config used by more than one validators, shared types only when earned
workspace package
The dependency graph is the architecture you can compile
Once packages depend on one another, the workspace becomes a graph. Healthy graphs point toward reusable
foundations rather than creating cycles.
GOOD
apps/web ----> packages/validators <---- apps/api
BAD
apps/web ----> packages/shared ----> apps/api ----> apps/web
Cycle warning pnpm can detect cyclic workspace dependencies. A cycle usually means
responsibilities are mixed. Do not hide the warning; inspect which package
should stop depending on which other package.
Volume 01 - Engineering Foundation
One lockfile, strict declarations
pnpm workspaces use a shared lockfile by default. That gives the repository one exact dependency-resolution
snapshot while still keeping each package honest: a package should only access dependencies it declares in its own
package.json.
This matters because a monorepo should make dependency boundaries more visible, not less visible.
When a monorepo is the wrong tool
•
Projects have unrelated release cycles, ownership and security boundaries.
•
Teams cannot share repository access for compliance reasons.
•
The repository becomes a dumping ground for unrelated experiments.
•
Tooling complexity exceeds the coordination benefit.
TaskFlow is a good fit because the web and API are parts of one product and will share contracts, versions and
learning checkpoints.
Mental-model checkpoint
•
Git repository != pnpm workspace, even when they share the same root folder.
•
A workspace package has its own package.json.
•
An application is a package with a deployable runtime responsibility.
•
The root coordinates; it should not absorb every dependency.
•
Shared packages are introduced by reuse pressure, not by folder aesthetics.
Volume 01 - Engineering Foundation