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

Focused architecture demo with two new connections between Catalog and Basket. The headline change is now a direct C# Catalog Service → Basket API dependency, as requested, so static analysis has an explicit cross-component method call to follow.

Direct C# connection: read-only basket preview

CatalogApi.GetBasketPreview
    → BasketPreview.Create (Basket.API assembly, in-process)
        → BasketItem.Validate
        → decimal line-total calculation

Catalog loads the product and directly invokes Basket-owned validation/pricing code. This hop uses neither HTTP nor RabbitMQ. It reuses code inside the Catalog process; it does not contact the running Basket service, write a basket, reserve stock, or lock a price.

The preview can be invoked through Catalog's existing HTTP API surface:

GET /api/catalog/items/2/basket-preview?api-version=2.0&quantity=3

It returns product ID/name, quantity, unit price, and total price. Quantity defaults to 1; invalid quantities return 400 with Basket's validation message; missing products return 404. Both Catalog API versions are supported and their generated OpenAPI documents are updated.

Deliberate demo tradeoff: Catalog references the Basket web-service assembly directly. That is build-time/code coupling, not independent microservice communication. A production design would normally extract reusable domain rules to a small library. Catalog's publish target excludes Basket host settings, and tests explicitly select the Catalog assembly to avoid the two generated Program types.

Existing first commit: Basket → Catalog HTTP validation

Kept from the initial iteration: authenticated Basket updates validate product IDs using Catalog's existing batch endpoint before saving. Missing products or failed lookups leave the stored basket unchanged. Empty-basket writes bypass Catalog. Input validation bounds the batch to 100 unique positive IDs/quantities; HTTP resilience, discovery, and AppHost wiring are included.

Demo walkthrough

  1. Open https://app.codeboarding.org/CodeBoarding/eShop/pull/8.
  2. Focus on Catalog Service and Basket API. Follow CatalogApi.GetBasketPreview → BasketPreview.Create → BasketItem.Validate.
  3. Show the explicit Catalog.API.csproj → Basket.API.csproj project reference. There is no event-bus handler or HTTP client on this preview path.
  4. With eShop running via aspire run, call the preview URL above using the Catalog endpoint from the dashboard. Change quantity=3 to quantity=0 to demonstrate Basket's validation. The caller-to-Catalog request is HTTP; the Catalog-to-Basket-code hop is an ordinary C# method call.
  5. Optionally show the separate Basket-to-Catalog HTTP validation from the first commit for contrast.

Verification

  • Local dotnet test --solution eShop.Web.slnf: 158 passed, 0 failed, including container-backed functional tests.
  • Basket unit suite: 32 passed; covers preview decimal totals and quantity boundaries alongside prior validation cases.
  • Catalog functional suite: 48 passed; includes both versions of preview success, default quantity, validation errors, missing/invalid IDs, and unchanged stock.
  • Release dotnet publish src/Catalog.API/Catalog.API.csproj: succeeds. Published/build configuration matches Catalog's own settings.
  • git diff --check.
  • Updated CI and CodeBoarding analysis are running after the second commit; previous-commit results are not treated as fresh verification.

Uses the pinned .NET SDK 10.0.302. Existing ASPIRE010 CLI-bundle warnings remain. No dependency upgrades, database migrations, generated CodeBoarding baseline edits, or UI changes. Based on the latest fetched CodeBoarding/eShop:main.

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