Requirements
- Docker Engine with Compose v2 (the
docker composeplugin). - A Linux host for production storage — Unraid, TrueNAS SCALE, Proxmox, or any Debian/Ubuntu box. Mount propagation and inode semantics are Linux features.
- Local disk for
./data— the SQLite index and WebP thumbnails. Keep it off network shares: SQLite WAL relies on shared memory that NFS and SMB cannot provide. - Nothing else. The backend image already bundles
ffmpeg,tesseract-ocr, andpoppler-utils, and runs as an unprivilegedtaoguser.
Quickstart
Clone the repository and start both services. The first run builds the Go backend and the Next.js studio images.
$ git clone https://github.com/jerrytunin/taog.git && cd taog && docker compose up -dConfirm the API is healthy and the database is in WAL mode:
$ curl -s http://localhost:8115/api/v1/health{"status":"ok","service":"taog","version":"0.1.0-alpha","db":"wal"}Then open the studio at http://localhost:8116. After pulling new commits, rebuild with docker compose up -d --build.
Ports
| Host port | Service | Serves |
|---|---|---|
8115 | taog-backend | REST /api/v1/*, SSE /api/v1/events, MCP POST /mcp |
8116 → 3000 | taog-frontend | Next.js studio UI |
To move the backend, change TAOG_ADDR and the matching ports entry together.
Compose file
The stack shipped in the repository root:
services: taog-backend: build: context: ./backend dockerfile: Dockerfile container_name: taog-backend restart: unless-stopped ports: - "8115:8115" environment: - TAOG_ADDR=:8115 - TAOG_DB_PATH=/data/taog.db - TAOG_THUMB_DIR=/data/thumbs - TAOG_MOUNT_ROOT=/mnt - TAOG_CORS_ORIGIN=* - TAOG_SCAN_CONCURRENCY=4 volumes: - ./data:/data # Uncomment to expose host/NAS mounts read-only for indexing: # - /mnt:/mnt:ro,rslave taog-frontend: build: context: ./frontend dockerfile: Dockerfile args: - NEXT_PUBLIC_API_URL=http://localhost:8115 container_name: taog-frontend restart: unless-stopped ports: - "8116:3000" environment: - NEXT_PUBLIC_API_URL=http://localhost:8115 depends_on: - taog-backendEnvironment variables
All configuration is read from the environment of taog-backend at startup. Empty values fall back to the defaults below.
| Variable | Default | Status | Purpose |
|---|---|---|---|
TAOG_ADDR | :8115 | Live | Listen address for REST, SSE, and MCP. |
TAOG_DB_PATH | ./data/taog.db | Live | SQLite database file; WAL and SHM sidecars live beside it. Compose sets /data/taog.db. |
TAOG_THUMB_DIR | ./data/thumbs | Live | WebP thumbnails and video filmstrip sprites. Compose sets /data/thumbs. |
TAOG_QUARANTINE_DIR | — | T8 | Destination for the quarantine remediation mode. Files keep their relative path so they can be moved back. Suggested: /data/quarantine. |
TAOG_MOUNT_ROOT | /mnt | Live | Container path where host and NAS storage is bind-mounted. Source root_path values live beneath it. |
TAOG_SCAN_CONCURRENCY | 4 | Live | Global scan worker count. Integers ≥ 1; anything else falls back to 4. Each source also throttles its own mount via io_concurrency. |
TAOG_CORS_ORIGIN | * | Live | Sent as Access-Control-Allow-Origin. Pin it to the studio origin when the API is reachable beyond localhost. |
TAOG_WEBHOOK_URL | — | T8 | Webhook or ntfy endpoint for bit-rot, scan, and remediation alerts. |
NEXT_PUBLIC_API_URL | http://localhost:8115 | Live | Studio only: build-time API base URL compiled into the browser bundle. |
Variables marked T8 are reserved for the Safe Remediation milestone; v0.1.0-alpha ignores them, so setting them early is harmless.
Read-only host & NAS mounts
Indexing, search, hashing, duplicate analysis, and bit-rot scrubbing only ever read. Bind every data path with :ro so the kernel — not application logic — guarantees your files cannot be modified.
volumes: - ./data:/data # Unraid user shares - /mnt/user:/mnt/user:ro,rslave # NFS / SMB shares mounted on the host (fstab, autofs, systemd) - /srv/nas:/mnt/nas:ro,rslave # A second disk or VM export - /mnt/backups:/mnt/backups:ro,rslaveWhat the flags do
| Flag | Effect |
|---|---|
ro | The mount is read-only inside the container. Writes fail with EROFS no matter what any API call or UI action requests. |
rslave | Recursive, one-way propagation from host to container. Shares that mount after Taog starts — autofs NFS, SMB, USB disks, an Unraid array coming online after Docker — appear inside the container without a restart. Nothing mounted inside the container leaks back to the host. |
Checking propagation
rslave only receives events if the host path sits on a shared mount. systemd makes / shared by default; verify, and fix if needed:
$ findmnt -o TARGET,PROPAGATION /mnt# PROPAGATION should read "shared". If it says "private":$ sudo mount --make-rshared /mntDocker Desktop on macOS and Windows does not support propagation flags on host paths — use plain :ro there. Bind mounts preserve device and inode numbers, which is what lets Taog recognize existing hardlinks across paths.
Registering sources
A source is a named root to index. root_path is a container path, so it lives under TAOG_MOUNT_ROOT.
$ curl -sS -X POST http://localhost:8115/api/v1/sources \ -H 'Content-Type: application/json' \ -d '{"name":"media","host":"nas-01","root_path":"/mnt/user/media","io_concurrency":2}'| Field | Type | Required | Notes |
|---|---|---|---|
name | string | yes | Unique display name. A duplicate returns 409. |
host | string | yes | Host label shown in results, e.g. nas-01. |
root_path | string | yes | Absolute container path to index. |
io_concurrency | integer | no | Parallel I/O for this mount. Values below 1 become 2. |
cron_schedule | string | no | Cron expression saved with the source. |
Unknown fields are rejected, and leading or trailing whitespace is trimmed from every string.
Conventions
| Topic | Behavior |
|---|---|
| Base URL | http://<host>:8115 |
| Format | JSON in and out. Errors are {"error":"message"} with a 4xx/5xx status. |
| Body limit | Request bodies are capped at 1 MiB. |
| CORS | Access-Control-Allow-Origin from TAOG_CORS_ORIGIN; methods GET, POST, OPTIONS; headers Content-Type, Authorization. Preflight OPTIONS returns 204. |
| Timestamps | RFC 3339 UTC, e.g. 2026-11-27T19:02:11Z. |
REST endpoints
/api/v1/healthLiveLiveness and database probe. db reports SQLite's journal mode in lowercase.
{ "status": "ok", "service": "taog", "version": "0.1.0-alpha", "db": "wal" }{ "status": "degraded", "service": "taog", "version": "0.1.0-alpha", "db": "error" }/api/v1/statsLiveIndex-wide counters for dashboards and agents.
{ "source_count": 3, "file_count": 4812337, "total_bytes": 38620000000000, "protected_path_count": 2, "bitrot_open_count": 1}- 500
- {"error":"failed to load stats"}
/api/v1/sourcesLiveEvery registered source.
{ "sources": [ { "id": 1, "name": "media", "host": "nas-01", "root_path": "/mnt/user/media", "enabled": true, "io_concurrency": 2, "cron_schedule": "", "last_scan_at": null, "created_at": "2026-11-27T19:02:11Z" } ]}- 500
- {"error":"failed to list sources"}
/api/v1/sourcesLiveRegister a source. See Registering sources for the body schema.
{ "name": "media", "host": "nas-01", "root_path": "/mnt/user/media", "io_concurrency": 2 }- 201
- The created source, same shape as an entry in GET /api/v1/sources
- 400
- {"error":"invalid JSON payload"} — malformed JSON or unknown field
- 400
- {"error":"name, host, and root_path are required"}
- 409
- {"error":"source name already exists"}
- 500
- {"error":"failed to create source"}
Server-sent events
/api/v1/eventsLiveA long-lived text/event-stream with Cache-Control: no-cache. A ready event is sent on connect, then a comment keepalive every 25 seconds until the client disconnects.
$ curl -N http://localhost:8115/api/v1/eventsevent: readydata: {"status":"connected","service":"taog"} : keepaliveconst events = new EventSource("http://localhost:8115/api/v1/events"); events.addEventListener("ready", (e) => { console.log(JSON.parse(e.data)); // { status: "connected", service: "taog" }});Scan progress, duplicate groups, bit-rot detections, and heals join ready on this stream as the studio is wired up. Clients should ignore event types they do not recognize.
MCP · JSON-RPC 2.0
POST /mcp accepts one JSON-RPC 2.0 request per HTTP call and answers with application/json. Any agent or script that can POST JSON can use it.
| Method | Status | Result |
|---|---|---|
initialize | Live | protocolVersion 2024-11-05, serverInfo, and capabilities.tools. |
tools/list | Live | The registered tool catalog with JSON Schema inputs. |
tools/call | T8 | Executes a tool. Until T8 it answers -32601. |
initialize
$ curl -sS http://localhost:8115/mcp \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'{ "jsonrpc": "2.0", "id": 1, "result": { "protocolVersion": "2024-11-05", "serverInfo": { "name": "taog", "version": "0.1.0-alpha" }, "capabilities": { "tools": {} } }}tools/list
$ curl -sS http://localhost:8115/mcp \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'{ "jsonrpc": "2.0", "id": 2, "result": { "tools": [ { "name": "taog_search_files", "description": "Search indexed filenames, paths, OCR text, subtitles, and archive contents via SQLite FTS5.", "inputSchema": { "type": "object", "properties": { "query": { "type": "string" } }, "required": ["query"] } }, { "name": "taog_storage_growth", "description": "Query 24h, 7d, or 30d directory growth deltas across indexed hosts and NAS shares.", "inputSchema": { "type": "object", "properties": { "window": { "type": "string", "enum": ["24h", "7d", "30d"] } } } }, { "name": "taog_reclaimable_summary", "description": "Summarize reclaimable space from exact BLAKE3 duplicates, Merkle folder clones, and perceptual media matches.", "inputSchema": { "type": "object", "properties": {} } } ] }}Tool catalog
| Tool | Arguments | Status |
|---|---|---|
taog_search_files | query: string | Registered |
taog_storage_growth | window?: "24h" | "7d" | "30d" | Registered |
taog_reclaimable_summary | none | Registered |
taog_bitrot_status | status?: "open" | "healed" | "all" | T8 |
taog_storage_tiers | source_id?: integer | T8 |
Registered tools appear in tools/list today; executing them through tools/call ships with T8. Argument shapes for T8 tools may still change.
Errors
| Code | Message | When |
|---|---|---|
-32700 | parse error | The body is not valid JSON. HTTP 400, id is null. |
-32601 | method not found | Unknown or not-yet-implemented method. HTTP 200. |
From an agent
const res = await fetch("http://localhost:8115/mcp", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" }),}); const { result } = await res.json();console.log(result.tools.map((t) => t.name));Layers of protection
Taog is designed so that the destructive half of storage management is the hardest half to trigger by accident. Protection is layered from the kernel up — each layer holds even if the one above it fails.
- L1Read-only mountsKernelData mounted :ro cannot be written, full stop.Live
- L2Protected PathsIndex + plannerReference-only directories are never remediation targets.T8
- L3#keep-forever tagsIndex + plannerPinned files are excluded from every plan.T8
- L4Dry-run plansPlannerEvery action is previewed with exact ops and bytes first.T8
- L5Donor verificationSelf-healerHealing copies only bytes that verify on disk.Live
The protected_paths, tags, and file_tags tables already exist in the v0.1.0-alpha schema and /api/v1/stats reports protected_path_count; planner enforcement arrives with T8.
Protected Paths
T8A Protected Path is a reference-only directory. Files beneath it can be the keeper in a duplicate group — never the target. Every remediation plan is validated against protected_paths before a single filesystem call is made.
Good candidates: the canonical photo library, a backup target, and anything another tool manages — such as a media library hardlinked to a torrent client's seeding directory.
Dry-run remediation
T8Every action is expressed as a plan. Submit it with dry_run: true to receive the validated operation list and byte totals without touching disk, review it, then submit the same plan with dry_run: false.
{ "mode": "quarantine", "target_paths": ["/mnt/user/photos/dupes/IMG_0412 (1).CR3"], "dry_run": true}| Mode | Effect | Reversible |
|---|---|---|
quarantine | Moves the file into TAOG_QUARANTINE_DIR, preserving its relative path. | Yes — move it back |
hardlink | Replaces the duplicate with a hardlink to the keeper. Same filesystem only. | Content preserved |
symlink | Replaces the duplicate with a symlink to the keeper. | Content preserved |
delete | Unlinks the duplicate. | No |
fix_extension | Renames the file to the extension that matches its sniffed MIME type. | Yes — rename back |
heal_bitrot | Restores rotted bytes from a verified donor (see below). | Restores the original |
Bit-rot donor verification
LiveA scrub re-hashes each indexed file with streaming BLAKE3. A mismatch is recorded as bit-rot only when size and mtime match the index before, during, and after a complete read and the file was not swapped mid-read. Anything else — edited, replaced, written while hashing — counts as a legitimate change and waits for the next scan. Detections persist even if the scrub is cancelled.
The healing pipeline
- 01
Re-check the target
The event must still be open, the indexed digest must still equal the expected digest, and the file's size and mtime must still match the index. A file that was legitimately edited after detection is never overwritten (
ErrTargetChanged). - 02
Resolve paths defensively
Absolute paths, NUL bytes,
..segments, and symlinks that resolve outside the source root are refused, and the target must be a regular file (ErrUnsafePath). - 03
Retry the target first
If the target now hashes clean — the mismatch was a transient read fault — the event closes and nothing is copied.
- 04
Verify the donor on disk
Each duplicate candidate is re-hashed with BLAKE3 before use. Hardlinks of the target (same inode, therefore the same rotten bytes) are rejected, and a donor that fails to read or verify is skipped in favor of the next.
- 05
Stream into a temp file beside the target
Same directory, same filesystem — so the final rename is atomic. The bytes are hashed as they are written, and the temp file is verified again.
- 06
Restore metadata, rename, verify
The temp file receives the target's mode and mtime, atomically replaces it, and the result is hashed one final time before the event is marked healed.
Reverse proxy
Server-sent events need response buffering disabled, or updates arrive in delayed bursts. The 25-second keepalive keeps idle streams under typical 60-second proxy timeouts.
# SWAG / nginx: Taog API, live events, and MCP behind one hostnamelocation /api/ { proxy_pass http://taog-backend:8115;} location = /api/v1/events { proxy_pass http://taog-backend:8115; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_buffering off; # stream events as they happen proxy_cache off; proxy_read_timeout 1h; # keepalives arrive every 25 s} location = /mcp { proxy_pass http://taog-backend:8115;} location / { proxy_pass http://taog-frontend:3000;}When the studio and API share one public hostname, rebuild the studio with NEXT_PUBLIC_API_URL set to that hostname and pin TAOG_CORS_ORIGIN to it.
Troubleshooting
| Symptom | Fix |
|---|---|
| Backend exits on start with a database error | The container runs as the unprivileged taog user (UID 1000). If Docker created ./data as root, hand it over: sudo chown -R 1000:1000 ./data. |
| Studio shows BACKEND OFFLINE | Your browser cannot reach NEXT_PUBLIC_API_URL. See Browsing from another machine. |
| Health returns 503 degraded | The SQLite file is unreachable or locked. Check that TAOG_DB_PATH is on local disk. |
| New NAS shares are missing inside the container | The host path is not a shared mount. See Checking propagation. |
| Live events arrive in bursts | Disable proxy buffering for /api/v1/events. |
Build from source
$ cd backend$ CGO_ENABLED=0 go test ./...$ CGO_ENABLED=0 go run ./cmd/server$ cd frontend$ npm install$ npm run typecheck$ npm run devThe backend is pure Go (modernc.org/sqlite, lukechampine.com/blake3) and cross-compiles without a C toolchain. Issues and pull requests are welcome on GitHub.