Preparing your design workspace

Loading the problem and your latest saved attempt…

Design an Address and Date Tax Engine

Resolve overlapping tax jurisdictions and effective-dated rate components for an address through a schema-first lookup service.

Problem statement

For this exercise, assume a checkout client supplies a postal address and an explicit calendar date and asks which tax-rate components apply. Geocode the address to coordinates and use PostGIS containment against authoritative jurisdiction boundaries; a postal code alone does not determine the applicable jurisdictions.

State, county and city jurisdictions may overlap, and each jurisdiction can define several tax kinds with rates that change by effective date. Store each jurisdiction and its rate history once, including a state rate shared by all cities in that state.

Start with the database schema and its keys, relationships, validity periods and query path, then design the lookup architecture.

As bounded practice assumptions, return the applicable jurisdiction/rate components grouped by tax kind, together with the dataset release used; within a tax kind the applicable rates add, but do not combine different tax kinds into one percentage. Do not calculate a monetary bill without a supplied taxable amount.

Treat the requested date as a date value with inclusive start and exclusive end of validity. A successful result uses one complete validated dataset release for geometry and rates.

Ambiguous geocoding or an exact unresolved boundary point returns an explicit unresolved result, and missing required rate data is unavailable rather than zero. A background sync validates new data and activates a complete immutable release; real-time checkout requests must not wait for that sync.

Explain Redis cache identity and invalidation, historical-date lookups, batch publication failure and Black Friday traffic. Assume an authenticated client and a managed geocoding dependency.

Deriving tax law, collecting tax, item exemptions, filing returns, determining rates from unreviewed external prose and building a geocoder are outside scope. All rates and membership rules are supplied approved exercise data.

What to build

  1. Resolve an unambiguous address to all applicable state, county and city jurisdictions using coordinates and authoritative spatial boundaries.
  2. For one requested date, return each applicable jurisdiction/tax-kind rate once, grouped by tax kind with the dataset release and explicit unresolved or unavailable outcomes.
  3. Validate and activate complete geometry/rate releases in background sync while checkout lookups remain independently available and cache results safely.

At scale

  • For this exercise, assume 50,000 jurisdiction geometries and one million effective-dated rate records retained across releases; repeated addresses are common and a state record is shared by many cities.
  • Assume 5,000 lookups per second normally and a Black Friday peak of 50,000 per second, with a strongly skewed set of popular checkout locations.
  • Target p99 lookup latency below 200 milliseconds for requests with a cached geocoding result, and 99.9% lookup availability; bound calls to the external geocoder and surface its unavailable or ambiguous outcomes.
  • Activate a validated daily sync within 60 seconds of its ready signal in healthy operation. Every success pins one complete release, and a failed or incomplete sync leaves the previous validated release serving with its identity visible.