Merge develop into main: the docs, including the root README

main was one commit behind and the commit it lacked added the root README --
the file whose whole purpose is to orient someone who lands on the default
branch. Leaving it only on develop defeats the point of having written it.

No conflicts. The merge base is f9d0b09 and main had added nothing of its own
since then, so this only catches it up; the resulting tree is byte-identical to
develop's, checked before committing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Thomas KarnerandClaude Opus 5 committed 2026-09-21 23:04:26 +02:00
commit a9d5ce86e6
6 files changed
+1261 -2

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
# poorBird
A radar-triggered bird camera. An ESP32-S3 watches a feeder with a 24 GHz
radar module, photographs whatever moves, and uploads it to a small server on
the same LAN that stores the images and shows them in a gallery you can label.
Radar rather than a PIR motion sensor: it sees through a plastic housing,
does not care about warm air or moving branches, and reports distance and
signal energy, which is enough to tell "a bird landed" from "the hedge moved".
```
ESP32-S3 + LD2410 radar FastAPI + PostgreSQL 17 React gallery
------------------------ ----------------------- -------------
detects, photographs, ----> stores, thumbnails, <---- browse, filter,
buffers, uploads authorises label
plain HTTP :8080 loopback :8090 over TLS
```
## Where things stand
Honestly, because a status table that flatters is worse than none:
| Part | State |
|---|---|
| **Firmware** | Written, compiles, **never run on hardware.** |
| **Device↔server contract** | Specified in full and implemented on the server. **Never yet exercised by real firmware.** |
| **Server** | Phases 1–2 and the Phase 3 server half. 308 tests against real PostgreSQL 17. **Not yet on the real host.** |
| **WebUI** | Login and a working cursor-paged gallery. Devices and System are honest empty states waiting on Phase 4. |
| **Backups** | **None.** Phase 5. Do not let captures you care about accumulate yet. |
Nothing here has been released, and `main` means "the project", not "a
release".
## Start here
| If you want to | Read |
|---|---|
| use it, in plain language | [`docs/README.USER.md`](docs/README.USER.md) · [Deutsch](docs/README.USER.de.md) |
| install it on a Linux box | [`server/deploy/INSTALL.md`](server/deploy/INSTALL.md) |
| work on the server | [`server/README.md`](server/README.md) |
| work on the UI | [`web/README.md`](web/README.md) |
| work on the firmware | [`firmware/README.md`](firmware/README.md) |
| know what is broken or unfinished | [`docs/OPEN-TOPICS.AI.md`](docs/OPEN-TOPICS.AI.md) |
| know *why* it is built this way | [`SPEC.md`](SPEC.md) |
| know what is next | [`TODO.md`](TODO.md) |
Two documents outrank the rest. [`firmware/API.md`](firmware/API.md) is the
device contract: the camera cannot be patched from a laptop once it is mounted
outdoors, so where the server and that document disagree, the document wins.
[`SPEC.md`](SPEC.md) holds the decisions and the reasons, which is what keeps
a later change from quietly undoing an earlier one.
## Layout
```
firmware/ ESP32-S3 sketch (PlatformIO) + API.md, the device contract
server/ FastAPI, PostgreSQL, the job queue, the CLI, systemd + Caddy
web/ React gallery, built on your machine and shipped as static files
docs/ user guides, open topics, and per-branch code reviews
SPEC.md the design and the reasoning behind it
TODO.md phase-by-phase plan and the open questions
```
## Constraints that are not up for negotiation
These are decided in `SPEC.md`, and they explain choices that would otherwise
look old-fashioned:
- **No containers.** Native packages and systemd units on an x86 thin client.
- **PostgreSQL, not SQLite.** The job queue needs `FOR UPDATE SKIP LOCKED`.
- **No Redis.** The queue is a table; one fewer service to run and back up.
- **Caddy, not nginx.** It gets a real certificate for a LAN-only hostname
over DNS-01, so there is no browser warning and no port forwarding.
- **The camera speaks plain HTTP.** TLS on an ESP32 means a CA baked into
firmware and a mounted camera that stops uploading when the chain rotates.
- **Images are never served straight off disk.** The app authorises the
request and Caddy sends the bytes. An unguessable URL is not access control.
- **Logs go to stdout.** journald catches them; the app manages no log files.
## Quick start on a dev machine
```bash
# server
cd server && python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/poorbird check # says what is misconfigured, and why
.venv/bin/poorbird migrate
.venv/bin/poorbird user add me --role admin
.venv/bin/poorbird seed --captures 500 # something to look at
.venv/bin/poorbird serve
# UI, in another terminal
cd web && npm install && npm run dev # http://localhost:5173
```
On Windows the venv puts those executables in `.venv\Scripts\` rather than
`.venv/bin/`; [`server/README.md`](server/README.md) covers that setup, uv and
Podman included.
There is no sign-up page and no default account, on purpose — a shipped
default credential is a backdoor. Accounts are created with the CLI.
Two settings need flipping for local development, and both say why in
[`server/deploy/poorbird.env.example`](server/deploy/poorbird.env.example):
`POORBIRD_SESSION_COOKIE_SECURE=false` (a `Secure` cookie is dropped over
plain HTTP, so login silently never sticks) and
`POORBIRD_SERVE_IMAGES_DIRECTLY=true` (there is no Caddy to hand the files to).
+386
View File
@@ -0,0 +1,386 @@
# Open topics and unfixed security issues
**Scope:** the whole repository, `develop`.
**Written against:** `f9d0b09` plus the deploy changes committed alongside this file.
**Date:** 2026-09-21.
**Audience:** an AI or a maintainer picking this up cold.
---
## How to read this
This is a list of what is **not** done, deliberately or otherwise. It is not a
review of the code that exists — for that, see
[`reviews/`](reviews/), which holds branch-scoped snapshots.
Three labels are used, and the difference between them is the point of the
document:
| Label | Means |
|---|---|
| **ACCEPTED** | A known trade-off, decided on purpose, with the reasoning recorded. Do not "fix" one of these without reopening the decision — several exist specifically to prevent a well-meant change that breaks something worse. |
| **OPEN** | A real gap. Not yet paid for. Fixing it is straightforward and wanted. |
| **TRAP** | Works as written, but will mislead someone. Usually a default, a missing step, or a silent failure mode. |
Every claim below was verified against the code at the commit named above.
Where a line number is given, it was read, not remembered. If you are reading
this later and a reference does not match, trust the code.
---
## 1. Security — accepted trade-offs
### 1.1 ACCEPTED — the device link is plain HTTP, and the token rides on it
`SPEC` C2. The camera speaks unencrypted HTTP on `:8080`
(`server/deploy/Caddyfile`, the `:8080` block). TLS on an ESP32-S3 means a CA
baked into the firmware image and a camera that silently stops uploading when
that chain rotates — while mounted outdoors, where it cannot be reflashed.
**What this actually exposes:** the device bearer token crosses the LAN in
cleartext on every request. Anyone already on the network can capture it and
then impersonate that camera indefinitely — post fabricated captures, drain
its command queue, read its config. Passive capture of the images themselves
is the lesser problem.
**What would fix it without TLS:** HMAC request signing with a per-device key,
which is cheap on an ESP32 and needs no certificate chain. It requires a
coordinated firmware change, so it is a `firmware/API.md` contract revision,
not a server-side patch.
**Why it stays:** the threat model is a home LAN behind Tailscale. Worth
revisiting the moment this is reachable from anywhere else.
### 1.2 ACCEPTED — one enrollment secret, shared, compiled into firmware
`POORBIRD_ENROLL_SECRET` is one value for all cameras
(`server/src/poorbird/config.py:84`) and is compiled into the firmware image as
the last-resort recovery path for a camera that cannot be reached over USB
(`firmware/API.md`).
Consequences, both real: extracting the flash of one camera yields the
enrollment credential for the whole fleet; and rotating it on the server
without shipping new firmware removes the only way back into a mounted camera.
Both are documented at the point of use, including in `config.py` and
`deploy/poorbird.env.example`.
Per-device pre-shared keys would fix the first and worsen the second.
### 1.3 ACCEPTED — failed logins are limited by address, never by username
`api/ratelimit.py:201` — `LOGIN = Limit.per_hour(30, burst=8)`, keyed
`by_address`.
Keying on username would let anyone lock a known account out of its own
service by guessing at it, which converts a nuisance into a denial of service
against a specific person. The cost of the choice is the mirror image: an
attacker spread across many source addresses gets proportionally more
attempts, and a legitimate user sharing a NAT with an attacker gets throttled.
There is deliberately **no account lockout** for the same reason.
### 1.4 ACCEPTED — `SameSite=Lax`, not `Strict`
`api/sessions.py`. `Strict` means following a link from anywhere outside the
app presents as signed out, which trains people to distrust the login. `Lax`
permits the cookie on top-level cross-site **GET** only; every mutation is
POST/PUT/PATCH/DELETE and goes through the CSRF middleware, so the residual
exposure is limited to read-only navigations.
### 1.5 ACCEPTED — device endpoints have no CSRF check
`api/userauth.py`, `csrf_middleware`. It returns early unless the method is
unsafe **and** the request carries the session cookie. Device requests are
bearer-authenticated and carry no cookies, so they are never in scope — which
is correct, because CSRF is an attack on ambient browser credentials and a
camera has no browser.
**Do not "fix" this by applying CSRF to all unsafe methods.** It would break
every device endpoint and protect nothing.
### 1.6 ACCEPTED — images are authorised by the app, served by Caddy
`api/delivery.py` + the `protected_files` snippet in `deploy/Caddyfile`. The
app checks the session, then returns an empty 200 carrying
`X-Accel-Redirect`; Caddy reads the file. `serve_images_directly=true` makes
the app send the bytes itself, for development where there is no Caddy.
The flag does **not** relax authorisation — the same check runs in both paths,
and the only difference is how an already-authorised response is finished.
This was built as one code path with two endings, specifically to avoid a
separate unauthenticated dev route, which is the kind of thing that survives
into production because it works.
`_safe_absolute()` resolves the stored relative path and answers 404 — not
403 — on any escape from the configured root. The traversal test escapes to a
canary file that genuinely exists outside the root; it was originally written
against `/etc/passwd`, which does not exist on the Windows dev machine, so it
would have passed with the guard removed. Keep the canary.
---
## 2. Security — open, not yet paid for
### 2.1 OPEN — a TOTP code can be replayed for ~90 seconds
`totp.py:25` sets `VALID_WINDOW = 1`, so the previous, current and next
30-second steps are all accepted. Nothing records which codes have been used,
because there is no column for it. An observer who sees a code once can use it
until its window closes.
**Fix:** add `users.totp_last_counter`, reject any counter `<=` the stored
value, and persist on success. One migration, a few lines in
`api/routes/auth.py` around the check at `auth.py:135-140`.
The limitation is documented in the `verify()` docstring rather than left
implicit. On a Tailscale-only LAN the observer has already had to get onto the
network; that stops being reassuring the day this is public.
### 2.2 OPEN — TOTP cannot be added, removed or repaired after account creation
`cli.py` exposes only `user add`, `user list` and `user passwd`. There is **no
`user delete`** and no way to change the second factor later.
Three consequences, all reachable today:
- An account created with `--no-totp` (`cli.py:133-134`, which warns) stays
without a second factor permanently.
- Losing the `otpauth://` URI — printed exactly once — bricks that account.
There is no recovery path short of editing the database.
- A wrong `--role` or a typo'd username cannot be undone.
The dev admin `me` on this machine was created with `--no-totp`, so it is an
instance of the first case.
**Fix:** `poorbird user totp --enable|--disable NAME`, `poorbird user delete
NAME`, `poorbird user role NAME --role X`. All small; none exist.
### 2.3 OPEN — `audit_log` only records authentication
`api/routes/auth.py` writes `login`, `login_failed` (with a reason) and
`logout`. Nothing else writes to the table. Content mutations — observations,
tags, device config, keep/reject decisions — leave no trace, so "who changed
this label, and when" is currently unanswerable.
The table and its `ON DELETE SET NULL` on `user_id` are already in the schema,
so this is purely a matter of adding writes as each endpoint lands. Recorded in
`TODO.md` Phase 3.
### 2.4 OPEN — no password reset, and no second admin by default
If the only admin's password is lost, recovery is manual SQL. `user passwd`
requires shell access on the server, which is the intended trust model, but it
means there is no in-band recovery at all. Worth at least documenting a
"create a second admin" step; worth more if this is ever used by someone other
than its author.
### 2.5 OPEN — rate limits are per-process, and nothing enforces one process
`api/ratelimit.py` uses in-process token buckets, sized for a single uvicorn
process. Running with `--workers N` silently multiplies every effective limit
by N, including the login limit.
Nothing in `deploy/poorbird-api.service` prevents that being added later by
someone reasoning that more workers is faster. SPEC C8 rules out Redis, so the
fix is either a Postgres-backed limiter or an assertion at startup that there
is exactly one worker. Currently it is a comment in the module docstring.
---
## 3. Traps
### 3.1 TRAP — `api_port` defaults to 8080, which is the camera's Caddy port
`config.py:52` — `api_port: int = 8080`. Meanwhile
`deploy/poorbird.env.example:30` sets `POORBIRD_API_PORT=8090`, and
`deploy/Caddyfile` proxies to `127.0.0.1:8090` and itself binds `:8080` for
the camera.
So the code default and the deployment disagree, and the default collides with
Caddy's own listener. Any host where `POORBIRD_API_PORT` is unset gets uvicorn
on `127.0.0.1:8080` — contending with Caddy's `:8080` site and unreachable
from the proxy, which is looking at 8090.
**Fix:** change the default in `config.py` to `8090` so code and deployment
agree. Trivial, and nothing depends on 8080.
### 3.2 TRAP — `POORBIRD_SESSION_COOKIE_SECURE` fails silently and invisibly
A `Secure` cookie is discarded by the browser over plain HTTP. The login
returns **200**, the session row is created, and the browser is not signed in.
Nothing appears in any log, because from the server's point of view nothing
went wrong.
This is documented in three places now (`config.py:92-97`,
`poorbird.env.example`, `web/README.md`) and, as of this commit, in
`deploy/INSTALL.md` next to the "for a first test, drop the `tls` block"
suggestion that triggers it. It stays on this list because the failure mode is
undetectable from the server side and costs an hour every time it is met fresh.
### 3.3 TRAP — a `git pull` on the host never updates the UI
`web/` is built on the dev machine and shipped as static files (SPEC §6).
There is no Node on the server and no build step in
`deploy/poorbird-api.service`. Pulling and restarting gives a new API with the
old bundle, and the mismatch shows up as UI features that appear not to work.
Covered in `INSTALL.md` step 7 and the Upgrading section as of this commit.
Vite emits content-hashed filenames, so the copy must use `--delete` or stale
bundles accumulate indefinitely.
### 3.4 TRAP — running the test suite deletes seeded captures
`tests/test_seed.py:36-49`, the `no_seed_left_behind` autouse fixture, sweeps
`Device.device_uid.startswith(SEED_UID_PREFIX)` and deletes every match plus
its captures. A developer's own `poorbird seed --captures 500` uses that same
`5eed` prefix, so **`pytest` destroys it.** Observed twice on 2026-09-21.
The fixture cannot delegate to `clear()`, because `clear()` is the function
under test — a broken `clear()` would then leave the database dirty *and* hide
that it was broken. So it re-derives the scope, and the derived scope cannot
distinguish a test's seed device from a person's.
**Fix:** have the fixture record the device ids it creates and delete exactly
those.
**Not at risk:** user accounts and real camera devices. Every other teardown
in the suite deletes by explicit id — verified across
`test_auth.py:110`, `test_captures.py:73,127-128`. The `garden-feeder` device
on the dev machine has survived every run.
### 3.5 TRAP — the test suite shares the development database
`tests/conftest.py` connects to whatever `POORBIRD_DATABASE_URL` points at,
and `test_schema_matches_models.py` additionally creates and drops a
`poorbird_schema_check` database on the same server, needing a role that may
`CREATE DATABASE`. Combined with 3.4, running tests against a database that
holds anything you care about is a mistake waiting to happen.
Mutation-testing `clear()` was done against an isolated scratch database for
exactly this reason.
---
## 4. Deployment — changed in this commit, and unverified
`deploy/Caddyfile` previously had no `file_server` for the built UI, and
FastAPI mounts no static files, so **nothing served the WebUI in production**.
`INSTALL.md` also never created an account, so a by-the-book install ended at
a login form with no usable credentials.
Both are addressed in this commit. What that is worth:
- The Caddyfile **syntax is validated** — `caddy validate` via the official
`caddy:2` image, with the cloudflare-DNS `tls` block stripped because that
plugin is not in the stock image and that block is unchanged. Result: *Valid
configuration*.
- `npm run build` was run: typecheck clean, 192 modules, 400 kB → 127 kB gzip.
- **Nothing has been run on a real host.** The `try_files` fallback, the
`X-Accel-Redirect` handoff against a real Caddy, the systemd units and the
account-creation step under `sudo -u poorbird` are all unexercised. Treat
section 6-8 of `INSTALL.md` as untested instructions.
The whole install has never been performed end to end. Until it has, the
deploy directory is a plausible plan, not a proven procedure.
---
## 5. Test and process debt
| | |
|---|---|
**OPEN** | No ESLint. `tsc --noEmit` catches the important class of mistakes; the flat-config setup was skipped during scaffolding and never revisited.
**OPEN** | No test runs the UI. There is no component or end-to-end test in `web/` at all — the gallery's behaviour is covered only by the server tests behind it and by looking at it.
**OPEN** | Virtualisation is unmeasured. The grid is built to recycle rows and the data path is verified over 506 captures, but nothing asserts that DOM node count stays bounded as you scroll. That is the property the whole design exists for.
**ACCEPTED** | Two tests once passed for the wrong reason, both now fixed: a pool-size assertion whose expected value equalled SQLAlchemy's own default, and the traversal test described in 1.6. The lesson is recorded here because it generalises — assert against values that differ from the library's defaults, or the test cannot fail.
**ACCEPTED** | Reviews under `reviews/` are point-in-time snapshots and are deliberately **not** updated. Their "12/12 tests" and "what's missing" sections describe the commit in their header. Several reference implementations in them are wrong; where that mattered, the code that replaced them says so.
---
## 6. Functional gaps, by phase
**Phase 3, still open:**
- `taxa` is not seeded, so there is no species list. Taxon and tag filters are
therefore absent from both `GET /api/v1/captures` and the UI — deliberately,
rather than shipped as controls with nothing behind them.
- No observation editor. The gallery reads and displays observations; nothing
writes them. Labelling, the actual point of the project, does not exist yet.
- `users.theme` and `users.locale` are in the schema and returned by
`/auth/session`, but the UI keeps both in `localStorage`. A second browser
starts from the default.
- The viewer steps only through loaded captures. At the end of a page the
arrow disables rather than fetching the next one.
**Phase 4:**
- No device listing endpoint, so the Devices page is an honest empty state and
the gallery's device filter is built from whatever devices appear in loaded
captures.
- No admin `POST /api/v1/firmware`, so OTA images cannot be uploaded through
the UI.
- `firmware.is_target` has no single-row constraint. Two rows marked as the
target is a state the schema currently permits and the OTA logic does not
expect.
- CORS is unconfigured. Correct today — Caddy serves UI and API from one
origin — but it needs a deliberate answer before anything is ever served
from a second origin, rather than a permissive header added under pressure.
**Phase 5:**
- **No backups of any kind.** Blocked on open question 9 (whether the NAS
offers SFTP or only SMB/NFS), which decides between restic and a mounted
path. The image store and the database are both unprotected. This is the
single largest operational gap in the project.
- No retention or pruning. Captures accumulate without bound; `kept` exists in
the schema but nothing acts on it.
**Phase 6:**
- `/stream` is unimplemented. It is the one part of `firmware/API.md` with no
server side at all.
---
## 7. Not problems — do not re-open these
Listed because each one looks like an oversight and is not.
- **Sync SQLAlchemy, not async.** Deliberate. The workload is a handful of
concurrent requests and a background worker; async buys nothing here and
costs a second idiom for every contributor.
- **The job queue is a Postgres table** using `FOR UPDATE SKIP LOCKED`, not
Redis or Celery (SPEC C8). One fewer service to run, monitor and back up.
- **Device tokens are SHA-256, user passwords are Argon2id.** Not an
inconsistency. Device tokens are 256-bit CSPRNG output, so there is nothing
to brute-force and a slow hash would only add latency to every ingest;
passwords are human-chosen, so slowness is the entire point. Both are
explained at `api/deps.py.hash_credential` and `passwords.py`.
- **`verify_password` returns `False` instead of raising** for `None`, `""` or
a corrupt hash. Every Phase 1 row has a NULL `password_hash`, so raising
would turn a normal state into a 500.
- **Password rehash on login is already wired** (`auth.py:147`,
`needs_rehash`). If Argon2 parameters change, hashes migrate as people sign
in.
- **The login endpoint hashes a password even when the username does not
exist**, discarding the result. Without it, a missing username returns
measurably faster than a wrong password, which is a username oracle.
- **CSRF is compared against the token on the session row**, not merely
cookie-against-header. Plain double-submit accepts any self-consistent pair,
so anyone able to set a cookie on the domain satisfies it while the victim's
session cookie rides along.
- **`0001_initial.py` is frozen explicit DDL.** It used to call
`Base.metadata.create_all()`, which meant a clean database got the current
models and then later migrations tried to add columns that already existed.
Do not edit it to reflect a model change; add a revision.
- **`pool_timeout` is finite (30s), on purpose.** An infinite timeout turns a
pool leak into a permanent hang with no error.
- **`received_at` is authoritative, not `captured_at_device`** (SPEC C7). The
camera has no battery-backed clock; `captured_at_device` is NULL when it was
unsynced and must never be rendered as 1970.
- **Model-sourced observations are badged as predictions.** The observations
table is also the training data for any future model, so a guess displayed
as a human label would poison it.
- **The purge of expired sessions lives in `worker/handlers.py`**, not
imported from `api/`. The worker must not import from the API layer; that
layering rule is why `images.py` sits at the package root.
+355
View File
@@ -0,0 +1,355 @@
# poorBird — Anleitung für den Gebrauch
*English version: [`README.USER.md`](README.USER.md)*
Diese Anleitung erklärt, wie man poorBird **benutzt**, nicht wie man es
entwickelt. Sie setzt voraus, dass du einen vorgegebenen Befehl in ein
Terminal kopieren kannst — mehr nicht. Jeder Fachbegriff wird dort erklärt, wo
er zum ersten Mal auftaucht.
---
## 1. Was es eigentlich macht
Du hängst eine kleine Kamera an ein Vogelhaus. Sie beobachtet die Futterstelle
mit einem **Radarsensor** — kein kamerabasierter Bewegungsmelder, sondern ein
Bauteil, das ein harmloses Funksignal aussendet und merkt, wenn sich davor
etwas bewegt. Kommt ein Vogel, macht die Kamera eine Bildserie und schickt sie
über dein Heimnetz an einen kleinen Rechner im Haus. Dieser Rechner speichert
die Bilder und zeigt sie in einer Webseite, in der du sie durchsehen und
festhalten kannst, welchen Vogel du gesehen hast.
**Warum Radar und kein normaler Bewegungsmelder?** Ein klassischer
Bewegungsmelder — die Sorte in einer Außenlampe — reagiert auf Wärme. Er löst
aus, wenn die Sonne herauskommt, wenn warme Luft zieht, wenn ein Zweig
schwankt. Radar erkennt echte Bewegung und meldet zusätzlich, *wie weit weg*
sie war und *wie stark* sie war. Das genügt, um „ein Vogel ist auf der Stange
gelandet" von „die Hecke hat sich im Wind bewegt" zu unterscheiden. Außerdem
funktioniert Radar durch ein Kunststoffgehäuse hindurch, der Sensor bleibt
also trocken.
**Drei Teile, und jedes kann für sich ausfallen:**
| Teil | Was es ist | Wo es sitzt |
|---|---|---|
| Die Kamera | Eine kleine Platine mit Objektiv und Radarsensor | Draußen, am Futterhaus |
| Der Server | Ein Programm, das Bilder speichert und die Webseite beantwortet | Ein kleiner Rechner im Haus, dauerhaft an |
| Die Webseite | Die Galerie, die du ansiehst | In deinem Browser |
Die Kamera behält selbst nichts auf Dauer. Die Bilder liegen auf dem Server.
Geht die Kamera kaputt oder wird sie gestohlen, ist alles bereits Hochgeladene
sicher.
---
## 2. Was du vorher brauchst
- Den **Server**, eingerichtet und laufend. Das ist eine eigene, technischere
Aufgabe: [`../server/deploy/INSTALL.md`](../server/deploy/INSTALL.md).
- Ein **Konto**. Es gibt bewusst nirgends einen „Registrieren"-Knopf — warum,
steht gleich unten.
- Einen Browser im selben Netz.
### Es gibt keine Registrierung und kein Standardpasswort
Viele Geräte kommen mit einem eingebauten Zugang wie `admin` / `admin`. Das
ist eine Hintertür: alle kennen sie, und die meisten ändern sie nie. poorBird
hat kein solches Konto. Wer Zugang zum Server hat, muss dein Konto bewusst
anlegen:
```bash
poorbird user add deinname --role admin
```
Das Programm fragt nach einem Passwort und gibt danach eine lange Zeile aus,
die mit `otpauth://` beginnt.
**Scanne diese Zeile in eine Authenticator-App, bevor du weitermachst.** Eine
Authenticator-App (Google Authenticator, Aegis, 1Password und andere) zeigt
einen sechsstelligen Code, der sich alle 30 Sekunden ändert. Diesen Code
brauchst du bei jeder Anmeldung. **Die Zeile wird genau einmal angezeigt und
nie wieder.** Geht sie verloren, kann sie niemand wiederherstellen, und das
Konto ist nicht mehr zu reparieren — es gibt derzeit keinen Befehl, den
zweiten Faktor zu entfernen oder neu einzurichten.
Wenn du den sechsstelligen Code wirklich nicht willst, hängst du `--no-totp`
an. Das Programm warnt dich dann. In einem Heimnetz, das von außen niemand
erreicht, ist das eine vertretbare Entscheidung — sonst nicht.
**Drei Arten von Konto**, damit nicht jeder alles ändern kann:
| Rolle | Darf |
|---|---|
| `viewer` | Bilder ansehen |
| `editor` | Ansehen und beschriften |
| `admin` | Alles davon, dazu die Seiten „Geräte" und „System" |
Die Kameras selbst sind *keine* Konten und tauchen in dieser Liste nie auf.
Sie weisen sich anders aus und können sich nicht an der Webseite anmelden.
---
## 3. Anmelden
Öffne die Adresse deines Servers im Browser. Du bekommst ein Anmeldeformular:
Benutzername, Passwort und — falls dein Konto einen hat — der sechsstellige
Code aus der Authenticator-App.
Wird der Code abgelehnt, prüfe die Uhr deines Handys. Diese Codes werden aus
der aktuellen Zeit berechnet; ein Handy, das eine Minute falsch liegt,
erzeugt Codes, die der Server für falsch hält. Ein paar Sekunden sind kein
Problem — der Server akzeptiert auch den Code davor und danach.
**Ein falsches Passwort und ein nicht existierender Benutzername ergeben genau
dieselbe Meldung.** Das ist Absicht: ein „diesen Benutzer gibt es nicht"
würde einem Fremden verraten, welche Benutzernamen existieren.
Wiederholte Fehlversuche werden gebremst. Diese Bremse gilt **pro
Netzwerkadresse, nicht pro Benutzername** — und zwar bewusst, denn eine Bremse
pro Benutzername würde es jedem erlauben, dich aus deinem eigenen Konto
auszusperren, indem er einfach darauf herumrät.
Angemeldet bleibst du standardmäßig **zwei Wochen**, danach musst du dich neu
anmelden.
„Abmelden" wirkt sofort, weil die Sitzung auf dem Server gelöscht wird und
nicht bloß vom Browser vergessen — es gibt kein Zeitfenster, in dem eine alte
Anmeldung noch funktioniert. Es beendet allerdings **nur die Sitzung in diesem
Browser**. Wenn du zusätzlich am Handy angemeldet bist, bleibt das angemeldet.
Erst ein Passwortwechsel (`poorbird user passwd`) beendet alle Sitzungen dieses
Kontos gleichzeitig.
---
## 4. Die Galerie benutzen
Die Hauptseite ist ein Raster aus Vorschaubildern, die neuesten zuerst. Beim
Scrollen werden ältere automatisch nachgeladen; es gibt keine Seitenzahlen.
> Im Browser existieren nur die Kacheln, die du gerade sehen kannst. Das
> klingt nach einer Nebensache, ist aber der Grund, warum die Seite bedienbar
> bleibt: eine gut besuchte Futterstelle bringt tausende Bilder pro Tag, und
> ein Browser, der ein ganzes Jahr davon gleichzeitig halten soll, reagiert
> irgendwann einfach nicht mehr.
**Klick auf ein Bild** zeigt es in voller Größe, die Details daneben. In
dieser Ansicht:
| Taste | Tut |
|---|---|
| `→` | Nächstes Bild |
| `←` | Voriges Bild |
| `Esc` | Zurück zum Raster |
Nimm die Tastatur. Einen Tag Bilder zu beschriften heißt ansehen – entscheiden
– weiter, ein paar hundert Mal, und das ist mit der Maus ermüdend.
Die Pfeile halten beim letzten bereits geladenen Bild an, statt dir ein leeres
Fenster zu zeigen, während weitere eintreffen. Scrolle das Raster ein Stück
weiter, dann geht es weiter.
### Filter
Über dem Raster kannst du nach Zeitraum, nach Kamera und nach drei
Ja/Nein-Fragen einschränken: **behalten**, **durchgesehen** und
**Vorauslöser**.
Jede davon ist eine Auswahl mit drei Zuständen — *beliebig*, *ja*, *nein* —
und keine Checkbox. Eine Checkbox kann nur „behalten" oder „egal" sagen, und
„zeig mir nur die, die ich verworfen habe" ist eine Frage, die du stellen
wirst.
Einen Filter zu ändern beginnt die Liste von vorne. Es hängt nichts an das an,
was schon auf dem Schirm war.
**„Vorauslöser" braucht eine Erklärung.** Die Kamera nimmt ständig leise
Bilder in einen kleinen Speicher auf, den sie immer wieder überschreibt. Löst
das Radar aus, schickt sie auch die zwei Bilder von *unmittelbar davor* mit.
Oft sind das die besten — ein landender Vogel statt eines schon sitzenden. Sie
sind markiert, damit du weißt: als sie entstanden, hatte das Radar noch nicht
ausgelöst.
### Was die Angaben bedeuten
- **Empfangen** — wann der Server das Bild bekommen hat. Dieser Zeitstempel
ist der, dem das System traut.
- **Aufgenommen** — wann die Kamera meint, das Bild gemacht zu haben. Hier
kann **„nicht synchronisiert"** stehen: die Kamera hat keine batteriegepufferte
Uhr, nach einem Stromausfall kennt sie die Zeit also nicht, bis sie
nachfragen kann. Sie sagt das ehrlich, anstatt den 1. Januar 1970 zu
behaupten — was ein naives System anzeigen würde.
- **Entfernung / Energie** — was das Radar gemessen hat: wie weit weg, und wie
stark die Bewegung.
- **Serie 2 von 5** — Bilder kommen in Serien. Dies ist das zweite von fünf.
- **Ein Hinweis „Vorhersage"** an einer Art bedeutet: *der Rechner hat
geraten*, nicht dass ein Mensch sie bestimmt hat. Automatische
Artbestimmung gibt es noch nicht; wenn es sie gibt, bleiben ihre Vermutungen
markiert. Deine eigenen Beschriftungen sind das Lernmaterial dafür, und eine
stillschweigend untergemischte Vermutung würde dieses Material verderben.
### Fehlende Vorschaubilder
Ein Bild, dessen kleine Vorschau noch nicht erzeugt wurde, zeigt einen
Platzhalter statt eines kaputten Bildes. Die Vorschauen macht ein
Hintergrundprogramm („Worker"). Verschwinden die Platzhalter nicht, läuft
dieses Programm wahrscheinlich nicht.
### Farben und Sprache
Oben rechts: drei Farbschemata (hell, dunkel und ein dunkles Blau) und zwei
Sprachen (Deutsch, Englisch). Beides merkt sich dein Browser. Es hängt noch
nicht am Konto, ein anderer Browser fängt also bei der Voreinstellung an.
---
## 5. Befehle, die du brauchen könntest
Diese laufen dort, wo der Server installiert ist. `poorbird` ist das Programm.
| Befehl | Tut |
|---|---|
| `poorbird check` | **Das zuerst, wenn etwas nicht stimmt.** Prüft Einstellungen, Datenbank und Ordner und erklärt, was es findet, ohne etwas zu starten. |
| `poorbird user add NAME --role admin` | Konto anlegen |
| `poorbird user list` | Konten anzeigen, und ob jedes einen sechsstelligen Code verwendet |
| `poorbird user passwd NAME` | Neues Passwort setzen. Meldet diese Person überall ab. |
| `poorbird serve` | Den Server-Teil der Webseite laufen lassen |
| `poorbird worker` | Das Hintergrundprogramm für die Vorschaubilder laufen lassen |
| `poorbird migrate` | Die Datenbankstruktur nach einem Update aktualisieren |
| `poorbird seed --captures 500` | 500 erfundene Bilder anlegen, um die Galerie auszuprobieren, ohne auf Vögel zu warten |
| `poorbird seed --clear` | Diese erfundenen Bilder wieder löschen |
`seed --clear` entfernt ausschließlich erfundene Daten. Es ist auf die
erfundene Kamera beschränkt, die es selbst angelegt hat — die Bilder einer
echten Kamera sind also nie in Gefahr. Es gibt einen Test, der eine echte
Kamera neben die erfundene stellt und prüft, dass sie überlebt.
---
## 6. Einstellungen
Die Einstellungen stehen in einer Datei, `/etc/poorbird/poorbird.env`, eine
`NAME=wert`-Zeile je Einstellung. Damit eine Änderung wirkt, wird das Programm
neu gestartet:
```bash
sudo systemctl restart poorbird-api poorbird-worker
```
Die vollständige Datei samt Begründungen ist
[`../server/deploy/poorbird.env.example`](../server/deploy/poorbird.env.example).
In Klartext:
### Die, die du setzen musst
| Einstellung | Bedeutung |
|---|---|
| `POORBIRD_DATABASE_URL` | Wo die Datenbank liegt und das Passwort dafür. **Keine Voreinstellung** — das Programm startet lieber nicht, als zu raten, und es weigert sich auch, wenn du die Beispieldatei kopiert und `CHANGE_ME` darin stehen gelassen hast. |
| `POORBIRD_ENROLL_SECRET` | Ein gemeinsames Geheimnis, mit dem sich Kameras beim allerersten Mal vorstellen. Erzeugen mit `openssl rand -hex 32`. |
> **Ändere `POORBIRD_ENROLL_SECRET` nicht leichtfertig.** Es steckt in der
> Software der Kamera als letzter Rückweg, falls die Kamera anders nicht mehr
> erreichbar ist. Es hier zu ändern, ohne auch die Kamera zu aktualisieren,
> nimmt dir diesen Notausgang — und eine Kamera, die draußen montiert ist,
> erreicht man nur mühsam.
### Wo Dateien landen
| Einstellung | Bedeutung |
|---|---|
| `POORBIRD_IMAGE_ROOT` | Die Bilder in voller Größe. Standard `/srv/poorbird/images`. |
| `POORBIRD_THUMB_ROOT` | Die kleinen Vorschauen. Standard `/srv/poorbird/thumbs`. |
| `POORBIRD_STATE_DIR` | Interne Verwaltungsdaten. Standard `/var/lib/poorbird`. |
Die ersten beiden müssen nebeneinander liegen, `images` und `thumbs` heißen
und denselben übergeordneten Ordner haben. Der Webserver liest sie von dort.
`poorbird check` sagt dir, wenn sie auseinandergelaufen sind — denn sonst ist
das Symptom, dass Bilder auf unerklärliche Weise nicht laden und in keinem
Protokoll etwas steht.
**Bilder werden nie direkt aus dem Ordner herausgegeben.** Jede Anfrage wird
zuerst gegen deine Anmeldung geprüft, und erst danach werden die Daten
gesendet. Dass die Adresse eines Bildes schwer zu erraten ist, ist kein
Schutz.
### Die zwei, über die alle stolpern
| Einstellung | Bedeutung |
|---|---|
| `POORBIRD_SESSION_COOKIE_SECURE` | Auf `true` lassen. Nur dann `false`, wenn du die Seite über einfaches `http://` statt `https://` erreichst. |
| `POORBIRD_SERVE_IMAGES_DIRECTLY` | Auf `false` lassen. `true` ist ausschließlich für einen Entwicklerrechner. |
Die erste ist wichtig wegen einer Browser-Regel: ein Cookie, das als „secure"
markiert ist, wird über eine unverschlüsselte Verbindung verworfen. Der
Browser warnt nicht, die Anmeldung meldet Erfolg, und du bist einfach nicht
angemeldet — und in keinem Protokoll steht, warum. Wenn du je „Anmeldung hat
geklappt, aber ich bin nicht drin" siehst: das ist der Grund.
Die zweite entscheidet, *wer das Bild von der Platte liest* — das
Hauptprogramm oder der Webserver davor. Der Webserver kann das deutlich
besser. **An der Rechteprüfung ändert sie nichts**: die läuft in beiden
Fällen gleich.
### Selten angefasst
| Einstellung | Bedeutung | Standard |
|---|---|---|
| `POORBIRD_SESSION_LIFETIME_H` | Wie lange du angemeldet bleibst, in Stunden | `336` (zwei Wochen) |
| `POORBIRD_RATE_LIMIT_ENABLED` | Wiederholte Fehlanmeldungen und flutende Kameras bremsen | `true` |
| `POORBIRD_API_HOST` / `_PORT` | Wo das Programm lauscht. Es sollte nur vom Rechner selbst erreichbar bleiben; nach außen kümmert sich der Webserver davor. | `127.0.0.1`, in der Beispieldatei Port `8090` |
| `POORBIRD_DB_POOL_SIZE` / `_MAX_OVERFLOW` | Wie viele Datenbankverbindungen gleichzeitig offen sein dürfen | `15` / `10` |
| `POORBIRD_WORKER_POLL_INTERVAL_S` | Wie lange das Hintergrundprogramm wartet, bevor es erneut nach Arbeit schaut, wenn es keine gibt. Es bremst *nicht* Arbeit, die schon wartet. | `5` |
| `POORBIRD_JOB_MAX_ATTEMPTS` | Wie oft ein fehlgeschlagener Hintergrundauftrag wiederholt wird | `3` |
| `POORBIRD_LOG_LEVEL` | Wie gesprächig das Protokoll ist | `INFO` |
| `POORBIRD_LOG_FORMAT` | `text` zum Selberlesen, `json` für Protokoll-Sammelwerkzeuge | `text` |
| `POORBIRD_DB_ECHO` | Jede Datenbankabfrage mitschreiben. Nur zur Fehlersuche, sehr geschwätzig. | `false` |
---
## 7. Wenn etwas nicht stimmt
**Fang mit `poorbird check` an.** Es ist genau dafür gebaut, „ist dieser
Rechner richtig eingerichtet" zu beantworten — und zu erklären, nicht nur zu
scheitern.
| Symptom | Wahrscheinlich |
|---|---|
| Anmeldung meldet Erfolg, aber du bist nicht angemeldet | `POORBIRD_SESSION_COOKIE_SECURE=true` bei einfachem `http://`. Siehe oben. |
| Die Webseite sagt, sie erreicht den Server nicht | Das Programm `poorbird serve` läuft nicht. |
| Die Seite lädt, aber das Raster ist leer | Noch keine Bilder. Mit `poorbird seed --captures 500` prüfen, ob die Galerie selbst funktioniert. |
| Vorschaubilder bleiben Platzhalter | Das Programm `poorbird worker` läuft nicht. |
| Bilder laden nicht, im Protokoll steht nichts | `images` und `thumbs` liegen nicht dort nebeneinander, wo der Webserver sie erwartet. `poorbird check`. |
| Der sechsstellige Code wird abgelehnt | Die Uhr deines Handys ist verstellt. |
| Das Anmeldeformular lehnt wiederholt ab und reagiert dann nicht mehr | Die Bremse gegen Fehlversuche. Warten, dann einmal sorgfältig versuchen. |
| Neu laden auf einer Seite wie `/devices` ergibt „nicht gefunden" | In der Konfiguration des Webservers fehlt die Regel, unbekannte Pfade zurück an die Galerie zu geben. Das ist die `try_files`-Zeile in der Caddyfile, eingerichtet in `INSTALL.md`, Schritt 6. |
### Zwei Dinge, die du wissen solltest, bevor du dich darauf verlässt
**Es gibt noch keine Sicherungen.** Nichts in poorBird kopiert deine Bilder
irgendwohin. Fällt diese Platte aus, sind die Bilder weg. Das ist geplante
Arbeit und kein Versehen — aber bis es sie gibt: lass hier keine Bilder als
einzige Kopie auflaufen, die dir fehlen würden.
**Die Kamera hat noch nie auf echter Hardware gelaufen**, und der Server noch
nie außerhalb eines Entwicklerrechners. Alles hier Beschriebene funktioniert —
es gibt 308 automatische Tests, und die Galerie wurde mit 500 Bildern benutzt
— aber „funktioniert auf dem Schreibtisch" und „funktioniert ein Jahr lang an
einem Pfahl im Regen" sind zwei verschiedene Behauptungen.
---
## 8. Datenschutz, kurz
Die Kamera spricht mit deinem Server über dein eigenes Netz, und zwar
unverschlüsselt. Das ist ein bewusster Handel: Verschlüsselung auf einem so
kleinen Gerät bedeutet ein Zertifikat, das in seiner Software festgeschrieben
ist — und eine Kamera, die stillschweigend aufhört hochzuladen, wenn dieses
Zertifikat getauscht wird, während sie an einem Pfahl hängt. Wer schon in
deinem Heimnetz ist, könnte die Uploads also mitlesen.
Dein eigener Blick in die Galerie *ist* verschlüsselt und braucht eine
Anmeldung.
Es geht nichts woandershin. Es gibt keinen Cloud-Dienst, kein Konto
irgendwo sonst und keine automatische Weitergabe. Die Bilder liegen auf deiner
Platte und nirgends sonst — was ebenfalls ein Grund ist, die fehlende
Sicherung ernst zu nehmen.
+330
View File
@@ -0,0 +1,330 @@
# poorBird — a guide for using it
*Deutsche Fassung: [`README.USER.de.md`](README.USER.de.md)*
This guide is for **using** poorBird, not for building it. It assumes you can
follow a copy-and-paste command in a terminal, and nothing else. Every term
that matters is explained where it first appears.
---
## 1. What it actually does
You hang a small camera near a bird feeder. It watches the feeder with a
**radar sensor** — not a camera-based motion detector, but a module that sends
out a harmless radio signal and notices when something moves in front of it.
When a bird arrives, the camera takes a burst of photos and sends them over
your home network to a small computer indoors. That computer stores the
photos and shows them to you in a web page where you can look through them and
write down which bird you saw.
**Why radar and not a normal motion sensor?** A classic motion sensor (the
kind in an outdoor lamp) reacts to warmth. It fires when the sun comes out,
when warm air moves, when a branch sways. Radar sees actual movement and also
reports *how far away* it was and *how strong* the movement was — which is
enough to tell "a bird landed on the perch" from "the hedge moved in the wind".
It also works through a plastic housing, so the sensor stays dry.
**Three pieces, and each can fail independently:**
| Piece | What it is | Where it lives |
|---|---|---|
| The camera | A small circuit board with a lens and the radar sensor | Outdoors, at the feeder |
| The server | A program storing photos and answering the website | A small computer indoors, always on |
| The website | The gallery you look at | Your browser |
The camera keeps nothing for long. Photos live on the server, so if the camera
breaks or is stolen, everything already uploaded is safe.
---
## 2. What you need before you start
- The **server** set up and running. That is a separate, more technical job:
[`../server/deploy/INSTALL.md`](../server/deploy/INSTALL.md).
- An **account**. There is no "sign up" button anywhere, on purpose — see
below.
- A browser on the same network.
### There is no sign-up, and no default password
Many devices ship with a built-in login like `admin` / `admin`. That is a
back door: everyone knows it, and most people never change it. poorBird has no
such account. A person with access to the server has to create yours
deliberately:
```bash
poorbird user add yourname --role admin
```
It asks for a password, then prints a long line starting with `otpauth://`.
**Scan that line into an authenticator app before you continue.** An
authenticator app (Google Authenticator, Aegis, 1Password, and others) shows a
six-digit code that changes every 30 seconds. You will need one of those codes
every time you sign in. **The line is shown once and never again.** If you
lose it, nobody can recover it and the account cannot be repaired — there is
currently no command to remove or re-arm the second factor.
If you genuinely do not want the six-digit code, add `--no-totp`. It will warn
you. It is a reasonable choice on a home network that nobody else can reach,
and a bad one otherwise.
**Three kinds of account**, so that not everyone can change everything:
| Role | Can |
|---|---|
| `viewer` | Look at photos |
| `editor` | Look, and label what it sees |
| `admin` | All of that, plus the Devices and System pages |
The cameras themselves are *not* accounts and never appear in this list. They
identify themselves a different way and cannot log into the website.
---
## 3. Signing in
Open the address of your server in a browser. You get a login form asking for
your username, your password, and — if your account has one — the six-digit
code from your authenticator app.
If the code is refused, check your phone's clock. These codes are generated
from the current time, so a phone that is a minute off produces codes the
server considers wrong. A few seconds out is fine; the server accepts the code
before and after the current one.
**A wrong password and a username that does not exist give exactly the same
message.** That is deliberate: telling you "no such user" would let a stranger
work out which usernames exist.
Repeated failed attempts are slowed down. This is limited **per network
address, not per username** — on purpose, because limiting by username would
let anyone lock you out of your own account just by guessing at it.
You stay signed in for **two weeks** by default, then have to sign in again.
"Sign out" takes effect immediately, because the session is deleted on the
server rather than merely forgotten by the browser — there is no window in
which an old login still works. It ends the session **in that browser only**,
though. If you are also signed in on your phone, that stays signed in.
Changing the password (`poorbird user passwd`) is what ends every session for
that account at once.
---
## 4. Using the gallery
The main page is a grid of thumbnails, newest first. Scroll and older photos
load automatically; there are no page numbers.
> Only the tiles you can actually see exist in the browser. This sounds like a
> detail but it is the reason the page stays usable: a busy feeder can produce
> thousands of photos a day, and a browser asked to hold a year of them at
> once simply stops responding.
**Click a photo** to see it full size with its details beside it. In that view:
| Key | Does |
|---|---|
| `→` | Next photo |
| `←` | Previous photo |
| `Esc` | Back to the grid |
Use the keyboard. Labelling a day of photos is look-decide-next a few hundred
times, and that is tiring with a mouse.
The arrows stop at the last photo loaded so far rather than showing you an
empty frame while more arrive. Scroll the grid a little further and they
continue.
### Filters
Above the grid you can narrow things down by date range, by camera, and by
three yes/no questions: **kept**, **reviewed**, and **pre-trigger**.
Each of those is a three-way choice — *any*, *yes*, *no* — not a checkbox. A
checkbox can only say "kept" or "don't care", and "show me only the ones I
rejected" is a question you will want to ask.
Changing a filter starts the list again from the top. It does not add to what
was already on screen.
**"Pre-trigger" needs explaining.** The camera is always quietly taking
pictures into a small buffer it keeps overwriting. When the radar fires, it
sends the couple of frames from *just before* the trigger as well. Those are
often the best ones — a bird landing rather than a bird already sitting. They
are marked so you know the radar had not fired yet when they were taken.
### What the details mean
- **Received** — when the server got the photo. This is the timestamp the
system trusts.
- **Taken** — when the camera thinks it took the photo. It may say **"not
synced"**: the camera has no battery-backed clock, so after a power cut it
does not know the time until it can ask. It reports that honestly instead of
claiming 1 January 1970, which is what a naive system shows.
- **Distance / energy** — what the radar measured: how far away, and how
strong the movement.
- **Burst 2 of 5** — photos arrive in bursts. This is the second of five.
- **A "prediction" badge** on a species means *the computer guessed*, not that
a person identified it. Automatic identification does not exist yet; when it
does, its guesses stay marked. The labels you write are training material
for it, and a guess quietly mixed in with confirmed labels would poison
that.
### Missing thumbnails
A photo whose small preview has not been generated yet shows a placeholder
instead of a broken image. The previews are made by a background program (the
"worker"). If placeholders do not disappear, that program is probably not
running.
### Themes and language
Top right: three colour schemes (light, dark, and a dark blue) and two
languages (German, English). Both are remembered in your browser. They are not
yet tied to your account, so a different browser starts from the default.
---
## 5. Commands you may need
Run these where the server is installed. `poorbird` is the program.
| Command | Does |
|---|---|
| `poorbird check` | **Run this first when something is wrong.** Checks the settings, the database and the folders, and explains what it finds without starting anything. |
| `poorbird user add NAME --role admin` | Create an account |
| `poorbird user list` | Show accounts and whether each uses a six-digit code |
| `poorbird user passwd NAME` | Set a new password. Also signs that person out everywhere. |
| `poorbird serve` | Run the website's server part |
| `poorbird worker` | Run the background program that makes thumbnails |
| `poorbird migrate` | Bring the database structure up to date after an update |
| `poorbird seed --captures 500` | Invent 500 fake photos, to try the gallery without waiting for birds |
| `poorbird seed --clear` | Delete those fake photos again |
`seed --clear` only ever removes invented data. It is restricted to the fake
camera it created, so a real camera's photos are never at risk. There is a
test that puts a real camera alongside the fake one and checks it survives.
---
## 6. Settings
Settings live in one file, `/etc/poorbird/poorbird.env`, one `NAME=value` per
line. The program is restarted to pick up a change:
```bash
sudo systemctl restart poorbird-api poorbird-worker
```
The full file with the reasoning is
[`../server/deploy/poorbird.env.example`](../server/deploy/poorbird.env.example).
In plain language:
### The ones you must set
| Setting | Meaning |
|---|---|
| `POORBIRD_DATABASE_URL` | Where the database is and the password to reach it. **No default** — the program refuses to start rather than guess, and it also refuses if you copied the example and left `CHANGE_ME` in place. |
| `POORBIRD_ENROLL_SECRET` | A shared password the cameras use to introduce themselves the very first time. Make one with `openssl rand -hex 32`. |
> **Do not change `POORBIRD_ENROLL_SECRET` casually.** It is built into the
> camera's own software as a last-resort way back in if the camera can no
> longer be reached. Changing it here without also updating the camera removes
> that escape hatch — and a camera mounted outside is hard to reach.
### Where files go
| Setting | Meaning |
|---|---|
| `POORBIRD_IMAGE_ROOT` | The full-size photos. Default `/srv/poorbird/images`. |
| `POORBIRD_THUMB_ROOT` | The small previews. Default `/srv/poorbird/thumbs`. |
| `POORBIRD_STATE_DIR` | Internal bookkeeping. Default `/var/lib/poorbird`. |
These two must stay next to each other, named `images` and `thumbs`, in the
same parent folder. The web server reads them from there. `poorbird check`
tells you if they have drifted apart, because the symptom otherwise is photos
that mysteriously fail to load with nothing written in any log.
**Photos are never handed out straight from the folder.** Every request is
checked against your login first, and only then are the bytes sent. A photo's
address being hard to guess is not protection.
### The two that trip everyone up
| Setting | Meaning |
|---|---|
| `POORBIRD_SESSION_COOKIE_SECURE` | Leave `true`. Set `false` **only** if you are reaching the site over plain `http://` instead of `https://`. |
| `POORBIRD_SERVE_IMAGES_DIRECTLY` | Leave `false`. `true` is for a developer's machine only. |
The first one matters because of a browser rule: a cookie marked "secure" is
thrown away over an unencrypted connection. The browser does not warn, the
login reports success, and you simply are not signed in — with nothing in any
log to explain it. If you ever see "login worked but I'm not signed in", this
is why.
The second changes *who reads the photo off the disk* — the main program, or
the web server in front of it. The web server is far better at it. **It does
not change the permission check**: the same check runs either way.
### Rarely touched
| Setting | Meaning | Default |
|---|---|---|
| `POORBIRD_SESSION_LIFETIME_H` | How long you stay signed in, in hours | `336` (two weeks) |
| `POORBIRD_RATE_LIMIT_ENABLED` | Slow down repeated failed logins and flooding cameras | `true` |
| `POORBIRD_API_HOST` / `_PORT` | Where the program listens. It should stay reachable only from the machine itself; the web server in front handles the outside world. | `127.0.0.1`, and set `8090` in the example file |
| `POORBIRD_DB_POOL_SIZE` / `_MAX_OVERFLOW` | How many database connections it may open at once | `15` / `10` |
| `POORBIRD_WORKER_POLL_INTERVAL_S` | How long the background program waits before checking for new work when there is none. It does *not* slow down work already waiting. | `5` |
| `POORBIRD_JOB_MAX_ATTEMPTS` | How many times to retry a failed background job | `3` |
| `POORBIRD_LOG_LEVEL` | How chatty the log is | `INFO` |
| `POORBIRD_LOG_FORMAT` | `text` to read by eye, `json` for log-collecting tools | `text` |
| `POORBIRD_DB_ECHO` | Print every database query. Debugging only; very noisy. | `false` |
---
## 7. When something is wrong
**Start with `poorbird check`.** It is built to answer "is this machine set up
correctly" and to explain, not just to fail.
| Symptom | Most likely |
|---|---|
| Login says success, but you are not signed in | `POORBIRD_SESSION_COOKIE_SECURE=true` while using plain `http://`. See above. |
| The website says it cannot reach the server | The `poorbird serve` program is not running. |
| The page loads but the grid is empty | No photos yet. Try `poorbird seed --captures 500` to confirm the gallery itself works. |
| Thumbnails stay as placeholders | The `poorbird worker` program is not running. |
| Photos fail to load, nothing in the log | `images` and `thumbs` are not siblings where the web server expects. `poorbird check`. |
| The six-digit code is refused | Your phone's clock is off. |
| The login form rejects you repeatedly, then stops responding | Rate limiting. Wait, then try once, carefully. |
| Refreshing on a page like `/devices` gives "not found" | The web server's configuration is missing the rule that sends unknown paths back to the gallery. It is the `try_files` line in the Caddyfile, installed in `INSTALL.md` step 6. |
### Two things to know before you trust it
**There are no backups yet.** Nothing in poorBird copies your photos
anywhere. If that disk fails, the photos are gone. This is planned work, not
an oversight, but until it exists: do not let photos you would miss pile up
here as their only copy.
**The camera has never run on real hardware**, and the server has never run
outside a developer's machine. Everything described here works — there are 308
automated tests and the gallery has been used against 500 photos — but "works
on a desk" and "works on a pole in the rain for a year" are different claims.
---
## 8. Privacy, briefly
The camera talks to your server over your own network in plain, unencrypted
form. This is a deliberate trade: encryption on a device this small means a
certificate baked into its software, and a camera that silently stops
uploading when that certificate is replaced — while it is mounted on a pole.
Anyone already on your home network could therefore see the uploads.
Your own browsing of the gallery *is* encrypted, and needs a login.
Nothing is sent anywhere else. There is no cloud service, no account
elsewhere, and no automatic sharing. The photos are on your disk and nowhere
else — which is also why the missing backup is worth taking seriously.
+16
View File
@@ -43,10 +43,26 @@ poorbird.example.internal {
encode zstd gzip
# The API, and with it the auth-checked image handoff.
handle /api/* {
reverse_proxy 127.0.0.1:8090 {
header_up X-Real-IP {remote_host}
import protected_files
}
}
# The WebUI: built on the dev machine with `npm run build` and copied here
# as static files. Nothing in web/ runs on the server (SPEC 6), so this is
# a file_server and not a second application.
handle {
root * /srv/poorbird/web
# The router does client-side routing, so a reload on /devices or a
# pasted deep link arrives as a path with no file behind it. Without
# this fallback those are 404s and only the entry page ever works.
try_files {path} /index.html
file_server
}
}
# --- the camera --------------------------------------------------------------
+68 -2
View File
@@ -16,10 +16,16 @@ sudo apt update
sudo apt install -y postgresql python3-venv python3-pip git caddy
sudo useradd --system --home-dir /opt/poorbird --shell /usr/sbin/nologin poorbird
sudo mkdir -p /opt/poorbird /etc/poorbird /srv/poorbird/{images,thumbs} /var/lib/poorbird
sudo mkdir -p /opt/poorbird /etc/poorbird /srv/poorbird/{images,thumbs,web} /var/lib/poorbird
sudo chown -R poorbird:poorbird /srv/poorbird /var/lib/poorbird /opt/poorbird
```
`images/` and `thumbs/` must stay siblings under `/srv/poorbird`: that is the
directory the Caddyfile's `file_server` serves, and the auth-checked image
handoff needs both sides to agree on it. `poorbird check` verifies the layout,
because getting it wrong produces 404s from Caddy and nothing in the app's log.
`web/` is where the built UI goes (step 7).
## 2. Database
Loopback TCP with `scram-sha-256`, deliberately not a Unix socket — see
@@ -112,7 +118,63 @@ DNS-01 needs a Caddy build with your provider's plugin:
`caddy add-package github.com/caddy-dns/cloudflare`. For a first test, replace
the human-facing site block with `http://:8081` and drop the `tls` block.
## 7. Network
> **If you do that, you cannot sign in until you also set
> `POORBIRD_SESSION_COOKIE_SECURE=false`.** The session cookie is `Secure` by
> default, and a browser silently discards a `Secure` cookie over plain HTTP:
> the login returns 200, and you are never signed in, with nothing in any log
> to explain it. Set it back to `true` the moment TLS is on.
## 7. The WebUI
The UI is built on your dev machine and copied here as static files. Nothing
in `web/` runs on the server (SPEC §6) — Caddy serves it, and there is no Node
on this host.
On the dev machine:
```bash
cd web
npm ci
npm run build # typechecks, then writes dist/
```
Then copy it over, and let Caddy read it:
```bash
rsync -a --delete dist/ youruser@poorbird-host:/tmp/poorbird-web/
# on the host:
sudo rsync -a --delete /tmp/poorbird-web/ /srv/poorbird/web/
sudo chown -R poorbird:poorbird /srv/poorbird/web
```
`--delete` matters on an upgrade: Vite writes content-hashed filenames, so
without it every old bundle stays behind forever.
Re-run this after any UI change. There is no build step on the server, so
`git pull` alone never updates the UI.
## 8. Your first account
**There is no sign-up page, and a fresh install has no accounts** — so without
this step the login screen has nothing you can type into it.
```bash
sudo -u poorbird env $(sudo cat /etc/poorbird/poorbird.env | grep -v '^#' | xargs) \
/opt/poorbird/venv/bin/poorbird user add yourname --role admin
```
It prompts for the password, then prints an `otpauth://` URI once. **Scan it
into your authenticator app before pressing on** — it is not shown again, and
TOTP is required on every login for an account that has a secret.
`--no-totp` skips the second factor and warns that it is doing so. There is
currently no command to add or remove TOTP later, and none to delete a user,
so this choice sticks for that account.
Roles are `viewer`, `editor` and `admin` (SPEC §3.1); Devices and System need
`admin`. Devices are not users and never appear here.
## 9. Network
Give the server a **DHCP reservation or a static IP, then hardcode that
address in the firmware** — simpler and more reliable than mDNS (SPEC §9).
@@ -131,6 +193,10 @@ sudo systemctl restart poorbird-api poorbird-worker
`ExecStartPre` applies migrations on restart.
**The UI is not part of that.** It is built on the dev machine, so a `git pull`
here leaves the old bundle in `/srv/poorbird/web` and you get a new API with an
old gallery. Repeat step 7 whenever `web/` changed.
> Restarting mid-OTA-rollout matters: a device on a trial image marks that
> image valid **only after a heartbeat the endpoint accepted**. Returning 5xx
> to a trial device rolls it back — correct behaviour, but know it before you