# 0001. Use Turborepo + pnpm for the monorepo

- **Status:** Accepted
- **Date:** 2026-05-26
- **Deciders:** Loma Group Platform
- **Related:** [`turbo.json`](../../turbo.json), [`pnpm-workspace.yaml`](../../pnpm-workspace.yaml)

## Context

We have multiple frontends (Angular + Next.js), multiple backends (.NET + NestJS), shared packages, and enterprise modules. We need workspaces, parallel task execution, and remote caching potential without locking into a vendor.

## Decision

Use **pnpm workspaces + Turborepo** as the monorepo toolchain:

- **pnpm** for install, workspace topology, dep resolution. Strict + fast + disk-efficient.
- **Turborepo** for task orchestration (`dev`, `build`, `test`, `typecheck`) with file-based caching.

## Alternatives considered

| Option               | Why rejected                                                                                                        |
| -------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Nx                   | More opinionated; harder to migrate away from; we want to keep the door open (the structure here is Nx-compatible). |
| Yarn 4 workspaces    | pnpm has stricter dep isolation + better Windows perf.                                                              |
| Plain npm workspaces | No remote cache; slower; weaker phantom-dep prevention.                                                             |
| Bazel                | Right tool, wrong scale for a small platform team.                                                                  |

## Consequences

### Positive

- Fast incremental builds via Turbo cache (file-input hashing).
- pnpm's `workspace:*` protocol surfaces breaking changes at install time.
- Avoid Turbo-specific runtime APIs in app code — migration to Nx stays possible.

### Negative

- pnpm's strict hoisting trips packages that assume hoisted deps (we pin via `pnpm.overrides` when this happens).
- Turbo daemon occasionally needs a restart on Windows.

### Neutral

- We stay AI-readable: every workspace's `package.json` declares its own deps + scripts; no hidden plugin magic.

## Compliance

N/A.

## References

- pnpm docs: https://pnpm.io
- Turborepo docs: https://turbo.build
