# CLAUDE.md — BESS-SCADA-Data project guide A FastAPI app that streams BESS SCADA (4-second power) and dispatch (5-minute energy) data live from AEMO NEMWEB. Deployed as a Docker Space on HuggingFace. Nothing is stored server-side; every request fetches fresh from AEMO. ## Where things live ``` app/ main.py FastAPI app, static mounting, cache-busted index config.py AEMO URLs, start dates, timeouts, column lists routers/api.py All HTTP endpoints services/ aemo_fetcher.py FPPDAILY ZIP download (Current + Archive) dispatch_fetcher.py Next_Day_Dispatch ZIP download data_processor.py Polars: parse + filter SCADA CSV dispatch_processor.py Polars: parse + filter dispatch CSV gen_info_fetcher.py AEMO XLSX → BESS list (live → bundled snapshot) analytics.py SQLite request logging (/tmp/analytics.db) data/ bess_list.json Snapshot, refreshed daily by CI workflow bess_list_meta.json Snapshot timestamp + provenance quality_flags.json MW_QUALITY_FLAG descriptions static/ index.html, app.js, style.css (UI) scripts/refresh_bess_list.py Standalone refresher invoked by CI .github/workflows/ sync_to_hf.yml Master push → HF Space deploy (filters binaries) refresh_bess_list.yml Daily cron → regenerates bess_list.json on master ``` ## Deploy flow 1. Push to `master` → `sync_to_hf.yml` runs. 2. The workflow rewrites local history (in the runner only) to strip `app/data/aemo_gen_info.xlsx` from every commit. **HuggingFace rejects any pushed commit that contains a non-Xet binary file**, including historical commits — this filter step exists because of that policy. 3. Force-pushes the filtered history to the HF Space's `main` branch. 4. HF rebuilds the Docker image and swaps the container (~30–60 s). Origin `master` is never rewritten by the deploy. Only HF's `main` is. ## Cache-busting `app/main.py` reads `app/static/index.html` once at startup, substitutes `__VERSION__` with `int(time.time())`, and serves the result from memory. Every container restart = new version stamp = browsers refetch JS/CSS. **Keep the `__VERSION__` placeholders on the `app.js` and `style.css` `