# Keep two products in one monorepo apart with FACET

> Give each product in a monorepo its own set of FACET records, a registry, write each product's rule under a shared feature id, and ask before every commit which product's rule a change touches.

Source: https://facet-framework.com/en/guides/two-products-in-one-monorepo/  
Last updated: 2026-11-22T21:10:21+01:00

Support asks for a longer refund window. A developer searches the repository for "refund", finds `REFUND_WINDOW_DAYS = 30`, changes it to 45 and opens a pull request. The request was about the back office, the internal tool where support staff refund orders. The constant belongs to the customer shop, which lives in the same repository. Two products, one word, and nobody in the review noticed which product the change hit.

FACET keeps a short, checkable description of each feature, called a record, next to your code and checks that the two still match. By the end of this guide each product has its own set of records, and FACET tells you which product's rule a change touches before you commit it. The FACET feature behind it is registries: a registry is one product's set of records, declared in `.facetrc.yaml`, FACET's configuration file, and each registry owns its own source folders.

The commands below use a small example shop written in TypeScript, set up as in [“One answer instead of three”](https://facet-framework.com/en/guides/write-down-what-a-feature-does/). Its repository holds a second product: a back office for the support team in `apps/admin/`. In your own monorepo, use your apps' folders instead.

## Check that you really have two products

Ask one question about a feature: "does this exist over there yet?" If the question makes sense, you have one product built twice, such as a web app and a native app, or an old system and its rewrite. That is a different case; FACET calls it variants. If the question makes no sense, because nobody asks whether the back office has the shop's checkout, you have two products. Then each product gets its own registry.

In the example, the shop has a cart, discount codes and checkout. The back office has staff refunds and, planned, discount-code management. Both have something called refunds, with different rules.

## Declare one registry per product

Create `.facetrc.yaml` in the repository root:

```yaml
registries:
  shop:
    records: docs/facets
    sources: [src, tests]
    description: the customer-facing web shop
  admin:
    records: apps/admin/docs/facets
    sources: [apps/admin]
    schema: docs/facets/schema
    description: the internal back office for the support team
```

- **`records`** is where the product's records live. The shop keeps the folder it already has.
- **`sources`** lists the folders that belong to the product. Code there is checked against this registry's records only.
- **`schema`** points the back office at the schemas `facet init` already wrote, so its records are validated too.
- **`description`** says in a few words what the product is, for people and coding agents reading the configuration.

Create the back office's record folders:

```sh
mkdir -p apps/admin/docs/facets/features/orders/refunds apps/admin/docs/facets/features/checkout/discounts
```

## Write down each product's rule under the same id

The refund feature exists in both products, so it gets the same id in both: `orders/refunds/refund-order`. Ids are shared across registries. Each product writes its own record for it.

Save the shop's rule as `docs/facets/features/orders/refunds/refund-order.yaml` (create the folder with `mkdir -p docs/facets/features/orders/refunds`):

```yaml
schema_version: "0.1"
id: orders/refunds/refund-order
lifecycle: active
intent:
  summary: A customer asks for a full or partial refund within 30 days of delivery and gets the money back the way they paid.
contract:
  scenarios:
    - id: within-30-days
      statement: |
        Given an order delivered 20 days ago
        When the customer asks for a refund
        Then the refund is accepted
    - id: after-30-days-is-refused
      statement: |
        Given an order delivered 31 days ago
        When the customer asks for a refund
        Then the shop refuses it with E3001
    - id: gift-card-as-store-credit
      statement: |
        Given an order paid with a gift card
        When the customer gets a refund
        Then the money comes back as store credit
lineage:
  owner:
    team: checkout
  created_at: "2026-11-22"
```

Save the back office's rule as `apps/admin/docs/facets/features/orders/refunds/refund-order.yaml`:

```yaml
schema_version: "0.1"
id: orders/refunds/refund-order
lifecycle: active
intent:
  summary: Support staff refund an order at any time, with a reason, up to the amount the customer paid.
contract:
  scenarios:
    - id: late-refund-with-reason
      statement: |
        Given an order delivered 45 days ago
        When a staff member refunds it and gives a reason
        Then the refund is recorded with the reason and the staff member's name
    - id: reason-is-required
      statement: |
        Given any order
        When a staff member refunds it without a reason
        Then no refund is recorded
    - id: never-more-than-paid
      statement: |
        Given an order with refunds that already add up to the amount paid
        When a staff member refunds any further amount
        Then no refund is recorded
lineage:
  owner:
    team: support-tools
  created_at: "2026-11-22"
```

Add what the back office does not have yet as a `planned` record, `apps/admin/docs/facets/features/checkout/discounts/create-code.yaml`:

```yaml
schema_version: "0.1"
id: checkout/discounts/create-code
lifecycle: planned
intent:
  summary: Marketing staff create a discount code with a value, a last day and an optional minimum order value.
contract:
  scenarios:
    - id: code-names-are-unique
      statement: |
        Given a discount code SPRING5 exists
        When a staff member creates another code named spring5
        Then the back office refuses it
lineage:
  owner:
    team: support-tools
  created_at: "2026-11-22"
```

Anchor each product's code to its record. In `src/orders/refund.ts`, directly above `export function requestRefund`, and in `apps/admin/src/refunds.ts`, directly above the comment of `staffRefund`, add:

```ts
// @facet: orders/refunds/refund-order
// @facet-role: primary
```

The comment is identical in both files. Which record it belongs to follows from the folder: `src/` is the shop's, `apps/admin/` is the back office's.

## See both products side by side

```sh
npx facet registries
```

![Terminal output of npx facet registries: a table with the columns FEATURE, admin and shop. checkout/discounts/create-code is planned in admin and missing in shop; checkout/discounts/redeem-code is missing in admin and active in shop; orders/refunds/refund-order is active in both. Summary: 3 features across 2 registries, 1 documented by more than one.](https://facet-framework.com/guides/two-products-in-one-monorepo/registries-matrix-light.png)

*One row per feature, one column per product.*

The refund row says both products have the feature, each with its own record and its own rule. `npx facet registries --gaps` shows only the rows where a product is missing a feature.

Check both registries:

```sh
npx facet lint
```

The summary reads `4 record(s), 3 anchor(s) checked across 2 registries (admin, shop) — 0 error(s)`. Every message in the output starts with the registry it belongs to, `[shop]` or `[admin]`.

Commit the setup:

```sh
git add .facetrc.yaml docs apps src
git commit -m "Describe the shop and the back office in two registries"
```

## Ask which product a change touches, before you commit

Back to the support request. Change the constant the search found, in `src/orders/refund.ts`:

```ts
export const REFUND_WINDOW_DAYS = 45;
```

Then ask FACET which records your uncommitted change touches:

```sh
npx facet drift
```

![Terminal output of npx facet drift: baseline HEAD; drift: shop:orders/refunds/refund-order, changed: src/orders/refund.ts; 1 drifted anchor.](https://facet-framework.com/guides/two-products-in-one-monorepo/drift-wrong-product-light.png)

*The change touches the shop's refund rule, not the back office's.*

`shop:orders/refunds/refund-order` is the answer: this edit changes what customers get, and the shop's record still says 30 days. The support request was about the back office. Undo the change:

```sh
git checkout src/orders/refund.ts
```

Make the change in `apps/admin/src/refunds.ts` instead and run `npx facet drift` again. It reports `admin:orders/refunds/refund-order`. Update that record's scenarios in the same commit. `facet drift` reports and never fails a run, so it fits before every commit and into review.

## Let the check catch code that claims the other product's feature

Code gets copied between apps. Say someone builds discount-code management in the back office and copies the shop's expiry check into `apps/admin/src/codes.ts`, anchor included:

```ts
// @facet: checkout/discounts/redeem-code
// The expiry day ends in UTC for every customer.
export function isExpired(expiresOn: string, now: Date): boolean {
  return now.getTime() > Date.parse(`${expiresOn}T23:59:59.999Z`);
}
```

Check the back office alone:

```sh
npx facet lint --registry admin
```

![Terminal output of npx facet lint --registry admin: an error in apps/admin/src/codes.ts says the tag references checkout/discounts/redeem-code, which has no record; another registry has this feature, but this code belongs to admin alone. Summary: 1 error, 2 warnings.](https://facet-framework.com/guides/two-products-in-one-monorepo/lint-wrong-registry-light.png)

*The shop has this feature, the back office does not: an error.*

The shop has a record with that id, but `apps/admin/` belongs to the back office alone. The error offers both fixes: give the back office its own record for the feature, or move the code into a folder both registries list in `sources`. Here the right id is the planned `checkout/discounts/create-code`; change the anchor to it, or remove it until the feature is built.

> **What this does not do**
>
> Registries separate records, not code. FACET does not stop an edit in `src/` from changing the shop, and it does not
> read what the change does. `facet drift` names the records whose anchored code changed, and `facet lint` checks that
> each product's code points at that product's records. Code without an anchor is not reported by either.

## If the check says something else

- **`registry "admin" points at "apps/admin/docs/facets", which does not exist`:** create the records folder from step 2, or fix the path under `records`.
- **`declares both top-level records/schema/sources/runners and a registries block`:** move the top-level `records:` line into one of the registries. A file with `registries` has no top-level layout.
- **`registry name "Admin" must be lowercase letters, digits and hyphens`:** registry names appear in front of ids, as in `admin:orders/refunds/refund-order`. Use lower case.
- **`@facet: tag names registry "backoffice", which is not declared`:** an anchor uses a prefix that `.facetrc.yaml` does not declare. Use a declared name, or the bare id.
- **`no schema directory at apps/admin/docs/facets/schema — schema validation skipped`:** add `schema: docs/facets/schema` to that registry.

For more on keeping teams that share a repository from breaking each other's features, read [Your release was green. Ours is broken now.](https://facet-framework.com/en/solutions/distributed-teams/)

### Sources

- [FACET registries guide: several products in one repository](https://github.com/facet-framework/core/blob/main/docs/REGISTRIES-GUIDE.md)
- [FACET variants guide: one product built twice](https://github.com/facet-framework/core/blob/main/docs/VARIANTS-GUIDE.md)
