- "All products" lists what's here first (My foods, kept products, the food database), then Open Food Facts; if the archive can't be reached, what's here is still shown. A My food picked there is used as it is. - The start of a barcode (4+ digits) finds the products whose barcode starts with it: in the search box, in all products and in the server's search (an index range, so it stays fast). - A meal made with a changed food is worked out again, and so are meals made with that meal and their logged entries (db.follow_meals, app _followMeals). - Saving a food that didn't change writes nothing, so nothing is synced again. - Food search knows a few words in other languages: stomach / žalúdok / pipotă find gizzards, kurací / pui chicken, morčací / curcan turkey. - App 1.1.5 changelog entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| bin | ||
| public | ||
| src | ||
| .gitignore | ||
| config.example.php | ||
| PROTOCOL.md | ||
| README.md | ||
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.