Track your compost pile's journey from kitchen scraps to black gold! Log temperature, moisture, C:N ratios, get turn reminders, and predict completion time. Perfect for backyard composters, community gardens, and sustainability enthusiasts.
# Install with Bun (recommended)
bun add compost-tracker
# Or with npm
npm install compost-tracker// REMOVED external import: import { CompostPileManager, CompostAdvisor, MaterialType } from "compost-tracker";
// Create your compost pile
const pile = new CompostPileManager("Backyard Bin", {
targetCNRatio: 30,
idealMoistureRange: { min: 40, max: 60 },
idealTemperatureRange: { min: 54, max: 65 }
});
// Add some materials
pile.addInput({
name: "Kitchen scraps",
materialType: MaterialType.GREEN,
carbonNitrogenRatio: 15,
weightKg: 2,
moisturePercent: 70
});
pile.addInput({
name: "Shredded leaves",
materialType: MaterialType.BROWN,
carbonNitrogenRatio: 60,
weightKg: 4,
moisturePercent: 20
});
// Log today's temperature
pile.addReading({
type: "temperature",
valueCelsius: 62,
depthCm: 30
});
// Get advice from the compost advisor
const advisor = new CompostAdvisor();
const analysis = advisor.analyzePile(pile.getState());
console.log(`Current C:N ratio: ${analysis.currentCNRatio.toFixed(1)}`);
console.log(`Moisture status: ${analysis.moistureStatus}`);
console.log(`Next turn recommended: ${analysis.nextTurnRecommended ? "Yes" : "No"}`);Constructor:
new CompostPileManager(name: string, options?: CompostTrackerOptions)Key Methods:
addInput(options: AddInputOptions): CompostInput– Add green/brown materialsaddReading(options: AddReadingOptions): TemperatureReading | MoistureReading– Log temperature or moistureturnPile(options?: TurnPileOptions): TurnEvent– Record a pile turning eventgetState(): PileState– Get current pile stategetSummary(): PileSummary– Get summary statistics
Key Methods:
analyzePile(pile: PileState): AdvisorAnalysis– Analyze pile health and progresspredictCompletion(pile: PileState, config?: AdvisorConfig): PredictionResult– Predict when pile will be readycalculateDegreeDays(pile: PileState): DegreeDayAccumulator– Calculate thermal accumulation
GREEN– High nitrogen materials (food scraps, grass clippings)BROWN– High carbon materials (leaves, straw, cardboard)
inputs: CompostInput[]– All added materialstemperatureReadings: TemperatureReading[]– Temperature historymoistureReadings: MoistureReading[]– Moisture historyturnEvents: TurnEvent[]– Turning historycreatedAt: Date– Pile creation timestamp
Analysis results including:
currentCNRatio: number– Current carbon-to-nitrogen ratiomoistureStatus: "too_dry" | "ideal" | "too_wet" | "anaerobic_risk"temperatureStatus: "too_cold" | "ideal" | "too_hot"nextTurnRecommended: boolean– Whether turning is adviseddaysSinceLastTurn: number– Days since last turning
const pile = new CompostPileManager("Winter Compost");
// Add weekly readings
pile.addReading({ type: "temperature", valueCelsius: 45 });
pile.addReading({ type: "moisture", valuePercent: 55 });
const state = pile.getState();
const advisor = new CompostAdvisor();
const analysis = advisor.analyzePile(state);
if (analysis.moistureStatus === "too_dry") {
console.log("💧 Time to water the pile!");
}
if (analysis.temperatureStatus === "too_cold") {
console.log("❄️ Pile needs more greens or insulation!");
}// Create a balanced pile
pile.addInput({
name: "Coffee grounds",
materialType: MaterialType.GREEN,
carbonNitrogenRatio: 20,
weightKg: 1
});
pile.addInput({
name: "Shredded newspaper",
materialType: MaterialType.BROWN,
carbonNitrogenRatio: 175,
weightKg: 2
});
const summary = pile.getSummary();
console.log(`Total weight: ${summary.totalWeightKg} kg`);
console.log(`Green:Brown ratio: ${summary.greenBrownRatio.toFixed(2)}`);const prediction = advisor.predictCompletion(pile.getState(), {
targetDegradation: 0.9, // 90% decomposed
climateZone: "temperate"
});
console.log(`Expected completion: ${prediction.estimatedCompletionDate.toLocaleDateString()}`);
console.log(`Confidence: ${prediction.confidence}%`);Found a bug? Have a feature idea? We'd love your help!
- Fork the repository
- Create a feature branch (
git checkout -b cool-new-feature) - Make your changes
- Run tests (
bun test) - Submit a pull request
Check the issues tab for good first contributions and current priorities. Let's make composting more accessible together! 🌱
MIT © AdametherzLab
Happy composting! May your piles be hot, your ratios balanced, and your garden abundant. 🌻