Instruction file imported from kassiwin/checkout-legacy (
.cursor/rules/architecture.mdc). Copyright stays with the author.
Architecture checkout-service
Target described in docs/ARCHITECTURE.md. Every proposal must comply with it.
Non-negotiable rules
- A single source of truth for price. Price calculation lives in
src/domain/pricing.ts. No other file recomputes a total, VAT, a discount or shipping. - Transport holds no business logic.
src/server.tsparses, routes, serializes. Nothing else. - The domain is pure. No I/O, no
console.log, no clock, noDate.now()insrc/domain/. These dependencies are injected. - Typed errors. Never
throw "message".
// ❌ BAD
if (!body.customerId) throw "customerId missing";
// ✅ GOOD
if (!body.customerId) throw new ValidationError("customerId missing");
- No
anyin a public signature. Model the cart, the customer, the quote.
Business rules to preserve
- Stacked discounts are capped at 50% of the subtotal.
- VAT applies after discount, on the amount excluding shipping.
- A quote and its corresponding order must produce the same total.