# EverShelf — Codebase Map > Deep, factual map of the repository to work without re-reading the monoliths. > Line numbers are for the commit at the time of writing; regenerate the indexes > with `bash scripts/gen-code-index.sh` after large edits. > > Counts and line numbers below were measured on **v2.0.0** and are rounded. ## 1. Top-level layout | Path | What it is | Size / notes | |---|---|---| | `index.html` | SPA shell, all pages as `
` + modals | ~3.8k lines | | `assets/js/app.js` | **The frontend** (one file, everything that is not a module below) | ~46k lines, 1.7k fns | | `assets/js/audit.js` | The quick stocktake (three modes, one ledger) | ~2.7k lines, own file | | `assets/js/screensaver.js` | The idle screen's four cards, its gestures and its timers | ~900 lines, own file | | `assets/js/settings_search.js` | The settings search over the generated registry | own file | | `assets/js/receipt.js` | Paper-receipt OCR (parked, opt-in) | own file | | `assets/js/core/auth.js` | API token helpers (`getApiToken`, `apiAuthHeaders`) | loaded before app.js | | `assets/js/core/dom.js` | `escapeHtml`, `escapeAttr` | loaded before app.js | | `assets/js/core/med.js` + `assets/js/med/italy.js` | Medicine code core + the Italy country module | data-driven | | `assets/js/core/vocab.js` | The vocabulary engine over `vocab.generated.js` | mirrors `api/lib/vocabulary.php` | | `assets/js/core/support.js` | The support/donations dialog (no ads) | own file | | `assets/css/style.css` | All styles (themes, surfaces, screensaver, idle screen) | ~16k lines | | `assets/css/corporate.css` | Corporate/"kiosk" theme overlay | ~640 lines | | `assets/css/elegant.css` | Third layer: the "elegant" restyle **and** the dark-mode repairs it caused | ~740 lines; loaded before `mobile.css`, deletes no selector | | `assets/css/mobile.css` | **Fourth layer: phone geometry only** (no colours) — list rows wrap instead of truncating, badges/quantities move under the text, buttons never break mid-word | ~200 lines; loaded **LAST** so the themes cannot override it; guarded by | | `api/index.php` | **The backend**: router + all handlers | ~25k lines, 519 fns | | `api/bootstrap.php` | Shared init for HTTP + cron | requires every lib | | `api/database.php` | SQLite schema + migrations | ~845 lines | | `api/logger.php` | `EverLog` rotating file logger + `LoggingPDO` | | | `api/lib/*.php` | Domain libs (see §4) | | | `api/cron_*.php` | CLI jobs (smart shopping, mealie cache, barcode catalog) | run by cron | | `api/scale_*.php` | Kitchen-scale gateway relay/discovery | | | `translations/*.json` | 6 languages, nested keys | 3,327 leaf keys each (identical sets) | | `data/` | Runtime DB + caches + logs (**HTTP denied** via `.htaccess`) | not all committed | | `scripts/*` | Maintenance CLIs: generators, i18n audits, importers | | | `mcp-server/` | Node MCP server exposing EverShelf API to agents | separate npm pkg | | `evershelf-kiosk/`, `evershelf-health-bridge/` | Android apps (Kotlin/Gradle) | | The kiosk WebView is themed, not white: `KioskActivity.launchWebView()` sets the surface colour to the splash (`#0C1222`), `onResume` only reloads when the URL is not the configured app any more (the WebView canonicalises `host:8080` → `host:8080/`), and a 5-minute watchdog reloads the page once if a JS probe goes unanswered for 6 s (`page-watchdog-reload` in the error reports). The web side paints `html` with `var(--bg)` so no frame is ever white. | `docs/`, `docs/wiki/` | Documentation | | | `.github/workflows/` | CI: lint (PHP/JS/shell), PHP regression tests, docker build, i18n audit, auto-merge, release | | ## 2. Request lifecycle (backend) 1. Apache rewrites `/api/` → `api/index.php?action=` (`.htaccess`). 2. `api/bootstrap.php` runs: env → constants → github → security → mealie → cron_log → logger → database → shopping_guards → health → weather → ai_provider → **seasonal**. 3. Early, DB-free short-circuits in `api/index.php`: `ping`, `health_bridge_hello`, `kiosk_update`/`getKioskUpdate`, `get_logs`, `gemini_usage`, `health_check`. 4. `getDB()` (SQLite, WAL, busy_timeout 20s) then global exception handlers. 5. Rate limit (`checkRateLimit`) → CSRF guard for write actions → `evershelfRequireApiAuth` → demo-mode block → `switch ($action)` (line ~898). 6. Handlers read `php://input` JSON or `$_GET`, write DB, `echo json_encode`. ## 3. Frontend lifecycle - `DOMContentLoaded` (~line 25800) wires everything; `showPage()` switches `
` visibility; `api()` (line **5384**) is the single fetch wrapper (retries on SQLite `database_busy`, offline queue, error report). - **Splash / boot rail**: `#app-preloader` (index.html) is dressed by `_runStartupCheck()` — one `health_check` call whose ~30 flat checks are grouped into seven stages by `_PRELOADER_STAGE_OF_CHECK`. Each icon is painted by `_preloaderStage(stage, state)`: grey (`is-pending`) → blinking (`is-active`) → coloured with an aura (`is-done`), amber/red for `is-warn`/`is-error`; the version chip `#preloader-version` is rewritten by `scripts/bump-version.sh`. The stages, their labels and the six locales are locked together by. - State held in module-level `let` vars (`shoppingItems`, `LOCATIONS`, `_currentLang`, `_scale*`, banner queue, …). No framework/reactivity. - i18n via `t(key)` + `data-i18n` attributes; `loadTranslations()` fetches `translations/.json`. The boot order is **`?lang=` in the URL → `localStorage.evershelf_lang` → `navigator.language` → `en`** (`_urlLangOverride()` parses `de`, `zh-CN`, `fr_FR` and ignores anything else; `changeLanguage()` rewrites the parameter instead of reloading into the old language locks it). Anything PHP can hand to the UI travels as a key, never as prose: `error_key` (resolved once inside `api()`), `hint_key`, `tip_key`, `reasons[]`, `urgency_label_key`. **Never** print a literal emoji beside a translated label: the values already carry their icon, so use `iconLabel(icon, key)` / `_stripLeadingEmoji` ( enforces it in all six locales). - Dashboard: the alert blocks are capped per block (`DASHBOARD_EXPIRING_MAX` 3, `DASHBOARD_OPENED_MAX` 5, `DASHBOARD_ALERT_MAX` 5 for expired, `DASHBOARD_STALE_MAX` 5). "Dimenticati" ranks by expiry, not by rotation: `forgottenExpiringItems()` (`api/lib/seasonal.php`, reached with `stale_inventory_items&mode=expiry`) returns the nearest expiry dates among the rows that were never used or have been idle for `min_days`, each with `expiry_date` and `days_to_expiry` so the row can print the date. The four lists (`expiring-list`, `expired-list`, `opened-list`, `stale-list`) all bind the same way — `_bindAlertItemsHoldOpen()` → `_bindRowHoldOpen()` — and every row carries `alert-item-clickable` + `data-alert-inv-id`: **a tap opens on touch as well as on desktop** (a hold also works; a pointermove > 12 px cancels it, and a tap on a child button never opens the sheet). Lists where a tap has another meaning pass `tapToOpen: false` (the shopping “suggested” rows). The expiry verdict comes from `getExpiredSafety()` in app.js: the date is a best-before, so the day itself is “Controlla” (the server’s expired query is DATE-ONLY for the same reason), 1–2 days past are “Controlla” in the pantry too, and liquids say “Non bere” instead of “Non mangiare”. A shopping row is a FAMILY row: the payload also carries `family_qty` and the row shows it (never the representative product's own stock), while the “Hai già X in dispensa” hint counts the same `shopping_name` family only. The insight area rotates `_INSIGHT_PHASES` (8 panels, 60 s each) through `_applyInsightPhase()`, which skips any panel whose body is empty. - Settings: `_initSettingsAccordions()` turns every heading-bearing `.settings-card` into an accordion (`_toggleSettingsCard`/`_setSettingsCardOpen`/`_closeSettingsCards`, one open at a time, `SETTINGS_ACCORDION_SKIP = ['settings-checklist']`), and `_openSettingsCardFor(el)` opens + flashes the card a checklist row points at. `SETTINGS_CHECKLIST` drives both the checklist card and the guided assistant. - PWA: `sw.js` caches the app shell; `manifest.json` for install. ## 4. Library reference (`api/lib`) | File | Responsibility | Key entry points | |---|---|---| | `env.php` | `.env` loader + DB-stored overrides; bridges `.env` into `getenv()`/`$_ENV` | `env()`, `loadEnv()`, `evershelfWriteEnvFile()`, `saveEnvOverrides()` | | `demo.php` | **Demo mode**: the flag (`DEMO_MODE`, `?demo=1`, `DEMO_BASE_PATH`), the per-language demo database under `data/demo/` (seeded from `demo_seed.json`, rebuilt daily) and the iframe policy | `evershelfDemoRequested()`, `evershelfDemoLang()`, `evershelfDemoDbPath()`, `evershelfDemoSeedIfStale()`, `evershelfDemoFrameAncestors()` | | `constants.php` | Paths + **Gemini pricing** constants | `EVERSHELF_ROOT`, `*_CACHE_PATH`, `GEMINI_COST_*` | | `security.php` | Auth, CORS, security headers, demo mode, SSRF allowlists, client IP, **outbound report redaction** | `evershelfRequireApiAuth()`, `evershelfSendSecurityHeaders()`, `evershelfClientIp()`, `evershelfScaleHostAllowed()`, `evershelfRedactSecrets()`, `evershelfReportContextJson()` | | `pairing.php` | One-time pairing code for `app_bootstrap` token disclosure; live code also via authenticated `pairing_code` (Settings → Security) | `evershelfPairingEnsure()`, `evershelfPairingConsume()`, `pairingCodeStatus()` | | `github.php` | Encrypted GH Issues token helpers + `REPORT_ENABLED` opt-in | `_ghToken()`, `_ghReportsEnabled()`, used by `report_error`/`report_bug` | | `ai_provider.php` | Provider abstraction (gemini/openai/llama) | `aiProviderConfigured()`, chat/vision calls | | `mealie.php`, `mealie_setup.php` | Mealie recipe-manager integration | discover/install/configure/sync | | `health.php` | Health/Fuel mode + Health Bridge | ingest, profile, daily rollups | | `weather.php` | Weather fetch + geocode | `weather_get`, `weather_geocode` | | `shopping_guards.php` | Anti-waste qty guards + pack-equiv family restock (`shoppingQtyToConfPacks`) | used by `smartShopping` / `shoppingEvaluateFamilyRestock` | | `vocabulary.php` | **The vocabulary engine** (language-neutral): loads `api/vocab/.json` and matches terms — `pane` (word), `pomodor*` (stem), `fette biscottate` (phrase), `estratto+vaniglia` (all of them) — with a Unicode tokenizer, folded diacritics and number forms from the data. No product word and no Italian rule lives here; the browser runs the same engine in `assets/js/core/vocab.js` over the generated `assets/js/vocab.generated.js` | `evershelfVocab()`, `vocabTokens()`, `vocabCategoryOfName()`, `vocabIsPieceProduce()`, `vocabLooksProcessed()`, `vocabIsPreparedSalad()`, `vocabSameLemma()`, `vocabNumberForms()`, `vocabHasPackSize()` | | `product_kind.php` | **Product title rules**: the curated dictionary that leads every article title (now read from `api/vocab/.json`), the signature cache for similar products, the AI fallback, the case of the title and its **number**. `productKindFromDictionary()` is the project's *single* dictionary lookup — `computeShoppingName()` returns it verbatim, so the shopping generic and the title genre never disagree on a known product; `productTitleCapitalize()` raises the first letter of every stored title and `productKindSingularizeName()` stores it as the *singular* of its genre (`Fette biscottate integrali` → `Fetta biscottata integrale`), while `productNameForPieces()` derives the plural back at read time and only for units that count pieces (`listInventory()` ships it as `display_name`, so `500 g Pasta` stays a mass); all of them idempotent | `productKindApply()`, `resolveProductKind()`, `applyProductKindPrefix()`, `productTitleCapitalize()`, `productKindSingularizeName()`, `productNameForPieces()`, `productKindFromDictionary()`, `evershelfProductKindNumberForms()`, `evershelfShoppingPhraseMap()`/`evershelfShoppingKeywordMap()` | | `auto_favorite.php` | **Automatic favourites**: promote the products consumed N times in the window, never overrule a manual unstar | `maybeAutoFavorite()`, `rememberFavoriteOverride()`, `autoFavoriteSweep()`, `autoFavoriteCandidates()` | | `shopping_sync.php` | **Shared Bring!/internal list sync** (markers, smart-item index, "still needed?" predicate) | `evershelfShoppingRowStillNeeded()`, `evershelfBuildShoppingSpec()`, `evershelfLoadSmartItemsForSync()` | | `seasonal.php` | **IT produce calendar** + stale-stock; the review card returns a `tip_key` the client resolves | `seasonalReviewShopping()`, `seasonalIsAllYearCrop()`, `staleInventoryItems()` | | `i18n.php` | Server-side `evershelfTr('key', $lang)` for responses PHP renders itself | used by the ICS feed, the notifier and seasonal tips | | `notify.php` | **Outbound notifications**: ntfy + generic webhook fan-out (legacy HA notify service kept), optional **Web Push** wake via `webpush.php`, i18n-aware event formatting | `evershelfNotifyEvent()`, `evershelfNotifySend()`, `evershelfNotifyConfigured()`, `notifyTestAction()` (in `index.php`) | | `open_prices.php` | **Free Open Prices** (Open Food Facts) barcode price lookup for shopping estimates | `evershelfOpenPricesLookup()`, `evershelfOpenPricesForProductName()`, `evershelfPriceSource()` | | `webpush.php` | **Browser Web Push** (opt-in): VAPID mint, empty-payload fan-out, inbox JSON, per-device inbox token (SHA-256 only) so the worker can read the inbox without the API token | `evershelfWebPushNotify()`, `evershelfWebPushGenerateVapidKeys()`, `evershelfWebPushMintInboxToken()`, `evershelfWebPushInboxTokenValid()`, subscribe/inbox actions in `index.php` | | `push_actions.php` | **Actionable notification buttons** (#122): the signed token a notification carries (`v1\|row\|action\|exp\|hmac`, 12 h, one row one action) and the 1–3 rows → one actionable notification each | `evershelfPushActionSign()`, `evershelfPushActionVerify()`, `evershelfPushActionsForRow()`, `evershelfPushInboxEntries()` | | `monthly_report.php` | **Printable monthly report** (#103): print-first HTML (browser → Save as PDF), same figures as `monthlyStatsData()` | `exportMonthlyReport()` (action), `evershelfMonthlyReportData()`, `evershelfMonthlyReportHtml()` | | `frozen_shelf_life.php` | **Freezer shelf life by category** (data in `data/frozen_shelf_life.json`), plus the 48 h thaw window constant | `frozenShelfLifeDays()`, `frozenShelfLifeTable()`, `EVERSHELF_THAW_DAYS` | | `healthcheck.php` | **Cron watchdog** (dead-man's switch): pings Healthchecks.io or an Uptime Kuma push URL at the end of every CLI job + records the last outcome per job | `evershelfHealthcheckPing()`, `evershelfHealthcheckSend()`, `evershelfHealthcheckConfigured()`, `evershelfHealthcheckStatus()`, `notifyHealthcheckTestAction()` (in `index.php`) | | `calendar_ics.php` | **ICS/WebCal expiry feed** (RFC 5545 emit + token gate) | `evershelfIcsBuild()`, `calendarIcsFeed()`, `getIcsSettings()`, `rotateIcsToken()` | | `recipe_shopping.php` | **Recipe → shopping list** with pantry deduction (recompute the gap on open) | `evershelfRecipeShoppingPlan()`, `recipeShoppingAdd()`, `evershelfBaseQty()` | | `cron_log.php` | Rotates `data/cron.log` | | ## 5. Database schema (`data/evershelf.db`, SQLite/WAL) Core tables (created in `initializeDB`): ```sql products(id PK, barcode UNIQUE, name, brand, category, image_url, unit, default_quantity REAL, notes, shopping_name, created_at, updated_at, -- added by migrations: package_unit, is_favorite, nutriments_json, -- name_user_set, kind (genre), favorite_user_override, ...) inventory(id PK, product_id FK->products ON DELETE CASCADE, location, quantity REAL, expiry_date DATE, added_at, updated_at, -- added by migrations: vacuum_sealed, opened_at, -- frozen_at + pre_frozen_expiry (freezer lifecycle, #286), ...) transactions(id PK, product_id FK, type CHECK IN('in','out','waste'), quantity, location, notes, undone INT, created_at) barcode_cache, shopping_templates, shopping_list(id, name UNIQUE lower, raw_name, specification, added_at, sort_order), app_settings(key PK, value), recipes(id, date, meal, recipe_json, content_hash, is_favorite; partial UNIQUE(date,meal) for scheduled slots only; UNIQUE(content_hash) so chat/use re-saves never clone), chat_messages(id, role, text, created_at), health_daily, ... ``` Indexes: `idx_products_barcode`, `idx_inventory_product`, `idx_inventory_location`, `idx_transactions_product`, `idx_transactions_date`, and composite `idx_transactions_type_date`, `idx_transactions_pid_type_undone`. Migrations are idempotent and guarded (`PRAGMA table_info` / `sqlite_master`); some one-shot data migrations are gated by flags in `app_settings`. ## 6. Runtime data files (`data/`) Most are user/runtime state and git-ignored (`*` = committed static/tracked). | File | Purpose | |---|---| | `evershelf.db` | main DB | | `backups/` | DB snapshots — created by the in-container cron (at most one every 23 h) or `backup.sh`; **inside the data volume**, so copy it off-volume for a real backup | | `bring_token.json`, `bring_catalog.json` | Bring! auth + catalog | | `smart_shopping_cache.json` | computed shopping plan | | `shopping_price_cache.json` | AI price estimates | | `shopping_name_cache.json` * | name→generic mapping | | `product_kind_cache.json` | genre resolved per product signature (similar products reuse it) | | `shopping_total_cache.json` * | canonical list totals | | `shopping_spend.json` | spend ledger | | `ai_usage.json` * | token usage/cost | | `opened_shelf_cache.json` | opened-pack shelf-life | | `category_ai_cache.json`, `food_facts_cache.json` | AI caches | | `seasonal_produce_it.json` * | static IT produce dataset | | `audit_finished_missing.json`, `reported_issue_fps.json` | tool scratch | | `cron.log*`, `error_reports.log`, `client_debug.log` | logs | | `cron_health.json` | last outcome per CLI cron job, written by the watchdog (`api/lib/healthcheck.php`) | | `rate_limits/` | per-IP rate-limit buckets | | `weather_cache_*.json` | weather cache | ## 7. API surface ~180 actions. Full action→handler→line table: **`docs/INDEX-actions.md`**. Groups: - **Products**: `search_barcode`, `lookup_barcode`, `resolve_barcode`, `barcode_catalog_sync`, `stock_for_name`, `product_save/get/delete/merge`, `products_list/search`, `inventory_search`, `ai_product_suggest`, `guess_category`, `products_toggle_favorite`, and **`products_apply_auto_rules`** (POST, `dry_run` preview) which re-applies the two automatic product rules to the items already stored: the title rules in every name — the genre prefix and the leading capital letter (`lib/product_kind.php`) — and the promotion of the products the household keeps consuming to favourites (`lib/auto_favorite.php`). - **Inventory**: `inventory_list/add/use/update/delete`, `inventory_summary`, `inventory_freeze` / `inventory_thaw` (the freezer lifecycle, #286), `family_sibling_suggest`, `inventory_finished_items`, `inventory_confirm_finished`, `inventory_restore_ghost`, `recent_popular_products`. - **Transactions / stats**: `transactions_list`, `transaction_undo`, `stats`, `monthly_stats`, `export_monthly_report` (printable month, #103), `spend_add`, `spend_stats`, `consumption_predictions`, `inventory_anomalies`, `inventory_duplicate_loss_checks`, `dismiss_anomaly`, `macro_stats`, `expiry_history`, `food_facts`, `opened_shelf_life`. - **AI**: `gemini_identify`, `gemini_expiry`, `gemini_chat`, `generate_recipe`, `generate_recipe_stream`, `chat_to_recipe`, `recipe_from_ingredient`, `gemini_product_hint`, `gemini_shopping_enrich`, `gemini_anomaly_explain`, `gemini_number_ocr`, `gemini_barcode_visual`, `tts_proxy`, `ai_test`. - **Shopping**: `shopping_list/add/remove/suggest`, `smart_shopping`, `seasonal_shopping_review`, `stale_inventory_items`, templates, and the `bring_*` family (Bring! mirror). **`recipe_shopping_add`** turns a recipe into the list of what the pantry does not cover (POST, `dry_run` for the render). - **Settings / ops**: `save_settings`, `get_settings`, `app_settings_get/save`, `db_cleanup`, `backup_now/list/delete/restore`, `gdrive_*`, `check_update`, `client_log`, `get_client_log`, `get_logs`, `gemini_usage`, `report_error`, `report_bug`, `migrate_units`, `export_inventory`, `import_inventory`. - **Notifications (ntfy / webhook)**: `notify_test` (POST — pushes one message through every configured channel, ignores `NOTIFY_ENABLED`, reports per-channel HTTP status; the same fan-out runs on every `_fireHaWebhook()` event). - **Cron watchdog (healthchecks.io / Uptime Kuma)**: `notify_healthcheck_test` (POST — pings the typed-or-stored URL once and reports the HTTP status; the stored state is untouched). The CLI jobs ping from cron via `evershelfHealthcheckPing()`; `get_settings` returns `notify_healthcheck_set/_jobs/_status` (never the URL). - **Integrations**: `ha_*` (Home Assistant), `mealie_*`, `health_*`, `weather_get/geocode`, `scale_*` (separate PHP files). - **Calendar (ICS)**: `calendar_ics` (**public**, guarded by its own read-only `ICS_TOKEN` — a calendar client can only GET a URL), `get_ics_settings`, `rotate_ics_token`. ## 8. Auth & trust model - If `API_TOKEN` (or legacy `SETTINGS_TOKEN`) is **empty** (default), every action is open. If set, almost everything needs `X-API-Token`/`?api_token=` (or `Authorization: Bearer`). Public allow-list: `api/lib/security.php::evershelfPublicActions()`. - CSRF: **every** POST requires `X-EverShelf-Request: 1`, whatever the action. Only the actions in `api/lib/security.php::evershelfCsrfExemptPostActions()` — native clients with no browser session to forge (`report_error`, `client_log`, `save_settings`, `health_ingest`, `ha_generate_recipe`) — may fall back to `Content-Type: application/json`. A `
` can send neither a custom header nor JSON, so both proofs are out of reach cross-site. - Demo-mode block list + read-only allow-list also in `api/lib/security.php`. - CORS is off by default; only emitted if `CORS_ORIGIN` is set. ## 9. Config & secrets - Secrets live in `.env` (git-ignored). `save_settings` (~line 8082) rewrites `.env`, or falls back to DB overrides in `app_settings.env_overrides` when the file is not writable. Each fallback entry stores the `.env` value it was saved against: when the file no longer matches (a hand edit followed by a restart) the file wins and the stale entry is dropped, with the event `settings_override_stale` — a DB copy must never shadow `.env` forever (#298). - `.env.example` documents every knob with comments. - `.env`, `data/`, `logs/` are denied by `.htaccess`. - **Scheduling:** `api/cron_smart_shopping.php` is the one job — smart shopping, barcode sync, retention passes and the daily backup. The Docker image runs it every 5 minutes from `/etc/cron.d/evershelf` as `www-data` (`docker/evershelf-cron`); bare metal uses the host crontab. The backup is `createLocalBackup()` in `api/index.php` (`VACUUM INTO` + `.part` rename, retention, `data/backup_last_ts.json`), and *Settings → 💾 Backup* warns when the last one is missing or older than 8 days. ## 10. CI/CD (`.github/workflows`) - `ci.yml`: PHP lint (`php -l` on every file under `api/`), `node -c assets/js/app.js`, translation JSON validity + top-level key parity against `it.json`, a Docker build smoke test, then **auto-merge develop → main** and **create GH Release** using the version in `index.html` (the release body is the `## [x.y.z]` CHANGELOG section for that version, when it exists: `awk` starts at `## [x.y.z]` and stops at the next `## ` heading, so the previous release is never appended, with a 200-line safety cap). The old end pattern `/^## [0-9]/` never matched the bracketed headings and ran to end-of-file — that is why v1.16.1 shipped with the 1.16.0 notes under it. - `build-kiosk.yml`, `build-health-bridge.yml`, `build-scale-gateway.yml`, `publish-docker.yml`, `security.yml`, dependabot. ## 11. Structural debt - `api/index.php` and `assets/js/app.js` are monoliths; `docs/ARCHITECTURE.md` lists a planned split (`api/handlers/*`, `assets/js/features/*`). The router body still sits inside `if (!defined('CRON_MODE'))`, which confuses naive tooling (it reports `checkRateLimit()` as a 1300-line function). - No static analysis configured yet (`phpstan.neon` / ESLint): both need a baseline pass before they can be enforced in CI. - `ca.crt` at the repo root is a local, untracked public CA certificate offered for download in settings (never commit the private key).