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>
This commit is contained in:
Bashy 2026-10-24 09:35:12 +02:00
commit fb3c01cdd7
333 changed files with 45151 additions and 0 deletions

58
docs/architecture.md Normal file
View file

@ -0,0 +1,58 @@
# How it fits together
```
3.5" SPI screen ◄── dash.py (Pillow → RGB565 → /dev/fb0) ──┐
touch (evdev) ──► │ one Python process:
│ workers fill a shared Store,
browser / TV ◄── web.py (Flask, :8080) ─────────────────┤ the screen and the web pages
│ read it
plugins/<name>/ (pages, workers, data in dash_data/<name>/*.db)
│
syncdb.py stamps every change; sync.py sends / receives
│ XChaCha20-Poly1305, key never leaves the devices
▼
server/ (PHP + SQLite): encrypted batches, in order
▲
app/ (Flutter): its own SQLite copy, same merge rules
```
## The dashboard (`dashboard/`)
- **No X, no Wayland.** Each tick `screens.render()` draws a 480×320 PIL image, `panel.to_rgb565()` packs it,
and it's written to the panel's framebuffer
(found by itself: `panel.find_screen`; none = web pages only). Redraws about once a second and on touch.
- **Store** (`store.py`): the shared state the workers fill (weather, calendar, sensors) and the screen and
pages read.
- **Plugins** (`pluginhost.py`): every feature beyond the clock is a package in `plugins/<name>/` with a `META`
and `register(ctx)`. `ctx` is the whole API: a blueprint for pages, Home regions, 3.5" screens,
workers, settings fields, cached pages, sync specs. A plugin keeps its data in `dash_data/<name>/`.
Turning one on or off needs no restart.
- **Web** (`web.py`): Jinja pages that fill a landscape screen without scrolling and stack on phones. They
refresh every minute and reload after a deploy.
- **Users** (`auth.py`): admin, members (a subset of sections), and the household (no login, read only;
also what the 3.5" screen shows).
- **Settings** (`settings.py`): `dash_config.json`, validated, applied live where possible.
Import direction is one way: `config` ← `store` ← `panel` ← screen modules ← `dash`. The plugins only use `ctx`
(the built-in weather, calendar and stations plugins also use the Store and the drawing helpers).
## Sync
Every device keeps a full copy. Changes go through the server, which only stores encrypted batches.
- `syncdb.py` adds `_uid`, `_hlc` (hybrid logical clock, ms) and `_dev` to every synced table, and triggers that
stamp each insert/update and turn deletes into tombstones. Plugin code doesn't change.
- Which tables sync is each plugin's `META["sync"]`. Foreign keys travel as the target's `_uid`.
- Merge: the last change wins by (`_hlc`, `_dev`); a tombstone beats older changes. Notes are documents with
revisions, and two edits made at the same time keep both, as a conflicted copy.
- Keys: one random data key, wrapped on the server with Argon2id(passphrase). The recovery key is the data key
in base32.
The full protocol, which the app follows to the letter: [server/PROTOCOL.md](../server/PROTOCOL.md).
## The app (`app/`)
Flutter, Android. `lib/sync/` is the protocol (store, crypto, client). `lib/health`, `lib/work`, `lib/notes`
and `lib/weather` are the pages. They are ports of the dashboard's views, and their numbers must match.
Health summaries from the band (sleep, heart rate, energy) are worked out on the primary dashboard and
synced to the app one way.