Monorepo Basics (When It Helps, When It Hurts)
On this page
What Is a Monorepo?
A monorepo is a single repository containing multiple packages or services. Instead of separate repositories per service, everything lives in one structured codebase.
Typical Structure
apps/ api/ worker/ packages/ shared-utils/ config/ package.json
Why Use a Monorepo?
- Shared code without publishing packages
- Unified dependency management
- Atomic cross-service changes
When It Makes Sense
- Multiple services sharing business logic
- Shared TypeScript types
- Unified deployment pipelines
When It Does Not
- Very small projects
- Completely independent services
Workspace Support
npm supports workspaces:
{
"workspaces": [
"apps/*",
"packages/*"
]
}
Benefits
- Single lockfile
- Consistent dependency versions
- Simpler local development
Risks
- Large repository size
- Slower installs
- CI complexity
Production Insight
Monorepos improve consistency but increase coordination cost. Choose based on team size and system complexity, not trend popularity.
Next Step
Next we will discuss project structure inside a single service and how to organize modules cleanly.