# Describe a repository with patchbay.yaml

> Add a patchbay.yaml catalog file to a repository so that Patchbay creates and updates its components for you.

Add a `patchbay.yaml` catalog file to a repository, and Patchbay creates and updates the components that the file declares. The file sits at the root of the default branch, names one project, and lists the components that the repository holds.

Patchbay reads the file only from repositories that the Patchbay GitHub App can read for your workspace. See [Connect GitHub](/workspace/github).

## Write the file

Add `patchbay.yaml` at the root of the repository and merge it into the default branch. Patchbay does not read the file from other branches or other paths.

The `project` field has the form `<workspace>/<project>`. Use the URL form of both names, as they show in the address bar of Patchbay. The workspace must be the one that the GitHub App installation belongs to.

<Tabs>
<Tab title="Standalone repository">
Leave out `components`, and the whole repository becomes one component. The component has the name of the project, and its root path is `/`.

```yaml title="patchbay.yaml"
apiVersion: patchbay.unbrikd.cloud/v1alpha1
kind: ProjectCatalog
project: acme/payments
```
</Tab>
<Tab title="Monorepo">
List each component with a `name` and a `rootPath`. Each `rootPath` is a folder of the repository, and the repository root `/` is not allowed in this list.

```yaml title="patchbay.yaml"
apiVersion: patchbay.unbrikd.cloud/v1alpha1
kind: ProjectCatalog
project: acme/commerce
components:
  - name: storefront
    rootPath: /apps/storefront
    description: Customer-facing storefront.
  - name: checkout-api
    rootPath: apps/checkout-api
  - name: shared-contracts
    rootPath: /packages/contracts
```
</Tab>
</Tabs>

<Media id="catalog-monorepo" label="A monorepo with three folders, each mapped by patchbay.yaml to one component of the same project." />

Names and root paths must be unique in the file, and the `description` field is optional. Each file declares components for one project only. For every field and rule, see the [catalog file reference](/reference/catalog-file).

## Turn on catalog sync for an existing project

If the project already exists, Patchbay does not apply the file until a project administrator turns on **Catalog sync**. As a reminder, project administrators get an **Enable catalog reconciliation** item in their [inbox](/inbox).

You need the **Admin** role on the project to do these steps:

1. Open the project and press `Cmd+K` (or `Ctrl+K`).
2. Select **Project settings**, and then click **Sources**.
3. Read the **If you turn it on** list, which shows what happens to each declared component.
4. Turn on the **Catalog sync** switch.

When **Catalog sync** is on, the pane shows **Sources** and **Bindings**. **Sources** lists the repositories whose `patchbay.yaml` Patchbay reads, with the commit that it read. **Bindings** shows each component as **Managed** (from a catalog file) or **Manual** (added by a person).

To turn **Catalog sync** off, turn off the switch and click **Disable** in the **Disable catalog sync** dialog. Existing components stay as they are.

## What Patchbay does with the file

Patchbay reads the file again after each push to the default branch. To read a source at once, a project administrator can click **Sync** next to it.

Catalog reconciliation compares each declared component with the components of the project, by name and by location. The location is the repository plus the root path.

| What the project has | Result |
|---|---|
| No component with the name or the location | Patchbay creates a **Managed** component. |
| A **Managed** component with the same name and location | Patchbay updates its description. |
| A **Manual** component with the same name and location | No change. A project administrator can click **Adopt** to make it **Managed**. |
| A component with the name at another location, or the location under another name | No change. Patchbay records a conflict. |

Patchbay never moves, renames or deletes a component because of a catalog file. If you remove a declaration from the file, the component stays in the project and shows as **Stale**. Changes to components do not change existing releases.

If the file is not valid, Patchbay applies none of it and the last valid version of the file stays in effect.

## When the project does not exist

If the file names a project that does not exist in the workspace, Patchbay creates a project proposal. Workspace owners and administrators see it in their [inbox](/inbox) as a **Project proposal**.

The proposal lists the declared components and the repositories that declare them. To accept it, click **Create project & start genesis**. Patchbay then creates the project as **Private**, adds the declared components and runs Genesis, and the person who accepts becomes the project administrator.

## See problems with the file

Patchbay reports problems with the file in two places:

- In the [inbox](/inbox), a file that is not valid creates a **Correct the catalog file** item. A name or location conflict creates a **Resolve a catalog component conflict** item.
- In the **Sources** settings of the project, a warning icon next to a source lists its problems. Each problem names the field in the file and says what is wrong.

[Problems Patchbay reports](/reference/catalog-file#problems-patchbay-reports) lists every problem with its fix.

Index of all pages: https://patchbay.unbrikd.com/docs/llms.txt
