Built
Battery Pricing Engine
Prices a battery from the metals inside it and today's market prices, with an AI second opinion.
The context
A battery recycling business needs to know what a battery is really worth. The value depends on its metal content and on metal prices that change every day.
What I built
- Rule-based pricing: weight × metal percentage × price per kg for each metal, plus margin and overhead
- Price collection from Metals.dev and CommodityPriceAPI, FRED for history, and manual entry as a backup
- Gemini review returning whether a price is underpriced, fair or overpriced, with a fair range, risk level and warnings
- Next.js dashboard with a calculator, commodity ledger, cross-source comparison, charts, CSV export and an admin panel
The hard parts
Sources that disagree
When several sources have a price for the same day, the tool averages them. With no price for today, it uses the latest available one.
Every source uses different units
Prices arrive per tonne, pound or troy ounce, in different currencies. All of them convert to one base currency and unit, which an admin can change.
Strict API limits
Symbols go in small batches, manual fetches are limited to 3 a day, and history is collected in small chunks with delays.
New metals without new code
Metal symbol mappings live in the database, so a metal can be added without a release.
What I'd improve next
- Include each metal's recovery rate, because recycling never recovers 100%
- Use the battery's condition in the price
- Use live exchange rates and schedule price updates
- Forecast prices from the stored history