Preparing your design workspace

Loading the problem and your saved attempt…

Design Tagged Gift Shop Search

Design an in-memory gift-shop catalog that supports product lifecycle changes, all-tags search, and correct bounded caching.

Design the domain layer behind a gift-shop search bar. Shoppers should be able to find products by tags, while catalog managers maintain the searchable products.

The source report mentioned a tag-to-product HashMap and cached multi-tag requests as one candidate's approach; treat that as optional inspiration, not a required implementation.

For this exercise, assume shoppers search the catalog and catalog managers can add products, replace a product's tags, and remove products. Each product has a unique stable identifier, a display name, and a non-empty set of tags.

A query contains one or more tag terms: trim them, compare them case-insensitively, remove duplicates, and return only products containing every requested tag. Reject a query that is empty after normalization. A search that starts after a successful catalog mutation must not return a pre-mutation result.

Keep the design within one in-memory application process. Persistence, UI rendering, free-text relevance and ranking, inventory, pricing, carts, checkout, and authentication are outside scope. Design the objects and responsibilities, public interfaces, ordered interactions, errors, and extension boundaries.

You may use an inverted tag index and query cache, a direct catalog scan, or another coherent design that preserves the behavior and invariants.