- /berichte lists published reports; /berichte/<slug> renders a report: Markdown subset built as React
elements (no raw HTML), [[angabe:ID]] embeds the claim card under a seal (green 'Amtliche Daten' when a
source is official), [text](angabe:ID|bericht:slug|person:slug|org:slug) links inline, [[bericht:slug]]
embeds another report; a box says how many claims the text rests on; backlinks between reports.
- /berichte/verfassen (login at the proxy): own reports, editor with a picker that finds claims, reports and
persons and inserts their codes; draft / published / withdrawn; every save kept in report_revision.
- Claim pages show the embed code, 'use in a new report' and the reports citing the claim.
- API: GET /api/v1/reports, /reports/{slug} (references resolved like permalinks, merged claims follow the
survivor); POST/PUT for the web app with POLITRACK_AUTHOR_TOKEN on behalf of the proxy user. The web app
trusts Remote-User only with X-Politrack-Proxy = POLITRACK_PROXY_SECRET.
- Migration 0011 (report, report_revision, report_reference, app_user.display_name); docs: data model,
deployment (sign-in setup), design system, roadmap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.4 KiB
Deployment on Unraid
Prerequisites
- Unraid 6.12+ with the Docker Compose Manager plugin (Community Applications).
- An appdata share, for example
/mnt/user/appdata/politrack. - Network access from the server to PyPI/npm for the image builds (
files.pythonhosted.org,registry.npmjs.org) – see "Troubleshooting". - Optional: a reverse proxy (SWAG, Nginx Proxy Manager, Traefik or Caddy) and SSO (Authentik or Authelia) if the site is exposed; an Ollama container for semantic search.
Steps
-
Clone the repository onto the server (for example
/mnt/user/appdata/politrack/src) or add it as a stack in Compose Manager pointing at this folder. -
cp .env.example .envand set at least:DATA_DIR=/mnt/user/appdata/politrack– database (postgres/) and raw archive (raw/) live herePOSTGRES_PASSWORD,POLITRACK_READER_PASSWORDPOLITRACK_USER_AGENTwith a real contact address (publishers must be able to reach you)- optional:
POLITRACK_ADMIN_TOKEN,POLITRACK_OLLAMA_URL, API keys (YouTube, Meta Ad Library, X)
-
Build and start:
docker compose build docker compose up -dDocker creates
${DATA_DIR}/rawand${DATA_DIR}/logsas root, but the backend runs as a non-root user, and every fetch then fails with "Permission denied". Hand them over once after the firstup:chown -R "$(docker run --rm --entrypoint id politrack-backend -u):$(docker run --rm --entrypoint id politrack-backend -g)" "$DATA_DIR/raw" "$DATA_DIR/logs".migrateruns once (schema, seed data, source registry, job-queue tables), thenapi,web,mcpand three workers start:service queues what runs there worker-scrapescrape, social most adapters (hourly to daily) worker-bulkbulk large or slow downloads: procurement, RTR, ad libraries, EC meetings, GDELT worker-enrichenrich linking, events, legal detection, topics, corroboration, embeddings -
Initial load (otherwise the schedules pick everything up over the next day):
docker compose exec api politrack sources list # what exists, when it runs docker compose exec api politrack run parlament.persons # members first: other adapters resolve against them docker compose exec api politrack run wikidata.politicians docker compose exec api politrack run europarl.meps docker compose exec api politrack run parlament.items # votes etc. – the longest run (30-60 min) docker compose exec api politrack run config.social_accounts docker compose exec api politrack enrich -
Open
http://<unraid-ip>:3000(web),http://<unraid-ip>:8000/api/docs(API) andhttp://<unraid-ip>:8001/mcp(MCP).
Upgrading from the first version (v1): the schema was rewritten (0001_schema.sql). Start with a
fresh database: stop the stack, move ${DATA_DIR}/postgres away, docker compose up -d, re-run the
initial load. Nothing is lost that the sources can't provide again.
Scaling and separate deployments
- More throughput:
docker compose up -d --scale worker-scrape=3. Queueing locks ensure one adapter never runs twice at the same time; per-host throttling is per process, so keep one replica per queue if you are close to a publisher's rate limit. - Another machine (different egress IP, GPU): run the same image with
POLITRACK_DATABASE_URLpointing at this database andprocrastinate --app=politrack.worker.app worker --queues=<queues>. Mount a raw archive volume there too (or setPOLITRACK_RAW_DIRto shared storage).
Semantic search (optional)
docker compose --profile ai up -d ollama
docker compose exec ollama ollama pull bge-m3
# .env: POLITRACK_OLLAMA_URL=http://ollama:11434
docker compose up -d
bge-m3 runs fine on CPU for this data volume. With an NVIDIA GPU, add a device reservation
(deploy.resources.reservations.devices) to the ollama service.
Backups
- Database: the
backupservice dumps it every night at 02:30 UTC toBACKUP_DIR(default./data/backups; better a different share, e.g./mnt/user/backups/politrack) and keepsBACKUP_KEEP_DAYS(14) days. Each dump is recorded as a run ofbackup, so the status endpoint below alerts when backups stop. Restore withpg_restore -h localhost -p 5433 -U politrack -d politrack --clean <file>. For off-site copies, syncBACKUP_DIRelsewhere. - Raw archive (
${DATA_DIR}/raw): optional to back up – it saves refetching after parser fixes, and it can be pruned (find raw -mtime +365 -delete); missing blobs are simply refetched.
Exposing publicly
- Expose only
web(and optionallyapi) through the reverse proxy. Keepmcpand the DB port LAN- or VPN-only, or protect them with SSO or an API key at the proxy. - Read legal.md before going public (Impressum, privacy policy, §7b MedienG).
Reports and sign-in
Anyone can read published reports; writing (/berichte/verfassen…) needs a login at the reverse proxy. The proxy
authenticates (Authelia, Authentik …) and passes Remote-User, Remote-Name, Remote-Email and Remote-Groups
to the web container. The web app trusts these headers only when the request also carries
X-Politrack-Proxy: $POLITRACK_PROXY_SECRET, which only the proxy sets, so a request straight to the web port
can't pretend to be someone. The web app then calls the API's write endpoints with
Authorization: Bearer $POLITRACK_AUTHOR_TOKEN (read by both web and api from .env).
- Put
POLITRACK_AUTHOR_TOKENandPOLITRACK_PROXY_SECRET(random, e.g.openssl rand -hex 32) into.envanddocker compose up -d web api. - SWAG: in the site's
location /after the Authelia includes, addproxy_set_header X-Politrack-Proxy "<the secret>";and reload nginx. The SWAG Authelia include already sets theRemote-*headers (empty when nobody is signed in, which also overwrites forged ones). - Authelia: if the site bypasses the login on the LAN, add a rule before the bypass that requires a login for
the write paths, e.g.
Pages behind a bypass rule see nobody as signed in (no edit buttons there); the write pages always do.
- domain: 'politrack.example.org' resources: ['^/(en/)?berichte/verfassen([/?].*)?$'] policy: 'one_factor'
Members of POLITRACK_REPORT_EDITOR_GROUPS (default ["admins"]) may edit and withdraw any report. Every saved
version stays in report_revision.
Monitoring
docker compose exec api politrack status– recent runs with stats and errors (tablerun).GET /api/v1/admin/runswithAuthorization: Bearer $POLITRACK_ADMIN_TOKEN.- Fetch log:
SELECT adapter, status, count(*) FROM fetch_log WHERE fetched_at > now() - interval '1 day' GROUP BY 1, 2; - Job queue:
SELECT task_name, status, count(*) FROM procrastinate_jobs GROUP BY 1, 2; GET /api/v1/status/sourcesreturns HTTP 503 as soon as a scheduled source (or the backup) missed its last two slots, and lists every task with its last successful run: point an HTTP monitor (Uptime Kuma) at it./healthzonly checks that the API reaches the database.- The
watchdogtask (every 10 minutes) fails jobs of dead workers, closes abandoned runs and starts any scheduled source whose last slot was missed (Procrastinate skips slots that are more than ten minutes overdue). - Worker logs:
${DATA_DIR}/logs/worker-*.log(rotating), kept across redeploys;docker compose logsonly covers the current containers.
Troubleshooting
pip install / npm install fail during the build with TLS errors, while other sites work.
Something between the server and the internet blocks the package CDNs by host name (TLS SNI): typically
a DNS filter (Pi-hole/AdGuard, router "parental control"/"web protection"), a firewall with TLS
inspection, or antivirus web protection on the build machine. Check:
nslookup files.pythonhosted.org # resolves to a Fastly address, not 0.0.0.0 / your router?
curl -v https://pypi.org/simple/ -o /dev/null # works?
curl -v https://files.pythonhosted.org/ -o /dev/null
curl -v https://registry.npmjs.org/ -o /dev/null
If pypi.org works but files.pythonhosted.org / registry.npmjs.org fail during the TLS handshake, allow
these host names in the filter/firewall/AV (also *.pythonhosted.org, registry.yarnpkg.com if used). On
Windows, the System event log (source Schannel) and the AV's web-protection log show which component
reset the connection.