CI ran Playwright (chromium-desktop) + the dependency audit and nothing else. cargo test,
clippy, the frontend vitest suite, svelte-check and the e2e typecheck were all green on a
developer's machine and gated NOTHING.
checks.yml (new): cargo test (with a Postgres service; --test-threads bounded so the
sqlx per-test DBs can't exhaust connections) + clippy; vitest + svelte-check; e2e tsc.
e2e.yml: also run the chromium-mobile project — 22 tests (focus traps, touch targets,
safe-area, viewport reflow) that never ran in CI on a phone-first app.
playwright.config: widen webkit-iphone beyond @smoke (2 specs) to the core guest journeys
(auth/upload/feed) — iOS Safari is the PRIMARY browser here; and retries 2 → 0.
retries:0 is deliberate and against the usual advice: this repo's real bugs are races, a
race is indistinguishable from a flake from outside, and a retry resolves that ambiguity
toward "flake" every time — it took a real 3%-flaky product bug from 1-in-33 to 1-in-37000,
green. A flake here is a bug report.
Not gated: cargo fmt (the tree has never been rustfmt'd — a 112-file reformat would bury
every real diff; do it separately). WebKit widening is unverified locally (needs libavif16
via sudo), so its first CI run may surface real iOS bugs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
271 lines
11 KiB
Markdown
271 lines
11 KiB
Markdown
# EventSnap
|
|
|
|
> A private, QR-code-accessed photo & video sharing platform for weddings, birthdays, and personal events — built for guests, run by you.
|
|
|
|
---
|
|
|
|
## What is EventSnap?
|
|
|
|
At private events, photos and videos are scattered across dozens of guests' phones and never truly shared. Existing solutions (WhatsApp groups, Google Photos) require accounts, expose personal data, and lack event-specific social features.
|
|
|
|
**EventSnap** gives every guest instant, frictionless access to a shared, living gallery — **no app store, no email, no password.**
|
|
|
|
A guest scans the QR code on their way in, types their name, and is immediately part of a shared moment. They upload, react, and comment throughout the day. After the event, the host releases the gallery — every guest walks away with a beautiful offline HTML keepsake and the full archive.
|
|
|
|
**Project type:** Mobile-first PWA — runs in any browser, no installation required.
|
|
**Scale:** Personal / private use — one event at a time, ~100 guests, ~1,000 files.
|
|
|
|
---
|
|
|
|
## Features
|
|
|
|
### MVP
|
|
|
|
| Area | Feature |
|
|
|------|---------|
|
|
| **Onboarding** | QR code join flow, name-only registration, persistent JWT + recovery PIN, 30-day sessions |
|
|
| **Uploads** | Photo & video from library or live camera, client-side IndexedDB queue, per-file progress & retry, captions + #hashtags |
|
|
| **Processing** | Lossless server-side compression, feed preview generation, ffmpeg video thumbnails |
|
|
| **Feed** | Chronological grid, real-time SSE updates, hashtag filtering, likes & comments |
|
|
| **Host Dashboard** | Ban/unban guests, delete content, promote to host, lock event, release gallery for export |
|
|
| **Admin Dashboard** | All host permissions + configure limits, rates, quota tolerance, disk usage widget |
|
|
| **Export** | On-demand ZIP (full-quality originals) + self-contained offline `Memories.html` viewer |
|
|
|
|
### Planned (v1.x)
|
|
|
|
- Individual file download button
|
|
- Low-disk alert (< 10 GB free)
|
|
- Event banner / cover image
|
|
- Chunked resumable upload for large videos
|
|
- Host-curated story highlights
|
|
- Slideshow / presentation mode
|
|
|
|
---
|
|
|
|
## Tech Stack
|
|
|
|
| Layer | Technology |
|
|
|-------|-----------|
|
|
| Frontend | SvelteKit + TypeScript |
|
|
| Styling | Tailwind CSS v4 |
|
|
| Backend | Rust + Axum |
|
|
| Async | Tokio |
|
|
| Database | PostgreSQL 16 via SQLx (compile-time query checking) |
|
|
| Auth | Custom JWT (`jsonwebtoken`) + bcrypt PINs |
|
|
| Image processing | `image` crate + `oxipng` (lossless compression) |
|
|
| Video processing | ffmpeg via `tokio::process::Command` |
|
|
| File storage | Local disk (`/media/`) |
|
|
| Real-time | Axum SSE + `tokio::sync::broadcast` |
|
|
| Export | `async-zip` (streaming ZIP) + `minijinja` (HTML bundle) |
|
|
| Rate limiting | `tower-governor` (token-bucket, DB-configurable) |
|
|
| Reverse proxy | Caddy 2 (automatic HTTPS via Let's Encrypt) |
|
|
| Containers | Docker + Docker Compose |
|
|
| Infrastructure | Hetzner CX33 (4 vCPU, 8 GB RAM, 80 GB SSD) |
|
|
|
|
---
|
|
|
|
## Repository Structure
|
|
|
|
```
|
|
eventsnap/
|
|
├── backend/ # Rust + Axum API server
|
|
│ ├── src/
|
|
│ ├── Cargo.toml
|
|
│ └── Dockerfile
|
|
├── frontend/ # SvelteKit PWA
|
|
│ ├── src/
|
|
│ ├── svelte.config.js
|
|
│ └── Dockerfile
|
|
├── docker-compose.yml
|
|
├── docker-compose.dev.yml # opt-in dev overlay (publishes Postgres on the host)
|
|
├── Caddyfile
|
|
└── .env.example
|
|
```
|
|
|
|
---
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- [Docker](https://docs.docker.com/engine/install/) (includes Compose plugin)
|
|
- A domain name with an A record pointing to your server
|
|
|
|
### Deploy on a fresh VPS
|
|
|
|
```bash
|
|
# 1. Clone the repository (into a lowercase dir, matching the paths used below)
|
|
git clone https://git.mc02.dev/fabi/EventSnap.git eventsnap
|
|
cd eventsnap
|
|
|
|
# 2. Configure environment
|
|
cp .env.example .env
|
|
nano .env # set DOMAIN, JWT_SECRET, ADMIN_PASSWORD_HASH, EVENT_NAME, etc.
|
|
|
|
# 3. Start the stack
|
|
docker compose up -d
|
|
```
|
|
|
|
Caddy automatically obtains a Let's Encrypt certificate on first start. The app is live at `https://DOMAIN` within ~30 seconds.
|
|
|
|
> **If the site never comes up:** with `APP_ENV=production` the backend **refuses to boot** while `JWT_SECRET`/`ADMIN_PASSWORD_HASH` still hold the `.env.example` placeholders (this is deliberate — a publicly-known signing key is worse than downtime). Caddy then waits on the unhealthy `app` container and never serves. Check `docker compose logs app` — a "Refusing to start … placeholder …" line means you skipped step 2. Rotate the secrets (see below) and restart.
|
|
|
|
> **Production note:** `docker compose up -d` does **not** expose the database — Postgres is reachable only on the internal Docker network. For local development where you need host access to Postgres, opt into the dev overlay explicitly:
|
|
> ```bash
|
|
> docker compose -f docker-compose.yml -f docker-compose.dev.yml up
|
|
> ```
|
|
|
|
### Generate required secrets
|
|
|
|
```bash
|
|
# JWT secret (64 random bytes)
|
|
openssl rand -hex 64
|
|
|
|
# Admin password hash (bcrypt, cost 12)
|
|
htpasswd -bnBC 12 "" yourpassword | tr -d ':\n'
|
|
```
|
|
|
|
### Environment Variables
|
|
|
|
See [.env.example](.env.example) for the full list with descriptions and defaults. Key variables:
|
|
|
|
| Variable | Description |
|
|
|----------|-------------|
|
|
| `DOMAIN` | Public domain for TLS (e.g. `my-wedding.example.com`) |
|
|
| `JWT_SECRET` | 64-byte random hex string for signing JWTs |
|
|
| `ADMIN_PASSWORD_HASH` | bcrypt hash of the admin dashboard password |
|
|
| `EVENT_NAME` | Display name shown to guests |
|
|
| `EVENT_SLUG` | URL-safe event identifier |
|
|
| `DATABASE_URL` | PostgreSQL connection string |
|
|
|
|
---
|
|
|
|
## Docker Compose Stack
|
|
|
|
```
|
|
┌─────────────────────────────────────┐
|
|
│ Caddy :80 / :443 (TLS termination) │
|
|
└────────────┬────────────────────────┘
|
|
│
|
|
┌────────┴────────┐
|
|
│ │
|
|
┌───▼────┐ ┌─────▼──────┐
|
|
│ app │ │ frontend │
|
|
│ :3000 │ │ :3001 │
|
|
│ (Rust) │ │(SvelteKit) │
|
|
└───┬────┘ └────────────┘
|
|
│
|
|
┌───▼────┐
|
|
│ db │
|
|
│ :5432 │
|
|
│(Postgres)│
|
|
└────────┘
|
|
```
|
|
|
|
- `/api/*` and `/media/*` → Rust backend
|
|
- Everything else → SvelteKit frontend (`adapter-node`)
|
|
- Named volumes: `postgres_data`, `media_data`, `caddy_data`
|
|
|
|
---
|
|
|
|
## Backup
|
|
|
|
```bash
|
|
# Database snapshot
|
|
pg_dump $DATABASE_URL | gzip > /media/backups/db_$(date +%Y-%m-%d).sql.gz
|
|
|
|
# Weekly offsite sync (Hetzner Storage Box or similar)
|
|
rsync -az /opt/eventsnap/media/ user@storagebox.example.com:backup/eventsnap/
|
|
```
|
|
|
|
The `/media` volume holds originals, previews, thumbnails, exports, and DB backups — a single path to back up.
|
|
|
|
---
|
|
|
|
## Running the backend test suite
|
|
|
|
```bash
|
|
cd backend
|
|
|
|
# The DB-backed integration tests (backend/tests/) need a live Postgres. `#[sqlx::test]` creates a
|
|
# throwaway database per test and runs backend/migrations/ into it — it does NOT touch this one's data.
|
|
docker run -d --name eventsnap-test-pg -p 55433:5432 \
|
|
-e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=eventsnap postgres:16-alpine
|
|
|
|
export DATABASE_URL=postgres://postgres:postgres@localhost:55433/eventsnap
|
|
cargo test # 44 unit + 12 DB-backed
|
|
cargo clippy --all-targets -- -D warnings
|
|
```
|
|
|
|
**`cargo test` requires `DATABASE_URL`** — without it the integration tests panic rather than skip.
|
|
That is deliberate. The riskiest code in this repo is SQL (the export epoch state machine, the
|
|
atomic quota increment, the `FOR SHARE` upload lock), and for a long time *not one line of it* was
|
|
executed by `cargo test` — every backend test was a pure-function test, so the tests clustered
|
|
tightly around the code that could not break and stopped exactly where it started to. Tests that
|
|
silently skip when the database is absent recreate that hole; they were meant to be a gate.
|
|
|
|
## Running the E2E test suite
|
|
|
|
Playwright-based end-to-end tests live in [`e2e/`](e2e/). They spin up an isolated docker-compose stack (Postgres on `:55432`, Caddy on `:3101`) and exercise the SvelteKit frontend against the real Rust backend with rate limits disabled.
|
|
|
|
```bash
|
|
cd e2e
|
|
npm install
|
|
npm run install:browsers # one-time
|
|
npm run stack:up # bring up the test stack
|
|
npm run test:e2e # full Phase 1 suite on chromium-desktop
|
|
npm run test:e2e:smoke # cross-UA matrix (chromium, samsung-internet, webkit, firefox, …)
|
|
npm run stack:down # tear it down
|
|
```
|
|
|
|
See [`e2e/README.md`](e2e/README.md) for the full UA matrix, Samsung Internet escalation tiers, and the Phase 2/3 roadmap.
|
|
|
|
CI runs this on every PR — see [`.github/workflows/e2e.yml`](.github/workflows/e2e.yml) (desktop **and**
|
|
mobile projects), plus [`checks.yml`](.github/workflows/checks.yml) for `cargo test`/clippy, the frontend
|
|
unit tests, svelte-check and the e2e typecheck, and [`audit.yml`](.github/workflows/audit.yml) for
|
|
dependency advisories.
|
|
|
|
**Playwright runs with `retries: 0`, including in CI.** This repo's real bugs are races, and from the
|
|
outside a race is indistinguishable from a flake — so a retry silently resolves that ambiguity in
|
|
favour of "flake" every time. A flake here is a bug report; treat it as one.
|
|
|
|
---
|
|
|
|
## Development Roadmap
|
|
|
|
Done:
|
|
- [x] Project blueprint & architecture
|
|
- [x] Monorepo scaffold (`backend/`, `frontend/`, Docker Compose)
|
|
- [x] DB schema + SQLx migrations (8 migrations through compression status + case-insensitive unique names)
|
|
- [x] Auth flow (join, JWT, 4-digit PIN with bcrypt + 3-attempt/15-min lockout, admin login)
|
|
- [x] Upload pipeline (multipart → compression worker via `tokio::sync::Semaphore` → SSE broadcast)
|
|
- [x] Client upload queue (IndexedDB, progress, retry, rate-limit auto-resume)
|
|
- [x] Gallery feed (list + grid toggle, SSE live updates, hashtag chips, in-memory search + autocomplete)
|
|
- [x] Camera capture (`getUserMedia` with front/back toggle, photo + `MediaRecorder` video)
|
|
- [x] Host Dashboard (event lock, gallery release, ban modal with hide-uploads choice, promote/demote, user search)
|
|
- [x] Admin Dashboard with inner tabs (Stats, Config, Export, Nutzer)
|
|
- [x] Export engine: streaming ZIP + SvelteKit-static HTML viewer (see [docs/CONCEPT_HTML_VIEWER.md](docs/CONCEPT_HTML_VIEWER.md))
|
|
- [x] Custom rate limiter (per-endpoint, hot-reloadable from `config` table)
|
|
- [x] Mobile-first redesign (bottom nav + FAB, see [docs/CONCEPT_MOBILE_UI.md](docs/CONCEPT_MOBILE_UI.md))
|
|
|
|
Open:
|
|
- [ ] Dynamic per-user storage quota enforcement (formula in [PROJECT.md §12](PROJECT.md); only tracking exists today)
|
|
- [ ] Own-upload deletion UI in the lightbox (backend route exists)
|
|
- [ ] SSE delta-fetch on foreground reconnect (scaffolded in [sse.ts](frontend/src/lib/sse.ts), not wired)
|
|
- [ ] Live diashow / slideshow mode — see [docs/CONCEPT_DIASHOW.md](docs/CONCEPT_DIASHOW.md)
|
|
- [ ] Individual file download button per post
|
|
- [ ] Low-disk alert (< 10 GB free)
|
|
- [ ] Event banner / cover image
|
|
- [ ] Chunked resumable upload for files > 100 MB
|
|
- [ ] Shared Tailwind config between main app and export-viewer
|
|
- [ ] End-to-end test event (10+ real devices on cellular)
|
|
|
|
See [docs/FEATURES.md](docs/FEATURES.md) for the up-to-date capability matrix by role.
|
|
Speculative / v2+ ideas live in [docs/IDEAS.md](docs/IDEAS.md).
|
|
|
|
---
|
|
|
|
## License
|
|
|
|
Private project — all rights reserved.
|