- JavaScript 43.5%
- TypeScript 38%
- Python 14.7%
- Nix 2.3%
- CSS 1.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo | ||
| .github | ||
| acceptance | ||
| bdfr-patches | ||
| nix | ||
| scripts | ||
| src | ||
| tests | ||
| web | ||
| .dockerignore | ||
| .gitignore | ||
| AGENTS.md | ||
| AMD-WORKERS.md | ||
| ARCHITECTURE.md | ||
| backup_legacy.py | ||
| benchmark.py | ||
| BENCHMARKS.md | ||
| CHANGELOG.md | ||
| DEPLOYMENT.md | ||
| ENCODER.md | ||
| flake.lock | ||
| flake.nix | ||
| init_db.py | ||
| legacy_inventory.py | ||
| LICENSE | ||
| MCP.md | ||
| migrate.py | ||
| MIGRATION.md | ||
| migration_status.py | ||
| package-lock.json | ||
| package.json | ||
| paseo.json | ||
| PRIORITIES.md | ||
| pyrightconfig.json | ||
| queries.sql | ||
| README.md | ||
| REMOTE-WORKERS.md | ||
| REQUIREMENTS-TRACE.md | ||
| REQUIREMENTS.md | ||
| schema.sql | ||
| tagger-amd.py | ||
| tagger.py | ||
| THIRD-PARTY-NOTICES | ||
| tsconfig.json | ||
| verify_migration.py | ||
| VERSION | ||
| VERSIONING.md | ||
| vite.config.ts | ||
Redview
This repository contains the V2 implementation. V1 is preserved on the v1-preservation branch. It includes browsing, curation, tagging, deduplication, separate background workers, generated OpenAPI and a resumable v1 database migration. Authentication supports anonymous browser sessions, password sign in, OIDC and a separate direct API key. Initial release acceptance and its explicit waivers are recorded; use REQUIREMENTS-TRACE.md for the current status. The server binds to 127.0.0.1 by default.
Requirement-by-requirement status and evidence are in REQUIREMENTS-TRACE.md.
Workers on other hosts can share media paths and send database commands to the main server; see remote worker setup and limits.
AI assistants can use the embedded /mcp endpoint to inspect jobs, curate entities and media, manage themes and folders, and preview images. Connect with the direct API key; see MCP setup and tools.
The remaining in-progress requirements are ordered by impact in PRIORITIES.md.
Development uses dev and temporary feature branches; release testing uses release/<version>, and main contains accepted, tagged releases. Branch rules, release-candidate versions and the complete release/back-merge commands are in VERSIONING.md.
The migration guide explains the read-only v1 backup, resumable conversion and rollback rehearsal.
NixOS service
The default flake package and NixOS module run V2. Existing redview-v2 package, command and module names remain available for compatibility. The v2 module creates separate redview-v2.service (browser and API) and redview-v2-worker.service units. It listens on 127.0.0.1:3211 and expects an existing v2 database at /var/lib/redview-v2/redview.db; it never initializes or migrates a database during service startup. The API and worker reject a v1 database or an incomplete v1-to-v2 migration before changing its schema. For a local empty demo database, initialize the target with redview-v2's packaged init_db.py or the repository script; for real data, follow MIGRATION.md.
{
inputs.redview.url = "path:/path/to/redview";
outputs = { self, nixpkgs, redview, ... }: {
nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
redview.nixosModules.redview-v2
{
services.redview-v2.enable = true;
services.redview-v2.databasePath = "/var/lib/redview-v2/redview.db";
}
];
};
};
}
Authentication
Set services.redview-v2.authMode to none (default), password, or oidc. In password mode, supply AUTH_PASS through services.redview-v2.environmentFiles. In OIDC mode, supply AUTH_DISCOVERY, AUTH_CLIENT_ID, AUTH_CLIENT_SECRET, and the public AUTH_BASE_URL through an environment file. The OIDC callback URI is <AUTH_BASE_URL>/auth/callback. For an HTTPS reverse proxy in password mode, set AUTH_COOKIE_SECURE=true in the environment file; OIDC infers it from an HTTPS base URL.
Opening the browser creates a session in none mode or starts sign in in the other modes. The session cookie authorizes browser API and media requests. Settings shows the separate direct API key and can rotate it; send the key in an X-Api-Key header from Bruno or another direct client. The key does not open the browser UI. /health and /api/spec remain public. Browser sessions are stored in the v2 database and survive an API process restart. The worker uses a different private key for BDFR callbacks, so rotating the direct key does not interrupt an active rip.
Open http://127.0.0.1:3211/ on the host, or use an SSH local port forward from another machine. To access existing media files, set services.redview-v2.user and .group to an account with the needed permissions, set .createUser = false, and give that account read/write access to the selected v2 database directory. The worker includes the patched BDFR 2.6.2 runtime, ffmpeg and a CPU Python tagging environment; set bdfr_bin to bdfr in Settings and bdfr_config_path to the absolute path of a readable BDFR config file. The same config file supplies credentials for subreddit descriptions. An accelerator build needs a suitable replacement Python environment. Keep v1 running on its own database and port during staging. See the acceptance report for tested scope and limits.
Run locally
From the repository root with Node.js 22 and npm:
npm ci
npm run build
python3 init_db.py /tmp/redview-v2-demo.db
REVIEW_V2_DB=/tmp/redview-v2-demo.db npm start
The empty browser view is at http://127.0.0.1:3001/. Gallery, Users, Subreddits, Themes and Settings also load directly at /gallery, /users, /subreddits, /themes and /settings; their links support refresh and browser Back. Favourites, Tags and Stats are also available. The generated schema is at /api/spec and in openapi.json. init_db.py refuses to replace an existing database. Add a gallery folder and rows only to a disposable database for this demonstration. The v1 database must not be passed to REVIEW_V2_DB.
Run the background worker in a separate terminal to execute queued jobs:
REVIEW_V2_DB=/tmp/redview-v2-demo.db npm run worker
For a local Nix trial without Node or npm installed, build the v2 package and its separate BDFR and CPU tagging runtimes from the repository root. The packaged worker supplies its tagger and perceptual-hash script paths; the CPU Python environment supplies the model dependencies:
nix build .#redview-v2 -o /tmp/redview-v2-demo-package
nix build .#redview-v2-bdfr -o /tmp/redview-v2-bdfr
nix build .#redview-v2-tagger-cpu -o /tmp/redview-v2-tagger-cpu
mkdir -p /tmp/redview-v2-data
PATH=/tmp/redview-v2-tagger-cpu/bin:/tmp/redview-v2-bdfr/bin:$PATH \
REDVIEW_PYTHON=/tmp/redview-v2-tagger-cpu/bin/python3 \
DATA_DIR=/tmp/redview-v2-data REVIEW_V2_DB=/tmp/redview-v2-demo.db \
/tmp/redview-v2-demo-package/bin/redview-v2-worker
For NVIDIA tagging, run nix build .#redview-v2-nvidia -o /tmp/redview-v2-nvidia and set REDVIEW_PYTHON to /tmp/redview-v2-nvidia/bin/python3 after confirming nvidia-smi can access the GPU. The tagger reports its active ONNX provider when it starts; CUDAExecutionProvider confirms GPU inference. ONNX can fall back to CPUExecutionProvider if the driver is unavailable.
Control the number of jobs the worker runs concurrently (default 2):
REVIEW_V2_WORKER_CONCURRENCY=4 REVIEW_V2_DB=/tmp/redview-v2-demo.db npm run worker
Gallery folders can be managed in Settings. The first enabled folder becomes the default destination; switching, disabling or removing that folder selects another enabled default. A subreddit can use an enabled folder of its own through the Subreddits browser or PATCH /api/subreddits/{subreddit}/folder with {"folder_id": 1}. Use {"folder_id": null} to return to the default. GET on the same route reports both the assignment and its effective destination; a disabled assignment falls back to the default.
The worker polls the jobs table and runs up to REVIEW_V2_WORKER_CONCURRENCY jobs at once. After a worker restart, interrupted scan, move and purge jobs are paused for deliberate resume through POST /api/jobs/{id}/resume; rip jobs automatically retry the current target. Scan, move, purge and rip jobs do not run simultaneously. The web server also starts a scheduler that re-queues scans for overdue folders based on the scan interval setting. Enqueue a scan job manually with:
curl -s -X POST http://127.0.0.1:3001/api/jobs \
-H 'X-Api-Key: YOUR_DIRECT_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"kind":"scan","payload":{"path":"/media"}}'
The scan path must be an enabled gallery folder. The scan walks supported media recursively, skips hidden directories and symlinks, and archives missing files as missing_on_scan only after a complete walk. GET /api/jobs/{id} reports checkpoint_json.scanned, added, and removed, plus error_count, started_at, and finished_at. An interrupted scan can be resumed without deleting rows from an incomplete walk. Existing v2 databases receive the scan reporting columns automatically on startup.
To start a rip, configure an enabled gallery folder and set the BDFR executable, config path and cooldown in Settings. Run the API and worker processes, then use the Rip panel in Settings to start, monitor, cancel or resume a job. The panel shows its current target, completed targets, registered download count as callbacks arrive, recent output, start/finish times and description-fetch warnings. Direct calls use POST /api/jobs with {"kind":"rip"}, GET /api/jobs/{id}, and the job cancel/resume routes. The worker downloads followed subreddits and users, skips blocked targets, and passes blocked users or subreddits to BDFR. Set REVIEW_V2_API_URL on the worker if the API is not on http://127.0.0.1:3001; the BDFR fork uses that URL to register completed media immediately and checks /api/media/checksum/{checksum} against live media and deletion history before writing a duplicate. For VPN access, provide a readable WireGuard config file, enter its absolute path in Settings and enable WireGuard. The worker starts a per-rip wireproxy SOCKS proxy, shares it between BDFR and subreddit description requests, and stops it when the rip ends or is cancelled. A migrated v1 wireguard_enabled=1 setting defaults to wireguard/wg0.conf beside the database or under DATA_DIR. REVIEW_V2_RIP_PROXY_URL remains available for an externally managed proxy when WireGuard is disabled. A worker restart retries the interrupted target; cancelling the job stops its BDFR subprocess. During the rip, newly discovered subreddits get their public descriptions through BDFR's OAuth credentials; the stored description appears in the Subreddits browser. Failed or empty fetches are reported in checkpoint_json.meta_failures and queued for a later rip. Live BDFR and real WireGuard routing tests remain pending.
The BDFR output folder in Settings can be any enabled gallery folder. It is used for users and subreddits without a folder assignment; an enabled subreddit assignment takes priority. Leave it at Use default gallery folder to follow the gallery default. If a migrated v1 output path or a later-disabled folder is unavailable, the worker falls back to the gallery default and Settings marks the saved path unavailable.
Use Move media beside a subreddit or Move all to assigned folders in the Subreddits browser to queue a move. Direct API calls are POST /api/subreddits/{subreddit}/move (optional {"folder_id": 1} override) and POST /api/subreddits/move-all. Both return a job ID; GET /api/jobs/{id} reports counts and the first 20 warnings in checkpoint_json. Moves preserve paths within the subreddit directory and append a number when a destination filename is occupied. A committed move intent lets a resumed job reconcile an interrupted file copy or database update. A missing or unsafe source is left in place and reported as a warning; a failed move must be resumed before another move can begin.
Newly scanned files receive a SHA-256 checksum when they do not already have one. BDFR filenames provide user, title, post ID, URL and zero-based resource index when parseable; files without those fields still enter the library. The first subfolder supplies the subreddit, while root-level files have no inferred subreddit. File mtime supplies an approximate post date, and rescans preserve metadata already recorded for that file.
A downloader can register each completed file immediately with POST /api/media/downloaded and a JSON body containing an absolute filepath. It may also provide checksum, post_id, user, subreddit, title, post_url, post_date, and post_index. Registration requires a regular supported media file inside an enabled gallery folder, rejects paths that escape through symlinks, and returns { "id": 123, "created": true }. Repeat calls keep the media ID and existing metadata unless richer values are supplied. New users and subreddits enter the new state; entities already seen, followed, blocked, or marked for deletion keep their state. The worker uses a private callback key for this route; direct clients use the rotatable API key from Settings in an X-Api-Key header.
Entity lists show an image thumbnail from each user or subreddit. Use Choose thumbnail to select a custom image from that entity's gallery; Reset thumbnail restores the automatic image fallback. GET, PUT and DELETE /api/thumbs/{type}/{value} expose the same behavior for direct calls. Original media and custom thumbnail selection validate that files are still inside an enabled gallery folder before serving or selecting them.
The Users view can filter collector and gender labels and edit each user's M/F/T/unset label or collector marker. PUT /api/users/{user}/gender and PUT /api/users/{user}/collector expose these controls to direct API callers. Marking a followed user as a collector moves them to seen; collectors cannot be followed until the marker is cleared.
The Themes view creates, lists, browses and deletes named subreddit groups. In Subreddits, Themes assigns any number of existing themes to a subreddit. GET/POST /api/themes, DELETE /api/themes/{id}, GET/PUT /api/subreddits/{subreddit}/themes, and GET /api/media?theme={id} expose the same workflow directly. Deleting a theme removes its assignments but keeps its subreddits and media.
The gallery Delete action and DELETE /api/media/{id} remove one file immediately. The active row disappears and media_deleted retains its checksum, identity and manual reason. Unsafe, missing and non-file paths return an error without discarding the active row. A committed deletion intent lets the API finish the tombstone at its next startup if the process stopped after unlinking the file.
Gallery tag filters use commas for AND and brackets for OR within a group: [cat,dog],landscape matches either cat or dog together with landscape. Excluded tags remove matches from any group. Tag suggestions offer Include and Exclude actions and preserve existing groups.
Use Tags on a gallery item to inspect its tag source, score and category, add a manual tag, or remove one assignment. GET and POST /api/media/{id}/tags provide the same per-item workflow; DELETE /api/media/{id}/tags/{tagId} removes one assignment. DELETE /api/tags/auto clears auto assignments only, with an optional name query parameter to target one tag. Manual assignments and blocked tag catalog entries remain intact.
GET /api/tags/top ranks auto-generated tags by assignment count, optionally within a category. GET /api/tags/search?q=cat searches tag names by literal substring (three characters or more) and returns counts with limit/offset pagination. Its optional category counts only assignments in that category; without it, counts include manual and auto assignments. The tag autocomplete remains the fast suggestion path in the gallery.
Vector similarity search is experimental. A vectorize job stores one 2048-dimensional embedding per non-video media row using the same image/text encoder, and reports progress through a recoverable checkpoint. GET /api/media/{id}/similar-vectors?limit= returns that item's nearest other visible media, and GET /api/media/search-by-text?q=&limit= returns ranked description matches. Results expose raw distance, not a confidence percentage.
Use Find by description in the gallery to show indexed matches as interactive image cards, best matches first. Clicking a card opens a slideshow through those matches; selection, favourites, tags and other curation actions use the normal gallery controls. Search covers indexed visible media across the gallery, independently of browsing filters. Clear restores ordinary browsing and its filters; changing a browsing filter also leaves description search. Set Settings → Image embeddings → Description search result limit to choose 1–1,000 matches (default 100), then select Save search limit. This setting persists across reloads and restarts. Repeat the same query as embeddings finish to include newly indexed images.
To index existing images, open Settings → Image embeddings → Calculate missing embeddings. The job processes images without stored vectors, keeps existing embeddings, and excludes videos. Progress, cancellation and resumption are available in that panel and in Job activity. Direct API clients can queue the same job with POST /api/jobs and body {"kind":"vectorize"}.
The API and workers connect to one persistent image/text encoder through REVIEW_V2_ENCODER_URL. The configured model is Qwen3-VL-Embedding-2B with the Hyphonical NSFW adapter; model identity is recorded in the index. Legacy placeholder vectors must be recalculated, and unavailable or mismatched encoders return an error. See ENCODER.md for runtime setup, pinned revisions and evaluation limits.
The blocked-content purge preview is GET /api/blocked/purge; POST /api/blocked/purge queues a worker job and returns its job ID. Follow progress with GET /api/jobs/{id}. Files outside their configured library root or files that cannot be removed remain active and count as job errors. A recorded deletion intent lets a resumed job finish the tombstone if the file was removed just before an interruption.
Blocked purge also includes media carrying blocked tags, and keeps those tags blocked after deleting their media. GET /api/unwanted/purge previews blocked users, subreddits and tags alongside marked entities, with a unique live-file count. POST /api/unwanted/purge queues combined cleanup. On overlap, blocked provenance takes priority; marked entities are removed after their media is gone. A purge job's checkpoint retains up to 20 file errors for review and removes each error when that file succeeds on resume.
DELETE /api/users/{user} and DELETE /api/subreddits/{subreddit} mark an entity for deletion without touching its files. Followed entities must be unfollowed first. POST /api/marked/unmark with {"type":"user","value":"Alice"} restores a marked entity to seen before cleanup. GET /api/marked/purge lists marked entities and counts unique live files; POST /api/marked/purge queues their cleanup. The worker deletes each file once, keeps a tombstone naming the responsible entity, and removes a marked user or subreddit only when no live media remains. Failed paths leave their media and entity records for deliberate job resume. The browser exposes marking, unmarking, preview, purge and resume controls.
Inspect a copy of an existing v1 database without modifying it:
python3 legacy_inventory.py /path/to/redview.db
The inventory reports table counts, columns, version and a few migration inconsistencies. It is not a migration. Current package check: nix build .#redview-v2 from the repository root. The package remains available under .#redview-v2 once these files are committed.