---
title: Deploy PeerDB with AI on Blossom
url: "/deploy/peerdb/"
canonical_url: https://blossom88.com/deploy/peerdb/
markdown_url: https://blossom88.com/deploy/peerdb.md
summary: Copy an orders table to a second PostgreSQL database and keep the mirror
  running as new changes arrive.
categories:
- deployment
- databases
stack:
- Go
- Rust
- PostgreSQL
- Temporal
---

# Deploy PeerDB with AI on Blossom

[PeerDB](https://github.com/PeerDB-io/peerdb) copies and streams
PostgreSQL data to reporting targets. This recipe uses the
[AGPLv3 edition](https://github.com/PeerDB-io/peerdb/blob/v0.37.17/LICENSE)
and mirrors one orders table between PostgreSQL databases.

## Ask Your Agent

> **Ask your AI agent:** Deploy PeerDB on Blossom and help me mirror a sample orders table to a reporting database.
>
> Follow this guide: https://blossom88.com/deploy/peerdb/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Have Ready

Nothing is required beyond your Blossom account.

- **Source and target databases** (Later): Use the isolated sample databases first. Bring a PostgreSQL source with logical replication and an owned reporting database when adapting the setup.

## How It Runs

| Part | Role | Where |
|---|---|---|
| PostgreSQL | Keep the mirror catalog, Temporal state, source, and reporting tables | Private Persistent Service |
| Temporal | Orchestrate the mirror and recover its work | Private Service on App Capacity |
| PeerDB Flow API and workers | Create the mirror and stream table changes | Private Services on App Capacity |

## Deploy PeerDB

Keep the Flow API and workers private. Use separate PostgreSQL
databases for the catalog, Temporal, source, and destination. Start
with one source publication that covers just the sample orders table.

<details class="optional-reading" markdown="1">
<summary>Notes for your agent</summary>

Mount the PostgreSQL Volume at `/var/lib/postgresql/data`.
Enable logical WAL on the sample source. Bind the private Temporal
listener to all Container interfaces so the readiness check and
workers can connect. Deploy with the Flow Services set to zero.
Once PostgreSQL and Temporal are ready, register the MirrorName
search attribute and run the catalog migration. Start the Flow API,
then start the workers. Use PostgreSQL copy and continuous
replication for this target.

    blossom environment:deploy --id environment-100 --follow

</details>

## Copy the Orders Table

Create and validate both peers, then start a CDC mirror with an
initial snapshot. Check the original packed order on the target.
Add one pending order and verify it appears there too.

> **Ask your AI agent:** Mirror my sample orders table and check that the target has both the original and the new order.

> Follow this guide: https://blossom88.com/deploy/peerdb/



![Find the original order and the newly replicated order.](/deploy/assets/images/peerdb/initial-mirror-orders.webp)

## Continue the Mirror After an Update

Replace the continuous worker and change the pending order to
shipped. Check that the same mirror updates the reporting table.

> **Ask your AI agent:** Replace the PeerDB worker and verify that the same mirror can replicate an update.

> Follow this guide: https://blossom88.com/deploy/peerdb/



![See the shipped order in the original mirror after replacing the worker.](/deploy/assets/images/peerdb/mirror-after-worker-replacement.webp)

## What You Get

A private reporting table that starts with a copy of your source
and stays current as new orders and changes arrive.

## What You Get

- A private mirror between two PostgreSQL databases
- An initial copy and new changes in the reporting table
- The same mirror carrying updates after replacing its worker

Tested on Blossom: The same mirror and replication slot carried an order update after replacing its worker.
