Document today's restructures, and give data/ a README that ships with it

This commit is contained in:
Gmer4Lfe
2026-08-09 00:01:05 -04:00
parent 38cd3edf99
commit 3a45c18555
12 changed files with 243 additions and 29 deletions
+29 -1
View File
@@ -105,11 +105,39 @@ once, and the endpoint, the cache writer, and the page all pick it up together.
| `api/` | 50 | JSON endpoints the pages poll, plus action endpoints (run a script, stop a job, toggle a flag) |
| `include/` | 16 | Shared builders and helpers — `vv_monitor_*`, `vv_arrs_*`, `vv_docker_*`, config read/write, auth |
**Caching.** Several endpoints serve from `/tmp/vv_cache` (tmpfs) rather than hitting live
**Caching.** Several endpoints serve from `$VV_CACHE_DIR` (`/tmp/varaverk/api`, tmpfs) rather than hitting live
APIs on every page view, refreshed by `Tools/api_cache_writer.sh`. `?live=1` bypasses the
cache. A missing or unparseable cache always falls back to a live call, so the cache can never
be the reason a page fails to load.
Anything expensive belongs in that one collection rather than in each consumer. `vv_ai_stats()`
costs about a second — mostly waiting on Ollama and `nvidia-smi` — and the AI tab was paying it
every 30 seconds per open tab; it is now written once to the `ai` cache and read by the tab, the
Monitor row and the dock alike. Polling faster cannot make a figure newer, it only decides how
soon a page notices the writer's update.
> `Tools/api_cache_writer.php` rebuilds the monitor payload **independently** of
> `api/monitor.php`, and is what the page normally reads — the endpoint only assembles one on a
> cache miss. A key added to the endpoint and not to the writer leaves its card loading forever
> on every ordinary page load and working only on the request that happens to miss.
**One widget, rendered twice.** `include/ai_chat.php` owns the conversation surface — profile
bar, transcript, composer, source viewer, stored-chat list — and both the AI tab and the Monitor
tab's AI row construct it. Every id is composed from a prefix so instances can coexist, and each
tears down the previous holder of its prefix, because Unraid swaps tab content by AJAX without
unloading the old page's JavaScript.
The Scheduler tab's dock is deliberately *not* built on it: a one-line bar that follows the view
you have open, with its own scope chip, fix flow and incident capture, is a different component
that happens to share an endpoint. Folding it in would produce one widget with two personalities
and a mode flag choosing between them.
**Timezone.** `include/config.php` adopts Unraid's own `timeZone` from `ident.cfg` for the whole
PHP layer. PHP here has no `date.timezone` and therefore ran in UTC while the server ran local,
so every date this layer produced was offset from every date the shell layer wrote — and the two
are compared constantly. `/etc/php.ini` is the wrong fix twice over: `/etc` is a RAM filesystem
so the edit dies at reboot, and it would retimezone every other PHP application on the box.
---
## ━━━ WHAT GUARDS THE API LAYER ━━━