guzva.ba shows guests how busy a venue is right now, with a live picture from a small camera in the room. The picture is stylised so nobody can be recognised. Owners get a panel with their statistics and settings; an admin console runs the whole fleet.
The parts
[venue Wi-Fi]
ESP32-CAM ── HTTPS POST /v1/ingest ──┐ (the camera only ever sends; the server never calls it)
v
[netcup VPS, Debian 13] guzva (one Go binary, systemd service)
├─ ingest receive, check, render the picture
├─ public guzva.ba/<venue>/ pages, pre-rendered to disk
├─ admin /admin/ (operator) owner /owner/ (venue owners)
├─ sched jobs on a timer: page refresh, alerts, mail, pruning
├─ SQLite /var/lib/guzva/guzva.db (WAL mode)
└─ TLS Let's Encrypt certificates, fetched by the binary itself
| Part | What it is | Why this choice |
|---|---|---|
| Camera | ESP32-CAM board, firmware in C++ (PlatformIO) | About 10 € a board, runs on USB power, enough to take one picture and send it over HTTPS |
| Server program | Go, standard library plus 3 dependencies | One static file to deploy, fast, easy to test, no runtime to install |
| Database | SQLite (modernc.org/sqlite, pure Go) | No database server to run or secure; the whole state is one file to copy and check |
| Pages | html/template + htmx, CSS from Tailwind built at compile time | Server-rendered pages load fast on cheap phones; htmx adds partial updates without a JS app |
| TLS | golang.org/x/crypto/acme/autocert inside the binary | No nginx or Caddy in front; certificates renew themselves |
| Alerts | Telegram bot message to one person | Free, instant, already on the phone |
| Brevo SMTP (out), Cloudflare routing (in) | Reliable delivery without running a mail server |
The path of one picture
- Capture. The camera takes a JPEG every 30–60 s (the venue's interval; the Jadro board posts about every 31 s).
- Send. It POSTs the JPEG to
ingest.guzva.ba/v1/ingestover TLS, with its device token and acapture_idthat is unique per picture. - Check. The server checks the token, the rate limit and the size. If the same
capture_idarrives twice (a retry after a lost answer), the second gets409with the same body as the first201. This is called idempotency: a retry can never create a duplicate. - Render. The raw JPEG is decoded in memory, turned into the stylised picture, and the raw bytes are zeroed when the function returns. The raw picture never touches the disk.
- Publish. The stylised
latest.pngand the venue'sindex.htmlare written to/var/lib/guzva/public/<venue>/atomically (write to a temp file, then rename), so a guest never sees half a file. - Serve. A guest opening
guzva.ba/<venue>/gets the pre-rendered page. With JavaScript it fetches only the new picture every 30 s. - Age out. Older renders are kept in a 48-hour ring under
venues/, then pruned every hour.
If a picture is bad or the camera goes quiet, the page keeps the last good picture and says STALE. It never shows garbage and never pretends an old picture is live.
The contracts (PLAN §1)
These hold for every change. Breaking one is a bug even if all tests pass.
- Freshness: the server's receive time is the truth; the camera's clock is only a hint.
- Idempotency:
UNIQUE(venue_id, capture_id); a retry returns the same answer. - Never publish a failure: keep the last good picture and show STALE.
- Privacy: raw JPEG only in RAM inside one call; stylised renders only at rest, on public routes and in logs; request bodies are never logged. Proven by tests and a disk scan in CI.
- No biometrics (decision D9): no face detection, no person counting from faces.
- Push only: the server never connects to a camera, so it can't be tricked into calling something inside a venue's network.
The code, by package
| Package | Job |
|---|---|
cmd/guzva | main: flags, wiring, the serve, provision and hashpw commands |
internal/store | All SQL lives here, with embedded migrations tracked by PRAGMA user_version |
internal/frames | Ingest: checks, save, prune, disk space |
internal/render | The picture pipeline (raw JPEG in, stylised PNG out) |
internal/pages | Writes the public pages to disk |
internal/admin | Admin and owner consoles (this page too) |
internal/auth | Device tokens, sessions, rate limits |
internal/alert | Alert rules and the Telegram sender |
internal/sched | The one timer loop that runs background jobs |
internal/privacy | Tests that prove the privacy contract |
internal/handbook | This handbook |
Dependencies only point downward: store knows nothing about admin, so each package can be tested alone.