dashboard/server
bashynx 4193de4262 Food, sync and warmer updates from 2026-10-26
- Food: "All products" lists what's here first (My foods, the food database, kept
  products), then Open Food Facts; the start of a barcode (4+ digits) finds the
  products starting with it (dashboard, app, server search).
- Food: My foods barcodes; entries follow edits of their food or meal, and meals
  made with a changed food are worked out again (nested meals too); a save that
  changes nothing isn't written.
- Food: the week strip shows protein / carbs / fat per day, over-target calories
  in red; the header's arrows go by week, days swap in place with prefetch on
  hover; the app's arrows go by week, a sideways swipe by day.
- Food search: stomach / žalúdok / pipotă find gizzards, kurací / pui chicken,
  morčací / curcan turkey.
- Sync: tables a plugin makes after start-up are prepared at the next sync and
  their file read from the start once.
- Warmers build pages as each admin account and wait while someone is using
  the dashboard; slow page builds are logged.
- Stations: impossible sensor readings are dropped; chart ticks never fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 15:45:32 +02:00
..
bin dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00
public dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00
src Food, sync and warmer updates from 2026-10-26 2026-10-26 15:45:32 +02:00
.gitignore dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00
config.example.php dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00
PROTOCOL.md dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00
README.md dashPi: a self-hosted home dashboard, its sync server and phone app 2026-10-24 09:56:19 +02:00

The sync server (dash-sync)

A mailbox for the dashboard's sync. Devices (dashboards, phones) send it encrypted batches of changes and read each other's, in order. It can't read them: the key is made on the first dashboard and never leaves the devices. Plain PHP and SQLite, no daemon, about 500 lines.

You only need it to sync with the phone app or between two dashboards. The dashboard works without it.

Set up

On a Debian / Ubuntu machine with a (sub)domain pointing at it:

sudo apt install apache2 libapache2-mod-php php-sqlite3 certbot python3-certbot-apache rsync
sudo rsync -a server/ /srv/dash-sync/                       # outside any other site's folder
sudo bash /srv/dash-sync/bin/setup-server.sh sync.example.com me

It makes the Apache site and the Let's Encrypt certificate, then the account me and its first device, dashboard, and prints that device's token once. Paste the token into the dashboard's Settings ▸ General ▸ Sync. Phones and other dashboards get their tokens from the dashboard as a QR code; you never come back here for them.

nginx, a shared host, a path instead of a subdomain: ../docs/server.md.

Files

public/index.php     the API: the only thing the web server serves
public/.htaccess     Apache: every request → index.php (mod_rewrite)
src/db.php           storage: one SQLite file in data/
src/food.php         the optional food archive search (an Open Food Facts database you add)
bin/admin.php        accounts and device tokens from the command line
bin/setup-server.sh  the one-time setup above
config.example.php   → config.php: quotas, base path, the food archive
PROTOCOL.md          the API and the encryption, for writing another client

What it keeps

  • Per account:
    • The wrapped data key: the key encrypted with your passphrase (Argon2id), plus a check value.
    • The devices: names, and their tokens' SHA-256 hashes.
    • The batches: encrypted blobs with a sequence number, the device name and the time.
  • Never: the passphrase, the key itself, or any of your data in a readable form.

Quotas (max_account_bytes, default 1 GB) and the answer size are in config.php. Batches aren't pruned yet (see the issues).

Check it

tests/server-setup.sh (from the repo root, needs Docker) runs this setup in a clean Debian container and checks the result: no token → 401, the printed token works, data/ is not reachable.