dashboard/server/README.md
bashynx fb3c01cdd7 dashPi: a self-hosted home dashboard, its sync server and phone app
The dashboard (Raspberry Pi 3.5" screen + web pages), the end-to-end
encrypted sync mailbox (PHP + SQLite) and the Android companion app
(Flutter), with docs, clean-install checks and screenshots made from
demo data.

Built mostly with an AI coding assistant; not yet reviewed line by line
by a human (see README and SECURITY.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 09:56:19 +02:00

2.4 KiB

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.