Files
politics-tracking/backend/politrack/config.py
T
simonandClaude Opus 5.5 9f0e2fc115 reports: user articles that embed claims under a database seal and link each other
- /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>
2026-11-20 10:19:50 +01:00

54 lines
2.1 KiB
Python

from functools import lru_cache
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""All settings come from environment variables prefixed POLITRACK_ (see .env.example)."""
model_config = SettingsConfigDict(env_prefix="POLITRACK_", env_file=".env", extra="ignore")
database_url: str = "postgresql://politrack:politrack@localhost:5432/politrack"
reader_password: str | None = None
# Crawling identity & politeness
user_agent: str = "PolitrackBot/0.2 (+https://github.com/your-user/politics-tracking; contact: admin@example.org)"
min_request_interval: float = 2.0
http_timeout: float = 60.0
# Raw archive (fetched responses, gzip, content-addressed)
raw_dir: Path = Path("/data/raw")
config_dir: Path = Path(__file__).resolve().parent.parent / "config"
# Parliament: legislative periods (GP) ingested in detail
parlament_periods: list[str] = ["XXVII", "XXVIII"]
# Embeddings via Ollama (optional)
ollama_url: str | None = None
embedding_model: str = "bge-m3"
# Optional credentials for sources that require them (adapters skip themselves when unset)
youtube_api_key: str | None = None
meta_ad_library_token: str | None = None
x_bearer_token: str | None = None
justiz_hvd_api_key: str | None = None # JustizOnline Firmenbuch HVD web service (firmenbuch.* adapters)
# Bulk sources: how far back to backfill on the first run
procurement_since: str = "2024-01-01"
ad_archive_since: str = "2023-01-01"
api_cors_origins: list[str] = ["http://localhost:3000"]
# Bearer token for moderation/admin endpoints. Empty = disabled (use the CLI).
admin_token: str | None = None
# Shared secret of the web app for writing reports on behalf of a signed-in user. Empty = reports are read-only.
author_token: str | None = None
# Members of these login groups (Authelia Remote-Groups) may edit and withdraw any report.
report_editor_groups: list[str] = ["admins"]
@lru_cache
def get_settings() -> Settings:
return Settings()