Contoso Traders
A sample online electronics store published by Microsoft to demonstrate cloud-native architecture on Azure. It has a React storefront and .NET APIs for products, shopping carts and profiles.
Business rules, traced to source lines.
These 11 rules are a sample of the 389 CoreStory V3 extracted from Contoso Traders. Each one links to the exact lines on GitHub at commit 96790a3. The statement is CoreStory V3’s wording; the code excerpt is the source it cites.
The quantity picker for each cart line item is configured with a minimum quantity of 1 and a maximum quantity of 10.
- 1 — minimum permitted item quantity
- 10 — maximum permitted item quantity
Also cited: L109
When a product is posted to the cart and a cart item with the same product id already exists, its quantity is increased by 1 through updateQuantity instead of adding a new item. Success returns the message "Product added on shopping cart", and failure returns the error "The product could not be added to the cart".
- 1 — quantity increment applied to an existing cart product
When a cart item's quantity is changed, a quantity greater than 0 updates the item's quantity through CartService.updateQuantity and local state; a quantity of 0 or less deletes the product through CartService.deleteProduct and removes it from local cart state.
- 0 — quantity threshold; quantities above it update the item, otherwise the item is deleted
The add-to-cart and shopping-cart buttons are shown only when stockUnits is greater than 0 and the user is logged in.
- 0 — stock units threshold; must be exceeded to allow add to cart
When retrieving a product, if the stock service throws StockNotFoundException for the product, the product's StockUnits is set to 0; otherwise StockUnits is set to the stock record's StockCount.
- 0 units — stock units assigned when no stock record is found
Each decrement stock operation reduces the stored stock count of the existing record by exactly 1 and upserts the updated record.
- 1 — amount subtracted from stock count per decrement
Product search lowercases the search term, splits it on spaces (discarding empty entries), and returns products where any term is contained in the product name, the product type name (lowercased), or any of the product's feature descriptions.
When at least one brand id or type id is supplied, products are filtered so that a product must match the brand list (if non-empty) and the type list (if non-empty); an empty list imposes no restriction. When both lists are empty, all products are returned.
Also cited: L39–L41
Issued JWT access tokens expire 365 days after creation, and the reported ExpiresIn is expiresInDays * 24 * 60 * 60 seconds (365 days expressed in seconds).
- 365 days — token lifetime
- 24 hours/day — conversion factor for ExpiresIn
- 60 minutes/hour — conversion factor for ExpiresIn
- 60 seconds/minute — conversion factor for ExpiresIn
The confirm password is required, must be at least 8 characters long, and must equal the new password value.
- 8 characters — minimum confirm password length
When handling a PostImageRequest, the uploaded file's ContentType must contain the text "image"; otherwise the handler returns a BadRequest result with the message "Invalid file type." and does not run the image search.
- image — required substring of the uploaded file's content type
- Invalid file type. — error message returned for a non-image file
What the application does
10 capabilities and 67 features, as described by an earlier CoreStory V3 ingest of the same commit. These are descriptions, not the cited rules above.
Application Shell and Navigation
Provides the main page structure, navigation, informational content, status feedback, diagnostics, and error experiences.
- About Us Display: Users can view About Us information.
- Breadcrumb Navigation: Displays breadcrumb navigation so users can observe and navigate their current location hierarchy.
- Debug Header Display: Displays a debug header within the user interface.
- Error Page Display: Displays an error page to users when an error occurs.
- Header Display: Displays a header whose visibility responds to application state.
- Home Page: Provides the application's home page experience.
- Loading Indicator Display: Displays a loading indicator while the user waits for an operation to complete.
- Terms of Service: Provides users access to the terms of service.
- Top App Bar Display: Displays the application's top app bar using state supplied by the application.
Client State Persistence
Maintains application state and initializes locally stored client data across sessions.
- State Persistence: Enables callers to load, inspect, update, and save persistent state values.
- Todo List Local Storage Initialization: Initializes the todo experience by checking locally stored todos and completion counts and creating default todos when needed.
Cloud Scalability and Observability
Supports cloud-native autoscaling, load validation, operational metrics, and monitoring dashboards.
- Azure Cloud-Native Application Autoscaling: Enables cloud-native applications on Azure to automatically scale in response to demand.
- Load Testing and Autoscaling: Users can load test cloud-native applications and observe them automatically scale on Azure.
- Metrics and Dashboards: Users can observe application and autoscaling behavior through metrics and dashboards.
Communications and Meetings
Supports chat, calls, meetings, and management and presentation of remote participants.
- Call Card Display: Displays a call card that responds to connection completion and remote participant activity.
- Chat Bubble Display: Displays chat content in a bubble-style interface.
- Chat Interface: Provides a user-facing chat interface that is initialized and displayed to users.
- Meeting Display: Displays the meeting interface to users.
- Remote Participant Display: Displays a remote participant in a user-facing card.
- Remote Participant Removal: Allows a user to remove a remote participant from the card interface.
Customer Account and Loyalty
Centralizes customer profile data, addresses, coupons, rewards, wishlists, and order history.
- Address Book: Provides an address book capability for managing contact information.
- Coupon Item Display: Displays a compact coupon item with generated visual styling.
- My Coupons: Users can access and view their coupons.
- My Coupons Display: Users can access and view their coupons in a dedicated interface.
- Profile Display: Users can view profile information through a state-connected profile interface.
- Purchase History: Users can access their purchase history.
- Recommended Item Rewards: Users can trigger and post rewards through a recommended-item interaction.
- User Portrait Display: Displays a visual portrait representing a user.
- View My Orders: Users can access and view their own orders.
- Wishlist: Enables users to access or manage a wishlist.
Identity and Session Management
Supports user sign-in, B2C identity flows, token lifecycle management, request recovery, and authentication error handling.
- Authentication Token Management: Enables access and refresh tokens to be stored and retrieved for authenticated sessions.
- Automatic Token Refresh and Request Retry: Automatically obtains new JWT access tokens after unauthenticated responses and retries the original request across supported authentication modes.
- B2C Login: Enables business-to-consumer users to log in.
- Expired Token Error Handling: Detects expired authentication tokens and returns an appropriate error response to the caller.
- Login Interface: Provides a login interface with form-error feedback and browser-local persistence of login information.
- User Login: Provides a form-based capability for users to initiate authentication.
Interactive UI Component System
Offers reusable controls and layouts for selection, actions, menus, accordions, sliders, details, and list or grid presentation.
- Checkbox Display: Displays a checkbox container as part of the user interface.
- Checkbox Input: Provides a user-facing checkbox control for toggling a binary selection.
- Customized Accordions: Provides a customized accordion interface for expandable and collapsible content.
- Customized Menus: Provides users with a customized menu experience.
- Detail Display: Displays a rendered detail view to the user.
- Interactive Actions: Supports triggering click, text, and submission interactions.
- Interactive Slider: Provides a slider composed of selectable or displayable items for user interaction.
- List Grid Display: Displays list content in a grid-based presentation.
- Sidebar Accordion: Provides an accordion-style sidebar for organizing and interactively expanding or collapsing sidebar content.
Product Discovery and Merchandising
Enables catalog browsing, product inspection, visual search, filtering, recommendations, and promotional product presentation.
- Hero Display: Displays a hero section as part of the user interface.
- Image-Based Product Search: Users can search the Contoso Traders product catalog using an image.
- List Sidebar Filtering: Users can view a list sidebar, control its visibility, and open its filter panel.
- Offer Banner Display: Displays an offer banner to users.
- Popular Products Display: Displays popular products on the home page in a ranked order.
- Product Detail Display: Users can view product detail information that is loaded and refreshed for the detail page.
- Product Details: Users can view detailed information about a product.
- Product List Browsing: Displays product data and supports browsing the list through page and query-string state changes.
- Product Recommendations: Provides recommended products to users or consuming systems.
- Recommendations: Provides recommended content for users or consuming systems.
- Suggested Products Display: Displays a list of suggested products to users.
Rich Media Handling
Provides file ingestion, local video preview, streamed media presentation, and image-based visual experiences.
- Carousel Display: Displays a carousel composed of individual items.
- File Upload: Users can select, submit, and reset a file through an upload interface.
- Image Slider: Enables users to browse through a sequence of images in a slider.
- Local Video Preview: Displays a local video preview to the user when the preview card is mounted.
- Stream Media Display: Displays streaming media through a user-facing component.
Shopping Cart Management
Provides cart creation and display, product addition, quantity selection, and item quantity updates.
- Add Product to Cart: Users can add the displayed product to their cart and receive success or error feedback.
- Quantity Selection: Users can view and adjust a selected quantity by incrementing or decrementing it through a quantity picker.
- Shopping Cart: Provides a shopping cart capability that users can directly access and use.
- Shopping Cart Display: Displays a shopping cart card to the user.
- Shopping Cart Management: Users or calling systems can add items to a shopping cart and retrieve stored cart information.
- Shopping Cart Quantity Update: Users can change item quantities in the shopping cart and observe the updated cart state.
What was analyzed
- JSON · 15 files · 19,215 lines
- JavaScript · 108 files · 7,396 lines
- SCSS · 37 files · 3,428 lines
- Markdown · 21 files · 2,854 lines
- C# · 99 files · 1,655 lines
- CSS · 4 files · 941 lines
- YAML · 12 files · 585 lines
- SVG · 66 files · 281 lines
- SQL · 1 file · 222 lines
- MSBuild script · 4 files · 109 lines
- XML · 2 files · 95 lines
- Other (4 languages) · 5 files · 131 lines
Whole repository: 980 files. cloc 2.06 counts 36,912 lines of code in 374 of them (41,692 lines with comments and blanks).
Where this came from
Business rules extracted by CoreStory V3 from the public repository at commit 96790a3 on 2026-11-11. Capability descriptions from an earlier CoreStory V3 ingest of the same commit (2026-10-17).
- Repository microsoft/ContosoTraders
- Commit 96790a39319748aa91f7b0517bcd341922066cba
- Line counts cloc 2.06
- Rule citations The 494 evidence quotes behind the 389 rules were compared with the repository source at this commit.
Code excerpts are from the upstream repository and remain under its MIT license. CoreStory is not affiliated with or endorsed by Microsoft.
Want this for your own codebase?
Talk to us about mapping the business rules in your repositories.