# flower-farm-math 🌷 **The open-source math behind [Stemwise](https://getstemwise.com).** Three pure, zero-dependency functions for the numbers a small flower farm or farmer-florist runs by hand every week: - **`weddingStems()`** — turn an arrangement list into a real stem count, with a buy-in buffer and a focal/filler/greenery recipe split. - **`csaPricing()`** — costs-up pricing for a bouquet CSA: per-bouquet cost, the price at your target margin, full-season member price, season P&L, and a margin comparison. - **`reconcile()`** — the bloom→sales bridge: compare the stems you'll **cut** against the stems you've **promised**, by variety, and get the shortfall to **buy in** and the surplus to **push to market**. No dependencies. Works in Node and the browser. MIT licensed. **▶️ [Try the live demo + docs →](https://saschaheyer.github.io/flower-farm-math/)** — run all three functions in your browser, no install. > This is the same client-side math our free tools run in the browser — extracted, > tested, and documented so other growers (and the people who build tools for them) > can use it. The hosted product — accounts, bloom plans, CSA management, and the > live weekly reconcile across your whole season — lives at **[getstemwise.com](https://getstemwise.com)**. ## Install ```bash npm install flower-farm-math ``` Or use the CLI without installing: ```bash npx flower-farm-math wedding examples/wedding.json ``` ## Why this exists Every flower-farm tool sits on one side of a gap. **Growing-side** tools (crop planners) know your beds but not who you've sold to. **Selling-side** tools (florist proposal software) assume you *buy* every stem wholesale and have no idea what's blooming in your field. Nobody bridges the two — so the farmer-florist does it by hand every Sunday night across three spreadsheets: > *"Did I overcommit my dahlias this week? What do I have to buy in? What surplus > can I dump at market?"* `reconcile()` is that Sunday-night math as a pure function. The rest of this package is the supporting arithmetic (wedding stem counts, CSA pricing) that the free [Stemwise tools](https://getstemwise.com) are built on. ## Usage ### Wedding stem count ```js import { weddingStems } from 'flower-farm-math'; const r = weddingStems([ { type: 'bridal-bouquet', qty: 1 }, { type: 'bridesmaid-bouquet', qty: 4 }, { type: 'boutonniere', qty: 6 }, { type: 'corsage', qty: 2 }, { type: 'low-centerpiece', qty: 10 }, { type: 'ceremony-arch', qty: 1 }, { type: 'cake-flowers', qty: 1 }, ]); console.log(r.total); // 671 (before buffer) console.log(r.buffered); // 752 (with a 12% buy-in buffer) console.log(r.roles); // { focal: 226, secondary: 188, filler: 150, greenery: 188 } ``` Pass `{ stems }` on any row to override the default, or `{ buffer, roleSplit }` as a second argument. Known arrangement types and their florist-standard stem counts are in [`src/arrangements.js`](src/arrangements.js). ### CSA pricing ```js import { csaPricing } from 'flower-farm-math'; const r = csaPricing({ shares: 30, weeks: 16, stems: 20, costPerStem: 0.35, margin: 50 }); console.log(r.unitCost); // 9.6 ($/bouquet: flowers + packaging + labor) console.log(r.pricePerWeek); // 19.2 (price that yields a 50% margin) console.log(r.seasonPrice); // 307.2 (what a member pays for the season) console.log(r.totalProfit); // 4608 (across 30 shares × 16 weeks) console.log(r.tiers); // 40 / 50 / 60% margin comparison ``` ### Weekly reconciliation (the bloom→sales bridge) ```js import { reconcile } from 'flower-farm-math'; const r = reconcile({ availability: [ // what you'll cut this week { name: 'Dahlia', variety: 'Café au Lait', stems: 120 }, { name: 'Zinnia', variety: 'Benary Giant', stems: 200 }, ], demand: [ // what you've already promised { name: 'Dahlia', variety: 'Café au Lait', stems: 180 }, ], csa: { shares: 12, stemsPerShare: 20 }, // bouquets built from leftover surplus }); console.log(r.shortfalls); // [{ name: 'Dahlia', variety: 'Café au Lait', buyIn: 60, ... }] console.log(r.surplusPool); // 200 console.log(r.marketLeftover); // ...stems left after the CSA is built ``` ## CLI ```text $ npx flower-farm-math csa examples/csa.json Per-bouquet cost: $9.60 (flowers $7.00 + pack $0.60 + labor $2.00) Price / week @ 50% margin: $19.20 (profit $9.60) Full-season member price: $307.20 (16 weeks) Season gross: $9,216 Season profit: $4,608 (30 shares) Margin comparison: 40% → $16.00/wk · $256/season · $3,072 profit 50% → $19.20/wk · $307/season · $4,608 profit 60% → $24.00/wk · $384/season · $6,912 profit $ npx flower-farm-math reconcile examples/reconcile.json BUY IN — short 60 stems across 1 variety: −60 Dahlia / Café au Lait Surplus pool: 250 stems CSA: 12 shares need 240 stems → covered, 10 stems left for market ``` Commands: `wedding`, `csa`, `reconcile`, `types`. Each reads JSON from a file or stdin. Examples are in [`examples/`](examples). ## API | Function | Input | Returns | |---|---|---| | `weddingStems(pieces, opts?)` | arrangement rows (`type` or custom `stems`, `qty`) | `{ total, buffered, roles, lines, arrangements }` | | `csaPricing(input?)` | `{ shares, weeks, stems, costPerStem, packaging, laborMinutes, laborRate, margin }` | `{ unitCost, pricePerWeek, seasonPrice, grossRevenue, totalProfit, tiers, ... }` | | `reconcile({ availability, demand, csa })` | stems by variety on each side | `{ shortfalls, surpluses, surplusPool, marketLeftover, csaShort, rows }` | | `priceAtMargin(cost, marginPct)` | a cost and a target margin | the price that yields that margin | | `ARRANGEMENTS` | — | reference table of stem counts per arrangement type | ## The hosted app `flower-farm-math` gives you the formulas. **[Stemwise](https://getstemwise.com)** gives you the whole workflow: a season-long bloom plan, weddings & market & wholesale & CSA in one place, and the **weekly reconciliation running live across all of it** — so the buy-in list and the market surplus write themselves. - 🌐 **App & free tools:** https://getstemwise.com - 🧮 **Wedding Flower Calculator** (free): https://getstemwise.com/tools/wedding-flower-calculator.html - 🌸 **CSA Pricing Calculator** (free): https://getstemwise.com/tools/csa-pricing-calculator.html - ▶️ **Live demo** (no signup): https://getstemwise.com/app.html ## Tests ```bash npm test # node --test — 9 passing ``` ## License MIT © 2026 Stemwise (Wren Calloway). Use it, fork it, build on it.