Urgent.News

What's breaking now, across thousands of outlets.

Tech

Building a Birthstone Lookup Into a Gift-Shop Checkout: An Engineering Walkthrough

If you run an online gift shop, you eventually hit a question that looks nothing like an engineering problem until it becomes one: "Can the customer just type their birthday and get the right birthstone shown next to the right product?" On paper, that is a one-line if statement. In practice, it is a small piece of data engineering — and the way you wire it determines whether your checkout page…

Building a birthstone lookup into a gift shop checkout requires careful consideration of several factors. The first challenge is accurately determining which birthstone tradition to use. There are various lists, such as the U.S. traditional list, the modern list maintained by the American Gem Trade Association, the mystical list, and the Ayurvedic list, among others. These lists may disagree on which stones correspond to specific months.

Another critical aspect is dealing with different calendar formats. If the storefront serves an international audience, customers may input dates in various formats, such as DD/MM/YYYY or MM/DD/YYYY. The system must parse these dates explicitly and not rely on locale-dependent parsing methods.

Edge cases also need to be considered. For instance, customers born on February 29 during a leap year or those using Tibetan or lunar calendars may present challenges. The system should handle these scenarios gracefully and provide accurate results.

To ensure the birthstone lookup remains maintainable and upgradeable, it is essential to treat the month-to-stone mapping as a separate artifact from the code. Storing this mapping in a JSON file within the repository allows for easy updates without modifying the actual code. The JSON file should include the stone name, alternate names for search compatibility, and the source list it originated from.

To maintain transparency and traceability, it is crucial to document the source string for each row in the JSON file. This documentation enables customer support to provide accurate responses when customers inquire about the origin of their birthstone.

Validation rules are vital to ensure the integrity of the lookup process. Every month should have exactly one primary stone, and the array of stones should never be empty. Additionally, every stone name should map to at least one SKU in the catalog, ensuring that customers can purchase the corresponding product. The lookup system can return a stone name that the shop does not currently stock, but the front-end must handle this case gracefully without causing any issues.

The system should parse dates using an explicit format string rather than relying on JavaScript or Python's `new Date()` or `strptime()` functions, which can be implementation-defined for non-ISO formats. By defaulting to the ISO 8601 format (YYYY-MM-DD) in the input field and parsing it directly on the server-side, the lookup process becomes more reliable and consistent.

The core lookup function should have a single responsibility: take a month integer as input and return the canonical stone entry as output. This function should be separate from other components like HTTP handlers, templating, and error pages. By keeping the lookup function independent, updates to the birthstone data, such as adding Ayurvedic stones for a campaign, can be made through a simple change to the JSON file without affecting other parts of the system.

This modular approach allows for easy integration of additional data sources or administrative tools in the future.

To handle the failure modes effectively, designers should anticipate potential issues. For example, the system should gracefully handle invalid date inputs, missing SKU mappings, or changes in birthstone lists due to revisions by trade bodies. By designing with these failure modes in mind, the system can remain robust and reliable even when faced with unexpected scenarios.

In summary, building a birthstone lookup for a gift shop checkout involves careful consideration of multiple factors, including the variety of birthstone traditions, calendar formats, edge cases, maintainability, validation rules, and potential failure modes. By addressing these aspects systematically, the lookup process can be optimized for accuracy, efficiency, and maintainability, ensuring a smooth checkout experience for customers while also providing valuable data for merchandising campaigns.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

OpenRig - Peer to Peer donation based hardware sharing platform

This is a submission for Weekend Challenge: Generosity Edition What I Built I grew up teaching myself to code in Pakistan on hardware that struggled to run modern dev tools.

  • OpenRig is a peer-to-peer compute sharing platform built in 48 hours.
  • Donors register idle hardware to enable recipients to access resources.
  • Google Gemini AI matches recipients with hardware based on impact.

I built a pay-per-call image processing API that AI agents can pay for with USDC

I keep experimenting with the x402 protocol — HTTP 402 payment-gated APIs where AI agents pay per call in USDC on Base, no accounts or API keys. Yesterday it was QR codes; today it's image processing.

  • Image Toolkit API allows AI agents to pay for image processing services in USDC on Base blockchain.
  • Four operations (resize, convert, compress, thumbnail) available at $0.01 USDC per call.
  • API built with Python, Pillow, and Caddy server on $4 VPS, awaiting community feedback.

Matt Haughey: ‘The Car Industry a/B Tested Selling a Car With and Without CarPlay and the Results Are Not Shocking’

Matt Haughey: One case in point is the Honda Prologue EV. It’s a partnership between Honda and Chevrolet, where the Prologue is basically a Chevy Blazer EV with Honda badges, slight visual differences…

  • Honda Prologue outsells Chevrolet Blazer by 43%, 73%, and 166% in three periods
  • Prologue includes Apple CarPlay and Android Auto integration, unlike Blazer
  • In 2026, consumers purchase Prologue 1.5 times more often than Blazer

Your zero-downtime deploy is probably fine. Check your p99 before you believe it.

I went looking for dropped requests during a rolling restart and found something more annoying than dropped requests: a deploy that looks perfect and isn't. Setup is deliberately boring.

  • Zero-downtime deploy may appear successful but can fail during process.
  • Lack of signal handling in Node/Express app causes mid-flight requests to die.
  • Monitoring p99 latency, not just error rates, crucial to detect deploy issues.

More from Sunday 6 September →