---
title: Managing catalog data
summary: How catalog administrators and integrators create and maintain books, authors, categories, and publishers.
version: 1.0.0
type: guides
order: 1
badges:
  - content: Guide
    backgroundColor: teal
    textColor: teal
---

**Audience & Outcome:** This guide is for catalog administrators and API integrators who create, update, or retire merchandising records. By following these rules, you will maintain valid taxonomy links, accurate promotional pricing, and reliable cover artwork across Storefront, [[service|basket-api]], and [[service|order-api]].

[[service|catalog-api]] is the authoritative owner of BookWorm's [[entity|book]], [[entity|author]], [[entity|category]], and [[entity|publisher]] records, pricing, and cover image references. Store administrators manage these records through Backoffice or authenticated REST calls requiring Microsoft Entra ID `business_user` or `admin` roles with `read` and `write` scopes.

## Context and motivation

Books depend on supporting taxonomy records (a category, a publisher, and one or more authors), carry promotional pricing rules, reference binary cover artwork in [[container|catalog-blob]], and display derived customer ratings from Reviews. Without strict domain invariants at the [[service|catalog-api]] boundary, invalid discounts, orphaned author attributions, expired image links, or manual rating overrides would corrupt merchandising data across customer experiences.

## How it works

Every catalog write enters [[service|catalog-api]], validates domain invariants before committing to [[container|catalog-database]], and triggers downstream cache invalidation in [[container|catalog-cache]] and background vector indexing in [[container|catalog-vector]].

This visual shows the relationships between Catalog's core records, cover artwork storage, and external Reviews and Ordering boundaries.

<MermaidFileLoader file="mermaids/01-managing-catalog-data-diagram-1.mmd" />

### Entity creation order

Because a [[entity|book]] references supporting taxonomy records, create entities in dependency order:

<Steps>
<Step title="Create publishers and categories">

Create [[entity|publisher]] and [[entity|category]] records first. Names must be unique within [[container|catalog-database]].

</Step>
<Step title="Create authors">

Create [[entity|author]] records independently before linking them to books.

</Step>
<Step title="Create the book with optional cover artwork">

Submit the book with its category, publisher, and author IDs via multipart form data (`POST /catalog/api/v1/books`). Direct reads reflect the saved book immediately, while free-text search becomes discoverable after the next scheduled [[service|catalog-ingestion]] batch runs.

</Step>
</Steps>

### Domain invariants

:::warning
Never attempt to bypass [[service|catalog-api]] or manually edit `average_rating` and `total_reviews` in [[container|catalog-database]]. Rating summaries are read-only projections updated asynchronously from [[service|rating-api]].
:::

| Rule                              | Behavior                                                                   | Downstream Impact                                                               |
| :-------------------------------- | :------------------------------------------------------------------------- | :------------------------------------------------------------------------------ |
| **Discount bounds**               | Discount price must be between `0` and the original price                  | Prevents negative or inflated promotional pricing at checkout                   |
| **Category / publisher deletion** | Preserves associated books and clears their foreign-key reference          | Keeps catalog titles intact during taxonomy reorganization                      |
| **Author deletion protection**    | Blocked while any [[entity\|book]] still references the [[entity\|author]] | Prevents orphaned author attributions; unlink or retire books first             |
| **Book soft deletion**            | Marks the book deleted, hides it from listings, and queues vector removal  | Preserves historical [[entity\|order]] references while removing search results |
| **Read-only rating summaries**    | Updated only via integration events from [[service\|rating-api]]           | Keeps Reviews authoritative and prevents manual score tampering                 |

### Cover artwork and post-change propagation

- **Multipart uploads and short-lived SAS URLs:** Upload cover artwork (`image/jpeg`, `image/png`, or `image/webp`) with the book create or update request. [[service|catalog-api]] stores only an internal URN in [[container|catalog-database]] and generates read-only, time-limited SAS URLs (1-hour default) on read. Clients must never persist temporary SAS URLs as permanent image identifiers.
- **Immediate direct reads vs. eventual search:** Book writes invalidate [[container|catalog-cache]] entries so direct lookups return current values immediately, while database triggers enqueue updates for asynchronous [[container|catalog-vector]] indexing via [[flow|product-ingestion]].
- **Immutable accepted orders:** [[service|basket-api]] and [[service|order-api]] re-validate current prices over gRPC at checkout. Editing a book's price in Catalog never retroactively alters an already accepted [[entity|order]].

<AccordionGroup>
<Accordion title="Design trade-offs and alternatives considered">

| Decision                                                        | Benefits                                                                                 | Costs and limits                                                                        |
| :-------------------------------------------------------------- | :--------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- |
| **Restrict author deletion; allow category/publisher deletion** | Protects author attribution integrity while keeping taxonomy reorganization low-friction | Removing an author requires unlinking or retiring their books first                     |
| **Soft-delete books**                                           | Preserves historical book identity and order-audit traceability                          | Deleted rows remain in [[container\|catalog-database]] and require filtering in queries |
| **Store internal URN and sign short-lived SAS URLs on read**    | Prevents public blob scraping and decouples clients from storage internals               | Clients caching payloads beyond the SAS expiry encounter HTTP `403` until re-fetch      |
| **Read-only rating summary updated asynchronously**             | Keeps Reviews authoritative and prevents manual tampering                                | Rating changes appear in Catalog after brief Kafka propagation lag                      |

**Rejected alternatives:**

- **Hard-deleting books:** Breaks historical references in accepted orders and complicates vector cleanup.
- **Public anonymous blob URLs:** Exposes storage containers to unauthenticated scraping instead of Managed Identity delegation keys.
- **Direct rating edits in Catalog:** Violates Reviews ownership of individual [[entity|feedback]] records.

</Accordion>
</AccordionGroup>

## Related documentation

- [[flow|product-ingestion]] — How [[service|scheduler-service]] and [[service|catalog-ingestion]] synchronize [[container|catalog-vector]].
- [[adr|adr-001-postgresql-system-of-record]] — Why [[container|catalog-database]] is the single authoritative store for Catalog.
- [[adr|adr-005-blob-storage-for-book-images]] — Why cover artwork uses internal URNs and short-lived SAS URLs.
