Skip to content

feat: connect Catalog to Basket with direct C# basket previews - #8

Open
ivanmilevtues wants to merge 2 commits into
mainfrom
demo/catalog-validated-baskets
Open

ivanmilevtues wants to merge 2 commits into
mainfrom
demo/catalog-validated-baskets

Conversation

@ivanmilevtues

@ivanmilevtues ivanmilevtues commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Validate basket products against the catalog before saving and add a read-only endpoint for previewing basket line totals. This prevents updates containing missing products and lets callers estimate a line using the current catalog price and Basket validation rules.

Changes

Validate basket updates against Catalog

  • Check all product IDs through the Catalog batch endpoint before persisting an authenticated basket update.
  • Reject duplicate products, non-positive IDs or quantities, and baskets with more than 100 items.
  • Leave the stored basket unchanged when products are missing or the catalog lookup fails. Return FailedPrecondition for missing products and Unavailable for catalog failures.
  • Allow empty baskets to be saved without a catalog lookup so clearing a basket remains possible during an outage.
  • Configure the Catalog HTTP client with service discovery and resilience defaults, and wire the dependency into AppHost.

Add basket line previews

Expose the following endpoint in Catalog API versions 1.0 and 2.0:

GET /api/catalog/items/{id}/basket-preview?api-version=2.0&quantity=3
  • Return the product ID, name, quantity, unit price, and total price; quantity defaults to 1.
  • Reuse BasketPreview.Create and Basket item validation through a direct in-process reference to the Basket assembly.
  • Return 400 for invalid product IDs or quantities and 404 for missing products.
  • Keep previews read-only: no basket writes, stock reservations, or price locks.
  • Update both OpenAPI documents and exclude Basket host settings from Catalog publish output.

Testing

  • Basket unit coverage for batch validation, missing products, catalog failures, cancellation, authentication, input limits, and clearing baskets without Catalog.
  • Preview unit coverage for decimal totals, quantity validation, and zero-priced items.
  • Catalog functional coverage for both API versions, default quantity, validation errors, missing products, and unchanged stock and prices.

Previously completed local validation:

  • dotnet test --solution eShop.Web.slnf — 158 passed, 0 failed, including container-backed functional tests.
  • Basket unit suite — 32 passed.
  • Catalog functional suite — 48 passed.
  • Release publish of src/Catalog.API/Catalog.API.csproj — succeeded.
  • git diff --check — passed.

Introduce a direct Basket-to-Catalog HTTP connection with Aspire service discovery.
Validate complete batches before saving and preserve baskets on catalog failures.
Cover missing products, outages, cancellation, authentication and input limits.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0d851-f6a1-75de-9f3b-578690b1f00f
Co-authored-by: Amp <amp@ampcode.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T11:50:31.873432Z 2172456 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

CodeBoarding review

Status: 5 changed components

See the full change in CodeBoarding.

graph LR
    n_Client_App["Client App"]
    n_Ordering_Service["Ordering Service"]
    n_Identity_API["Identity API"]
    n_Web_Frontends["Web Frontends"]
    n_Catalog_Service["Catalog Service"]
    n_Webhooks_and_Shared_Infrastructure["Webhooks and Shared Infrastructure"]
    n_Event_Bus["Event Bus"]
    n_Basket_API["Basket API"]
    n_Application_Host_and_Defaults["Application Host and Defaults"]
    n_Payment_Processor["Payment Processor"]
    n_Payment_Processor -- "publishes events to" --> n_Event_Bus
    n_Ordering_Service -- "stores outbox events in" --> n_Catalog_Service
    n_Ordering_Service -- "uses migration helpers in" --> n_Webhooks_and_Shared_Infrastructure
    n_Ordering_Service -- "publishes and subscribes events via" --> n_Event_Bus
    n_Ordering_Service -- "configures defaults from" --> n_Application_Host_and_Defaults
    n_Web_Frontends -- "subscribes to events on" --> n_Event_Bus
    n_Web_Frontends -- "configures HTTP and config defaults from" --> n_Application_Host_and_Defaults
    n_Catalog_Service -- "uses migration helpers in" --> n_Webhooks_and_Shared_Infrastructure
    n_Catalog_Service -- "publishes and subscribes events via" --> n_Event_Bus
    n_Catalog_Service -- "calls" --> n_Basket_API
    n_Webhooks_and_Shared_Infrastructure -- "subscribes to events on" --> n_Event_Bus
    n_Webhooks_and_Shared_Infrastructure -- "configures authentication defaults from" --> n_Application_Host_and_Defaults
    n_Event_Bus -- "dispatches events to" --> n_Payment_Processor
    n_Event_Bus -- "dispatches events to" --> n_Ordering_Service
    n_Event_Bus -- "dispatches events to" --> n_Web_Frontends
    n_Event_Bus -- "dispatches events to" --> n_Catalog_Service
    n_Event_Bus -- "dispatches events to" --> n_Webhooks_and_Shared_Infrastructure
    n_Event_Bus -- "dispatches events to" --> n_Basket_API
    n_Basket_API -- "subscribes to events on" --> n_Event_Bus
    n_Basket_API -- "configures defaults from" --> n_Application_Host_and_Defaults
    classDef added fill:#1f883d,stroke:#0b5d23,color:#ffffff;
    classDef modified fill:#bf8700,stroke:#7d4e00,color:#ffffff;
    classDef deleted fill:#cf222e,stroke:#82071e,color:#ffffff,stroke-dasharray:5 3;
    class n_Catalog_Service,n_Basket_API modified;
    linkStyle 9 stroke:#0b5d23,stroke-width:2px;
Loading

download artifacts · run 36132547888

Catalog calls BasketPreview.Create in the Basket assembly without HTTP or the
integration event bus. Keep previews read-only and reuse Basket validation.
Preserve Catalog host settings when publishing the cross-service reference.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0d851-f6a1-75de-9f3b-578690b1f00f
Co-authored-by: Amp <amp@ampcode.com>
@ivanmilevtues ivanmilevtues changed the title feat: connect Basket to Catalog for product validation feat: connect Catalog to Basket with direct C# basket previews Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant