Problem statement
Design the service that computes sales tax, VAT, or GST for a shopping cart at checkout, given a versioned set of jurisdiction rules, and produces an auditable, reproducible record when the order is committed.
Operating context. For each cart the service receives ship-to and bill-to addresses, line items with taxability categories, and the customer's tax status (e.g. exempt). It resolves the applicable jurisdictions (country, state/province, county, city, special districts) and rates from a rules dataset that changes constantly as thousands of jurisdictions update rates. The storefront calls the service on every cart change for a live estimate, then again at order commit to freeze the final numbers. A committed tax result must be reproducible and stored immutably for tax filing and audit years later. Peak is about 30000 calculation calls/sec.
Out of scope. Sourcing and legal interpretation of the raw rate data, tax filing and remittance to authorities, currency conversion, and invoice PDF generation. Assume a rules-authoring pipeline delivers validated, versioned rate datasets.
What to produce. A high-level architecture covering: how the versioned rules dataset is modeled and served for fast jurisdiction resolution, how a calculation is made deterministic and reproducible, how live estimates differ from the immutable committed record, how rule-dataset updates roll out without downtime or mid-cart inconsistency, and how committed records are stored for long-term audit. Sketch the components and trace a calculation from cart input to a per-line tax breakdown, and a commit to a stored immutable record.
Must do 5
Functional requirements
- Compute per-line and total tax for a cart from its addresses, line items, taxability categories, and customer tax status.
- Resolve the applicable jurisdictions and rates from a specific version of the rules dataset.
- Return a breakdown that names each jurisdiction, its rate, and the rule-dataset version used.
- Recompute and freeze tax at order commit, persisting an immutable record for filing and audit.