Nele-Till-Hochzeit
Self-hosted Next.js 14 standalone wedding media gallery with BullMQ/Redis background workers, admin scanner, custom grid layout, and AGE-encrypted deployment.
Overview
Nele-Till-Hochzeit is a self-hosted, high-performance wedding photo, video, and audio gallery built on Next.js 14 (standalone output). It serves a curated public gallery with interactive voting, fullscreen media browsing, background music playback with synchronized lyrics, and one-click ZIP downloads, alongside a protected /admin dashboard for media scanning, publication control, and grid layout curation.
System Architecture
┌──────────────────────────────┐
│ Next.js 14 Standalone App │
│ (server.js · Port 3000) │
│ │
Public Gallery ─────►│ App Router + API Routes │
Admin (/admin) ─────►│ instrumentation.ts Startup │
└──────┬───────────────┬───────┘
│ │
Prisma ORM │ │ BullMQ + ioredis
▼ ▼
┌──────────────────┐ ┌──────────────────────────┐
│ PostgreSQL 16 │ │ Redis 7.4 │
│ MediaItem, Like │ │ Queues: │
│ AppSettings, │ │ • scan (1x) │
│ AdminSession, │ │ • thumbnails (2x) │
│ RateLimitEntry │ │ • video-previews (1x) │
└──────────────────┘ │ • zip (1x, debounced) │
└────────────┬─────────────┘
│
sharp + FFmpeg + archiver
│
▼
/media (ro) ──► /cache
(thumbnails, previews, ZIP)
Features
- Public Media Wall & Fullscreen Viewer:
- Randomized chunked/ranked masonry wall (
/), directory filtering, and deep-link media URLs (/[...mediaPath]). - Fullscreen viewer supporting keyboard navigation, touch swipe gestures, sharing, and optional IP-hashed likes (
votingOpentoggle). - Integrated background music player (
/api/music) with on-demand.txtlyrics lookup (/api/music/lyrics) and automatic pause when opening videos or audio items. - Filtered, atomically built archive download (
GET /api/downloadservingHochzeit Nele & Till - 19.09.2026.zipcontaining only published media plusMusik/*.txtlyrics).
- Randomized chunked/ranked masonry wall (
- Automated Filesystem Scanner & Media Pipeline:
- Startup scan (5s after boot) and periodic scan (
SCAN_INTERVAL_SECONDS, default60s) via Next.jsinstrumentation.ts. - Stability check (
FILE_STABILITY_DELAY_MS, default3000ms) prevents ingesting files still transferring (e.g., via Syncthing); ignores_-prefixed folders and.txt/temp/Synology files. - Images (
sharp): EXIF auto-rotation, HEIC/HEIF conversion,400pxWebP thumbnails (_thumb.webp), and1600pxWebP gallery previews (_gallery.webp). - Videos (
FFmpeg/FFprobe): Dimensions/duration probing,480pxWebP poster (_poster.webp), and 4-second muted480pxH.264 MP4 preview (_preview.mp4). - ZIP Worker (
archiver): Debounced (ZIP_DEBOUNCE_MINUTES, default5) atomic.tmp→ rename rebuilds so existing downloads stay valid on failure.
- Startup scan (5s after boot) and periodic scan (
- Protected Admin Dashboard (
/admin,/admin/layout):- Password login (
/admin/login) with HTTP-only session cookies (wedding_admin_session) stored in PostgreSQL and rate-limited against brute-force attempts. - One-click Scanner trigger (
POST /api/admin/scan), individual/bulk publish toggles, voting lock toggle, and admin fullscreen curation shortcuts (ForSpace). - Custom layout editor (
/admin/layout) supportingRANKING,FIXED_POSITION,FIXED_SIZE_RANKING,FIXED_POSITION_ADJUSTABLE,featuredflags,sortOrder, anddirectoryOrder.
- Password login (
- Security Hardening (
src/middleware.ts):- Enforces CSP,
X-Frame-Options: DENY,X-Content-Type-Options: nosniff,Permissions-Policy, blocks internal dotfiles/paths (/.env,/.git,/prisma, etc.), and rate-limits login & like requests.
- Enforces CSP,
How It Works & Tech Stack
| Layer | Technology | Details |
|---|---|---|
| Framework | Next.js 14.2.15 (output: 'standalone') |
React 18.3.1, TypeScript 5.5.4, instrumentationHook |
| Database | PostgreSQL 16.4-alpine + Prisma 5.20.0 |
Models: MediaItem, Like, AppSettings, AdminSession, RateLimitEntry |
| Queue & Cache | Redis 7.4-alpine + BullMQ 5.13.0 + ioredis 5.4.1 |
4 queues/workers (scan, thumbnails, video-previews, zip) |
| Media Processing | sharp 0.33.5, ffmpeg (vips-dev), archiver 7.0.1 |
WebP thumbnails/previews, MP4 short previews, streamed ZIP downloads |
| Security & Auth | bcrypt 5.1.1, Next.js Middleware, PostgreSQL Rate Limiter |
Session cookies + SHA-256 hashed client IPs for likes & rate limits |
| Container | Multi-stage Dockerfile (node:22-alpine) |
Non-root user nextjs (UID 1001), healthcheck on /api/health |
| Testing | Vitest 2.1.2, Playwright 1.48.0, ESLint 8.57.1 |
Unit and E2E test setup |
Ports
| Environment | Host Mapping → Container Port | Service |
|---|---|---|
docker-compose.yml |
127.0.0.1:3001 → 3000 |
Next.js standalone app |
docker-compose.yml |
127.0.0.1:5433 → 5432 |
PostgreSQL |
docker-compose.prod.yml |
127.0.0.1:3847 → 3000 |
Next.js standalone app (behind reverse proxy on jannik-cloud-net) |
Prerequisites & Installation
Prerequisites
- Docker & Docker Compose
ageCLI (for decrypting.env.ageinto.env)- For local non-Docker development: Node.js 22+, PostgreSQL 16, Redis 7, and FFmpeg
Clone & Decrypt Environment (AGE Setup)
git clone https://git.orfel.de/Jannik/Nele-Till-Hochzeit.git
cd Nele-Till-Hochzeit
Decrypt .env.age to .env using your local age private key (the scripts search ~/.age/keys.txt, ./keys/age-key.txt, and /opt/Jannik-Cloud/keys/age-key.txt):
# Linux / macOS
./scripts/decrypt-env.sh
# Windows (PowerShell)
.\scripts\decrypt-env.ps1
To re-encrypt an updated .env before committing .env.age (uses the public key configured in scripts/encrypt-env.ps1):
.\scripts\encrypt-env.ps1
Run with Docker Compose
Local / Staging (docker-compose.yml):
docker compose up -d
Production (docker-compose.prod.yml):
Ensure the pre-built image git.orfel.de/jannik/nele-till-hochzeit:latest and external network jannik-cloud-net exist, then start:
docker compose -f docker-compose.prod.yml up -d
On startup, docker-entrypoint.sh automatically applies the Prisma schema (prisma db push --accept-data-loss --skip-generate) and starts node server.js.
Local Development (without Docker)
cp .env.example .env
npm install
npm run db:generate
npm run db:push
npm run dev
Configuration
Copy .env.example to .env (or decrypt .env.age):
| Variable | Default / Example | Description |
|---|---|---|
DATABASE_URL |
postgresql://wedding:...@postgres:5432/wedding |
PostgreSQL connection string for Prisma |
POSTGRES_USER |
wedding |
PostgreSQL username (used by Compose healthcheck & init) |
POSTGRES_PASSWORD |
— | PostgreSQL password |
POSTGRES_DB |
wedding |
PostgreSQL database name |
REDIS_URL |
redis://redis:6379 |
Redis connection URL for BullMQ queues & workers |
ADMIN_PASSWORD |
— | Admin login password (or bcrypt hash) for /admin/login |
APP_SECRET |
— | Random secret (>= 32 chars) for session/hash signing |
MEDIA_ROOT |
/media |
Source media root directory (mounted read-only in Compose) |
CACHE_DIR |
/cache |
Cache root for thumbnails, video previews, and ZIPs |
ZIP_OUTPUT_PATH |
/cache/download/hochzeit.zip |
Target path for the downloadable ZIP archive |
PUBLIC_BASE_URL |
https://hochzeit.orfel.de |
Public base URL without trailing slash |
NODE_ENV |
production |
Runtime mode (production enables Secure + SameSite=Strict cookies) |
PORT |
3000 |
Internal Next.js server port |
SCAN_INTERVAL_SECONDS |
60 |
Interval in seconds for automatic background media scans |
FILE_STABILITY_DELAY_MS |
3000 |
Wait interval in ms to verify files are not actively changing |
ZIP_DEBOUNCE_MINUTES |
5 |
Debounce window in minutes before rebuilding the ZIP archive |
Volumes
docker-compose.yml:./media:/media:ro,wedding-cache:/cache,wedding-pgdata,wedding-redisdocker-compose.prod.yml:/mnt/Jannik-Cloud-Volume-01/hochzeit/media:/media:ro,.../cache:/cache,.../pgdata:/var/lib/postgresql/data,.../redis:/data
Usage
Keyboard Shortcuts (Fullscreen Viewer)
| Key | Scope | Action |
|---|---|---|
ArrowLeft / ArrowRight |
Public & Admin | Navigate to previous / next media item |
Escape |
Public & Admin | Close fullscreen viewer |
F |
Admin (/admin) |
Toggle published state of the current item |
Space |
Admin (/admin) |
Toggle published state (for images; preserves playback control on video/audio) |
Key Routes & API Endpoints
| Route | Method | Auth | Description |
|---|---|---|---|
/ |
GET |
Public | Main wedding media wall |
/[...mediaPath] |
GET |
Public | Deep link opening a specific media item |
/admin |
GET |
Session | Admin dashboard (scanner, publish toggles, voting lock) |
/admin/layout |
GET |
Session | Visual grid placement & directory ordering editor |
/admin/login |
GET |
Public | Admin login page |
/api/health |
GET |
Public | Container healthcheck ({ status: "ok", timestamp }) |
/api/media |
GET |
Public / Admin | Paginated gallery items (admin=true requires session) |
/api/media/[...path] |
GET |
Public | Serves thumbnails, gallery WebPs, video previews, or originals |
/api/likes/[id] |
POST / DELETE |
Public | Toggle IP-hashed like when votingOpen is true |
/api/download |
GET |
Public | Streams the pre-built published ZIP archive |
/api/music, /api/music/lyrics |
GET |
Public | Lists published audio tracks & fetches matching .txt lyrics |
/api/auth/login, logout, check |
POST / GET |
Public / Session | Admin session authentication endpoints |
/api/admin/scan |
POST |
Session | Enqueues an immediate filesystem scan (enqueueScan) |
/api/admin/settings |
GET / PATCH |
Session | Read/update votingOpen and directoryOrder |
/api/admin/layout |
GET / PUT |
Session | Read/save grid placement & featured flags |
/api/admin/media/[id], bulk |
PATCH / POST |
Session | Single or bulk media metadata/publication updates |
Project Structure
Nele-Till-Hochzeit/
├── prisma/
│ └── schema.prisma # PostgreSQL schema (MediaItem, Like, AppSettings, AdminSession, RateLimitEntry)
├── public/ # Static public assets
├── scripts/
│ ├── decrypt-env.ps1 # Windows PowerShell AGE decryption (.env.age -> .env)
│ ├── decrypt-env.sh # Bash AGE decryption (.env.age -> .env)
│ └── encrypt-env.ps1 # PowerShell AGE encryption (.env -> .env.age)
├── src/
│ ├── instrumentation.ts # Server startup hook: starts BullMQ workers & initial scan
│ ├── middleware.ts # Security headers, CSP, path blocking & /admin redirect
│ ├── app/
│ │ ├── icon.svg
│ │ ├── layout.tsx / page.tsx
│ │ ├── [...mediaPath]/page.tsx # Deep-link media viewer route
│ │ ├── admin/ # /admin, /admin/layout, /admin/login pages
│ │ └── api/ # Health, media, likes, download, music, auth & admin APIs
│ ├── components/ # FullscreenViewer, MediaWall, MediaTile, MusicPlayer, Header, etc.
│ ├── hooks/ # useMediaWall, useViewer
│ └── lib/
│ ├── auth/session.ts # Admin session helpers
│ ├── jobs/
│ │ ├── queue.ts # BullMQ queues (scan, thumbnails, video-previews, zip)
│ │ └── workers.ts # BullMQ workers + periodic scan interval
│ ├── media/types.ts # Extension/MIME detection & scanner exclusion rules
│ ├── processing/
│ │ ├── images.ts # sharp WebP thumbnail & gallery processor
│ │ ├── videos.ts # FFmpeg poster & muted MP4 preview processor
│ │ └── zip.ts # Atomic archiver ZIP builder
│ ├── scanner/index.ts # Recursive filesystem scanner & DB reconciliation
│ └── security/ # Auth, path traversal guard, PostgreSQL rate limiter
├── .env.age # AGE-encrypted production environment file
├── .env.example # Plaintext environment template
├── Dockerfile # Multi-stage Node 22 Alpine build (sharp + ffmpeg)
├── docker-compose.yml # Local Compose stack (app, postgres, redis)
├── docker-compose.prod.yml # Production Compose stack (Jannik-Cloud)
├── docker-entrypoint.sh # Runs `prisma db push` then `node server.js`
├── next.config.js # Standalone output & serverComponentsExternalPackages
└── package.json
License
This project's own code is dedicated to the public domain under CC0 1.0 Universal — see LICENSE.
Third-Party Components: External dependencies, bundled libraries, fonts, datasets, and media assets retain their own respective licenses and are excluded from CC0 1.0. See
THIRD_PARTY_NOTICES.mdfor details.