A configurable, framework-agnostic pricing engine for any business domain.
Define your pricing rules in a simple JSON config — the engine does the math.
Every business has pricing logic. Most teams build it from scratch, tightly coupled to their application. This engine extracts that logic into a reusable, testable, configurable module.
Born from real-world experience building ERP pricing systems — area-based calculations, tiered rates, minimum charges, discounts. Abstracted to work across any domain: manufacturing, logistics, SaaS, e-commerce.
- Config-driven — define pricing rules in JSON, no hardcoding
- Area-based pricing — calculations from dimensions (m², ft², units)
- Minimum charge — guaranteed price floor per item
- Framework-agnostic — pure TypeScript, runs anywhere
- Minimal dependencies — only Zod for validation
- 100% test coverage — tested with Vitest
- TypeScript-first — full type safety, great DX
npm install open-pricing-engineimport { PricingEngine } from 'open-pricing-engine';
const engine = new PricingEngine({
rules: [
{
name: 'flat-surface',
type: 'area-based',
unitPrice: 12.50,
unit: 'm2',
minCharge: 25.00,
},
],
});
const result = engine.calculate({
rule: 'flat-surface',
dimensions: { width: 2.0, height: 1.5 },
quantity: 10,
});
// Result:
// {
// rule: 'flat-surface',
// area: 3.0,
// unitPrice: 12.50,
// subtotal: 37.50, // 3.0 × 12.50
// quantity: 10,
// total: 375.00 // 37.50 × 10
// }The engine works for any business where price depends on item dimensions:
- Metal coating & powder painting (price per m²)
- CNC machining, laser cutting (price per area)
- Glass, flooring, fabric (price per m² with minimum charge)
Future versions will support tiered pricing, discounts, and custom formulas — see Roadmap.
| Version | Scope |
|---|---|
| v0.1 | Area-based pricing, JSON config, minimum charge |
| v0.2 | Discounts & surcharges (%, absolute) |
| v0.3 | Price list versioning, effective dates |
| v0.4 | REST API wrapper (Fastify) |
| v0.5 | Interactive playground (React) |
| v1.0 | Plugin system for custom formulas |
open-pricing-engine/
├── packages/
│ ├── core/ — pricing logic (npm package)
│ ├── api/ — REST API wrapper (planned)
│ └── playground/ — interactive demo (planned)
├── docs/ — architecture decisions
└── .github/workflows/ — CI/CD
# Prerequisites: Node.js 22+, pnpm 10+
pnpm install # Install dependencies
pnpm test # Run tests
pnpm typecheck # Type-check
pnpm build # Build
pnpm format # Format codeContributions are welcome! Please open an issue first to discuss what you'd like to change.
- Fork the repository
- Create your branch (
git checkout -b feat/my-feature) - Commit using conventional commits
- Open a Pull Request