Building a scoring engine with pure TypeScript functions (no ML, no backend)
We needed to score e-commerce products across multiple dimensions: quality, profitability, market conditions, and risk. The constraints: Scores must update in real time Must run entirely in the bro...

Source: DEV Community
We needed to score e-commerce products across multiple dimensions: quality, profitability, market conditions, and risk. The constraints: Scores must update in real time Must run entirely in the browser (Chrome extension) Must be explainable (not a black box) We almost built an ML pipeline β training data, model serving, APIs, everything. Then we asked a simple question: Do we actually need machine learning for this? The answer was no. We ended up building several scoring engines in pure TypeScript. Each one is a single function, under 100 lines, zero dependencies, and runs in under a millisecond. What "pure function" means here Each scoring engine follows 3 rules: No I/O β no network, no DB, no files Deterministic β same input = same output No side effects β no global state, no mutations This makes them: Easy to test Easy to reason about Portable (browser, Node.js, anywhere) Core pattern: weighted scoring interface ScoringInput { qualityScore: number | null; profitScore: number | null;