Make tax a first-class part of your e-commerce backend. You'll add a dedicated tax rates table, expose a small admin-style Tax Rates API, and let carts choose a tax country so totals update in real time.
Overview
Syllabus
- Unit 1: Tax Rates Configuration API
- Review the repository, service, and route layers for tax rates
- Implement repository queries for tax rates
- Implement validation and service functions for tax rates
- Implement GET/PUT/DELETE routes for tax rates
- Unit 2: Applying Cart Taxes
- Review how carts store tax_country and compute totals
- Implement cart tax country validation and persistence
- Resolve tax rate by country and compute cart totals
- Implement the cart tax country route handler
- Unit 3: Snapshotting Tax at Checkout
- Snapshotting Tax at Checkout
- Persist tax snapshot fields on the order at checkout
- Map tax snapshot fields in the Order read model
- Remove recomputation and rely on checkout snapshots