Skip to content

Local development

Run the FastAPI backend and Vite frontend on your machine for UI and API work. Clone the repo first (git clone https://github.com/jm-connell/horde.git), then work from that checkout. This path does not require Docker, though you can still use Compose for a production-like stack (Install with Docker).

Trusted network

Even in dev the first visit creates an admin account. Do not expose the Vite or uvicorn ports beyond a trusted network.

Prerequisites

  • Python 3.14 with venv (the backend uses 3.14-only syntax; the Docker image and CI run 3.14)
  • Node.js 24 or newer, with npm (.nvmrc names the version CI uses)
  • Git (you need a clone of this repo)
  • curl (Linux/macOS helper scripts wait on /api/health)
  • FFmpeg (ffmpeg and ffprobe on PATH, or FFMPEG_BIN / FFPROBE_BIN) for downloads, thumbnails and imports; the UI and API start without it, but downloads fail with "ffmpeg is not installed"

On Fedora, something like sudo dnf install python3 nodejs npm curl ffmpeg covers the basics.

Linux / macOS

From the repo root:

./start.sh

start.sh execs scripts/dev.sh, which:

  1. Sets DOWNLOADS_DIR and DATA_DIR to ./downloads and ./data under the repo (creating them if needed)
  2. Creates .venv if missing and installs backend/requirements.txt when needed
  3. Installs backend/requirements-dev.txt (pytest, pytest-xdist, ruff, mypy, mkdocs-material) when it changed
  4. Builds the MkDocs wiki into backend/static/wiki/ when missing or when docs/ / mkdocs.yml changed (unless SKIP_WIKI=1)
  5. Runs npm install in frontend/ when node_modules is missing
  6. Starts uvicorn with --reload on port 8080
  7. Starts Vite (npm run dev, usually 5173) once the backend health check passes

Open the Vite URL printed in the terminal (typically http://localhost:5173). Vite proxies /api, /docs, /redoc, /openapi.json, and /wiki to http://127.0.0.1:8080. The proxy keeps the browser's Host header (changeOrigin: false): the backend's CSRF check compares Origin with Host, so a proxy that rewrites Host gets every POST, PATCH and DELETE rejected with 403 "Origin does not match this server".

Wiki in local development

./start.sh builds the wiki by default so Settings → Documentation and /wiki/ work locally (wiki_available on /api/health). Skip with:

SKIP_WIKI=1 ./start.sh

Manual rebuild (same output path Docker uses):

# from repo root, with the venv activated (or after start.sh installed requirements-dev)
mkdocs build -d backend/static/wiki --strict

Then open /wiki/ through Vite (or http://127.0.0.1:8080/wiki/ directly). Restart is not required for static files, but Vite needs a restart if you just changed vite.config.ts proxies.

Windows

dev.bat

That launches scripts/dev.ps1, which mirrors the same flow (repo-local downloads / data, uvicorn on 8080, then npm run dev).

Proxy target is 127.0.0.1

The Vite config proxies /api to 127.0.0.1:8080, not localhost. On Windows, localhost often resolves to IPv6 ::1 while uvicorn binds IPv4, which shows up as instant proxy 500s. Prefer the helper scripts so both sides stay aligned.

Manual start (two terminals)

Backend:

cd backend
python3 -m venv ../.venv
source ../.venv/bin/activate   # Windows: ..\.venv\Scripts\activate
pip install -r requirements.txt
DOWNLOADS_DIR=../downloads DATA_DIR=../data uvicorn app.main:app --reload --port 8080

Frontend:

cd frontend
npm install
npm run dev

Start the backend before the frontend so the proxy has something to talk to.

Process Default URL
Backend (uvicorn) http://127.0.0.1:8080
Frontend (Vite) http://localhost:5173
API via Vite /api → 127.0.0.1:8080
Wiki / Swagger via Vite /wiki, /docs → same backend
Swagger http://127.0.0.1:8080/docs

Data directories in dev

Env Default under repo Role
DOWNLOADS_DIR ./downloads Media tree (Channel/Year/Title [id].ext)
DATA_DIR ./data SQLite DB, thumbnails, sprites

Scanner import extensions: .mp4, .mkv, .webm, .m4v, .mov. Fallback poll interval: SCAN_INTERVAL_SEC (default 60), same as Docker.

Tests

Run scripts/check.sh before every commit: it runs all lint, format, type, test, build, and wiki gates (see Quality gates). See Automated testing for the intended layers (pytest API tests, Vitest, Playwright, MkDocs, Docker image), local commands, and how GitHub Actions runs the same jobs on every push, pull request, and manual Run workflow.

Backend (from backend/, with the repo venv activated):

pip install -r requirements.txt -r requirements-dev.txt
pytest -n auto

Frontend:

cd frontend
npm install
npm test
npx playwright install chromium
npm run e2e

CI is .github/workflows/ci.yml.

Sync frontend into the backend static tree

Production Docker serves a built SPA from the backend. After frontend changes you want baked into a container image (or a static-only run):

cd frontend
npm run build:sync

That runs npm run build then copies frontend/dist into backend/static via scripts/sync-static.mjs. backend/static is gitignored: it is a local build artifact, never committed (the Docker image builds its own copy).

Retake the screenshots

The README and docs screenshots come from a real library. Point the capture script at any running Horde (your own server works best) from frontend/:

npm run screenshots -- http://192.168.1.20:8686

A browser window opens: sign in there, then for each shot the script opens the page and says what to set up, and Enter saves it to docs/assets/screenshots/<name>.webp (s skips it). Name shots after the URL to retake only those, e.g. ... player ask. The first run needs Playwright's browser: npx playwright install chromium.

Optional: Docker-shaped local stack

You can still use Compose on a laptop:

cp .env.example .env
# point DOWNLOADS_PATH / DATA_PATH at local dirs; set PUID/PGID
docker compose -f docker-compose.yml -f docker-compose.build.yml up --build -d

UI: http://127.0.0.1:8686 (host 8686 → container 8080). bgutil-pot starts automatically; Ollama needs docker compose --profile ai up -d.