23 lines
1.6 KiB
Markdown
23 lines
1.6 KiB
Markdown
# Project Overview
|
|
|
|
**Name**: cropwise_weather
|
|
**Tech Stack**: Node.js, axios, pg, dotenv, Cropwise Operations API (v3), PostgreSQL, Chart.js dashboard
|
|
**Last Updated**: 2026-11-10
|
|
|
|
## Architecture
|
|
Scripts fetch field/weather data from Cropwise Operations API. CSV reports locally (`get_weather.js`, `fields_history.js`) and Postgres sync (`fields_history_pg.js` → DB `ak_fields`). Fertilizer write-off acts live in `fertilizer_field_acts` (linked to `fields` by name). Analytics dashboard in `dashboard/` reads aggregates from JSON regenerated by `build-data.js` / `build-dates-data.js` / `build-fertilizers-data.js`.
|
|
|
|
## Key Decisions
|
|
- Reports written as UTF-8 CSV files (with BOM for Excel Cyrillic) instead of console dump — 2026-08-12
|
|
- Field history sync scopes to group_folder subtree root id=27; history_items stored as JSONB on fields — 2026-08-12
|
|
- Field clusters live in `ak_fields.fields_clustered_all` (synced from `fertilizer_project_test`); dashboard is static JSON + HTML, no backend — 2026-11-09
|
|
- Factor pages: dates heatmap (`dates.html`), fertilizers analysis (`fertilizers.html`), fertilizer quality audit (`fertilizer-quality.html`), stub for predecessor; shared site-nav — 2026-11-10
|
|
- Fertilizer acts: table `fertilizer_field_acts` + view `v_fertilizer_field`; join key = field name — 2026-11-10
|
|
|
|
## Known Issues
|
|
|
|
## Resolved Patterns
|
|
- CSV export: `fs.writeFileSync` + `path.join(__dirname, ...)` with season/year in filename
|
|
- PG sync of many fields: Pool + CONCURRENCY workers + resume skip where history_items already set
|
|
- Dashboard rebuild: `npm run dashboard:build` then open `dashboard/index.html` or `npm run dashboard`
|