Log crop harvests with yield quantity, quality grade, field, and storage destination. Use when asked to record a harvest, check total yield for a crop or field, filter harvest history by date or grade, view analytics charts, or export harvest data. Triggers include "log harvest", "record yield", "harvest entry", "crop yield", "grade breakdown", "field yield", "harvest history", or any task involving tracking what was picked and where it went.
Record and analyze crop harvest yields with quality grading, field tracking, and storage destination logging.
Each entry records:
| Grade | Meaning |
|---|---|
| A | Premium - meets full market standards |
| B | Standard - minor defects, still marketable |
| C | Substandard - significant defects, reduced price |
| Reject | Not marketable, discarded or composted |
| Ungraded | No quality assessment performed |
The Analytics page uses Chart.js to show:
All analytics support date range filtering.
# Log a harvest
curl -X POST http://localhost:3003/api/harvests \
-H "Content-Type: application/json" \
-d '{
"crop_id": "...",
"field_id": "...",
"harvest_date": "2025-04-18",
"quantity": 142,
"unit": "kg",
"grade": "A",
"storage_id": "...",
"labor_hours": 2.5,
"notes": "Good color, early morning harvest"
}'
# List harvests (filtered)
curl "http://localhost:3003/api/harvests?crop_id=...&from=2025-04-01&to=2025-04-30"
# Filter by grade
curl "http://localhost:3003/api/harvests?grade=reject"
# Get yield by crop (analytics)
curl "http://localhost:3003/api/analytics/yield-by-crop?from=2025-04-01&to=2025-04-30"
# Get yield trend for a crop
curl "http://localhost:3003/api/analytics/yield-trend?crop_id=...&granularity=week"
# Get grade breakdown
curl "http://localhost:3003/api/analytics/grade-breakdown?from=2025-04-01"
# List crops
curl http://localhost:3003/api/crops
# List fields
curl http://localhost:3003/api/fields
# List storage locations
curl http://localhost:3003/api/storage
| Variable | Description | Default |
|---|---|---|
| PORT | HTTP port | 3003 |
| DATA_DIR | SQLite directory | ./data |
| AUTH_PASSWORD | Optional login password | (empty) |
| NODE_ENV | development or production | development |
| SESSION_SECRET | Required in production | (required) |
| DEFAULT_TIMEZONE | Initial timezone for settings | America/Chicago |
Verify harvests exist for the date range and crop: GET /api/harvests?crop_id=.... Analytics endpoints require at least one harvest record within the requested date range.
Ungraded entries are included in the total but shown separately. If you want 100% from A/B/C/Reject only, filter out ungraded entries in the frontend or exclude grade=ungraded from your query.
The CSV export on the Harvests page respects the active filters. Set the date range filter before clicking Export CSV.