An admin dashboard for the links behind your NFC tags and QR codes.
A tag is physical and awkward to re-encode once it is stuck on a wall. So
redorect puts a stable URL on the tag — /r/{slug} — and keeps what that
URL does in a database you can edit at any time. One tag, repointed as
often as you like, without ever touching the sticker again.
Each link does one of four things when scanned:
| Target | What a scan gets |
|---|---|
| Redirect | An HTTP 302 straight to a URL — the phone leaves immediately |
| Text | A rendered page with a heading and body text |
| Image | A full-bleed image, uploaded or linked, with an optional caption |
| Video | A YouTube embed or an uploaded clip, with optional autoplay and loop |
The dashboard sits behind a login. There is no sign-up page — the first account is seeded from the environment, and every account after that is created from the Users screen.
┌─────────────┐ / ┌──────────────┐
│ scanner │──────────────────────▶ │ nginx │
│ (phone/tag) │ /r/{slug} │ (frontend) │
└─────────────┘ └──────┬───────┘
/r/, /api/ │ / → Dioxus SPA (wasm)
▼
┌──────────────┐ ┌──────────┐
│ axum backend │────▶│ Postgres │
└──────────────┘ └──────────┘
Three crates in one workspace:
shared/— the types both sides speak:Link,LinkTarget, the auth payloads, plusslugify/is_valid_slug/youtube_idso the editor and the backend agree on what a slug and a video URL are.backend/— axum + sqlx. Serves the JSON API for the dashboard and the public tag pages.frontend/— Dioxus 0.7 (web) + Tailwind. The dashboard only.
/r/{slug} is handled by the backend, not the SPA. A phone that just tapped
a tag gets one self-contained HTML response — no wasm bundle, no stylesheet
fetch, no font fetch — so the page paints on the first round trip. A
Redirect target doesn't even render that much: it is a bare 302.
This is why nginx routes /r/ to the backend rather than letting it fall
through to index.html. If you put your own proxy in front, it has to do
the same.
Public pages are sent Cache-Control: no-store, so pausing or repointing a
link takes effect on the very next scan. Uploads, which are immutable, are
cached for a year.
docker compose up --buildThe dashboard is on http://localhost, and tags resolve at
http://localhost/r/{slug}. Sign in with ADMIN_EMAIL / ADMIN_PASSWORD
(defaults: admin@example.com / changeme — change them).
docker compose -f docker-compose.dev.yml up --buildDashboard on http://localhost:8080, backend on http://localhost:3000. Both reload on save.
Note that in dev the two run on different origins, so the frontend is built
with API_BASE and PUBLIC_BASE pointed at the backend — the latter
because the QR codes have to encode a URL that the backend answers, not
the dev server.
# 1. a database
docker run -d --name redorect-pg -p 5432:5432 \
-e POSTGRES_DB=redorect -e POSTGRES_USER=redorect \
-e POSTGRES_PASSWORD=redorect_secret postgres:17.5
# 2. the backend (migrations and the admin fixture run on boot)
DATABASE_URL=postgresql://redorect:redorect_secret@localhost:5432/redorect \
cargo run -p backend
# 3. the dashboard
tailwindcss -i frontend/input.css -o frontend/assets/tailwind.css --watch &
cd frontend && API_BASE=http://localhost:3000 PUBLIC_BASE=http://localhost:3000 dx serveThe chart in helm/redorect deploys the backend, the frontend and a bundled
single-instance PostgreSQL.
helm install redorect ./helm/redorect \
--namespace redorect --create-namespace \
--set ingress.enabled=true \
--set ingress.className=nginx \
--set ingress.host=tags.example.com \
--set ingress.tls.enabled=true \
--set ingress.tls.secretName=redorect-tls \
--set env.jwtSecret="$(openssl rand -base64 32)" \
--set env.adminPassword='pick-something-real'Rather than passing secrets on the command line, point the chart at a Secret
you manage yourself — it must carry JWT_SECRET, ADMIN_EMAIL,
ADMIN_PASSWORD, and DATABASE_URL if you also disable the bundled
database:
helm install redorect ./helm/redorect --set existingSecret=redorect-secretsTo use a managed database instead of the bundled one:
--set postgresql.enabled=false \
--set externalDatabase.url=postgresql://user:pass@host:5432/redorectThings worth knowing before you deploy:
- One Ingress rule, everything to the frontend. Its nginx splits
/api/and/r/off to the backend itself. Don't add a second rule routing/r/straight to the backend service — and don't let/r/fall through to the SPA, or tags will serve the dashboard'sindex.html. proxy-body-sizeis not optional. The chart defaults tonginx.ingress.kubernetes.io/proxy-body-size: "33m", because the nginx ingress controller caps bodies at 1MB and would reject every image and video upload. On a different controller, set its equivalent — Traefik imposes no limit by default, so nothing is needed there.COOKIE_SECUREfollowsingress.tls.enabled. Overrideconfig.cookieSecurewhen TLS terminates somewhere the chart can't see, such as an external load balancer. Getting this wrong one way sends session tokens in clear text; the other way locks you out, since browsers dropSecurecookies arriving over plain HTTP.API_BASEandPUBLIC_BASEare baked into the wasm bundle at image build time and left empty in the release image, which is correct for a single-origin deployment. They are deliberately absent fromvalues.yaml: serving the dashboard and the tags from different hosts needs a rebuilt frontend image, not a chart value.- The backend is stateless — links, uploads and scan history all live in
Postgres — so
backend.replicaCountcan be anything. The database is a single StatefulSet replica holding your uploaded media; back the volume up. - Scan client IPs depend on the forwarded-header chain. The ingress
controller sets
X-Forwarded-For, the frontend's nginx appends to it, and the backend reads the first entry. Strip or overwrite that header anywhere in the chain and the history will record the proxy's address instead.
| Variable | Used by | Meaning |
|---|---|---|
DATABASE_URL |
backend | Postgres connection string. Required. |
JWT_SECRET |
backend | Signs session tokens. Set it in production. |
COOKIE_SECURE |
backend | true marks the auth cookie Secure. Only when actually on HTTPS — browsers drop Secure cookies over plain HTTP and you will be locked out. |
ADMIN_EMAIL / ADMIN_PASSWORD |
backend | The account seeded on an empty database. |
API_BASE |
frontend (build time) | Origin of the API. Empty when one proxy serves both. |
PUBLIC_BASE |
frontend (build time) | Origin that QR codes and tag URLs are built against. Empty means "wherever the dashboard is loaded from". |
Public — no session, this is what a tag hits:
| Method | Path | |
|---|---|---|
GET |
/r/{slug} |
Resolve a tag: 302, or a rendered page |
GET |
/api/media/{id} |
Serve an upload (supports byte ranges) |
Dashboard — all require the auth_token cookie:
| Method | Path | |
|---|---|---|
POST |
/api/auth/login · /api/auth/logout |
|
GET POST |
/api/links |
List, create |
GET PUT DELETE |
/api/links/{id} |
Read, update, delete |
GET |
/api/links/stats |
Overview counters |
GET |
/api/links/slug-check?slug= |
Advisory availability check |
GET |
/api/links/{id}/scans?page=&per_page= |
One page of a link's scan history, plus device/browser breakdowns |
POST |
/api/media |
Upload raw bytes, typed by Content-Type |
GET POST |
/api/users |
List, create |
PUT |
/api/users/me/password |
Change your own |
PUT DELETE |
/api/users/{id}/password · /api/users/{id} |
Reset another's, delete |
- Slugs are lowercase
[a-z0-9-], no leading/trailing or doubled dashes, 48 characters max. Leave the field empty when creating and one is derived from the name (with a-2,-3… suffix if it collides). Accented letters become dashes rather than being folded to ASCII, soSalle de réunion→salle-de-r-union; pick the slug by hand when that matters. - Pause, don't delete. Deleting frees the slug, so a tag already in the wild could later resolve to something unrelated. Pausing keeps the slug reserved and answers 404.
- Redirect targets must be
http://orhttps://.javascript:anddata:URLs are rejected, since the public page hands the value straight to a scanner's browser. - Uploads live in a Postgres
BYTEAcolumn: 15 MB for images, 32 MB for videos. That is deliberately modest — every scan reads the blob back through the connection pool. For anything longer, host the file elsewhere and use aRedirecttarget. - Autoplay is always muted. Mobile browsers block unmuted autoplay outright, which would leave a scanned tag showing a frozen first frame.
- Every account is a full admin. There are no roles; the app has one job and no read-only audience. What is enforced instead is that you cannot delete your own account or the last remaining one — with no sign-up page, either would lock everyone out permanently.
- Scan counts are incremented synchronously on the resolve path, so they never silently drop writes. They count resolutions, not unique people.
- Scan history. Every resolution is also recorded as a row in
scans, listed page by page on a link's history screen: timestamp, device kind, browser, OS, IP, and referrer. Deleting a link cascades its history away. - Device detection is coarse.
backend/src/useragent.rsis substring matching on theUser-Agent, not a UA database — it will misattribute exotic browsers. Link-preview crawlers (WhatsApp, Telegram, Googlebot…) are flagged asBotand dimmed in the history, because a tag's URL pasted into a chat gets prefetched and would otherwise read as a real scan. - A
Refererusually means the URL was shared, not scanned — a camera app opens the URL directly, with no referrer. The history shows "Direct" in that case. - The scan history is personal data. It stores the visitor's IP address
and full user-agent string. Under the GDPR that needs a lawful basis, a
retention limit and a privacy notice wherever the tags are deployed —
none of which this app enforces for you. If you don't need it, drop the
column or stop passing the value in
scans::record; if you do, add a retention job (DELETE FROM scans WHERE scanned_at < NOW() - INTERVAL …).
See CONTRIBUTING.md. The short version:
cargo fmt --all
cargo clippy --workspace --exclude frontend -- -D warnings
cargo clippy -p frontend --target wasm32-unknown-unknown -- -D warnings
cargo test --workspace --exclude frontend