meta/CLAUDE.md
Coornhert 2b0f858b46 docs: PRD v1.0 + CLAUDE.md projectinstructies
- WetGit-PRD-v1.0 in docx en pdf (Product Requirements Document)
- CLAUDE.md met stack/endpoints/deploy/troubleshooting voor
  AI-assistenten die met de repo werken
2026-04-21 20:58:45 +02:00

3.8 KiB

WetGIT — Nederlandse wetgeving als code

Project

Elke Nederlandse wet als Markdown-bestand, elke wijziging als Git-commit. Data van officiële BWB (Basis Wettenbestand) XML bronnen.

Stack

  • Python 3.12+ (pyproject.toml, setuptools)
  • FastAPI — API + web frontend (module: wetgit.api.app:app)
  • Meilisearch v1.12 — full-text search
  • Qdrant v1.13 — semantic search (Mistral embeddings)
  • Forgejo — self-hosted git (git.wetgit.nl)
  • Redis — Celery broker
  • Nginx — reverse proxy (3 vhosts: wetgit.nl, api.wetgit.nl, git.wetgit.nl)
  • Codeberg — public mirror (codeberg.org/wetgit, daily push)

API Endpoints

GET /health                                    → status, version, count
GET /api/v1/regelingen                         → lijst (filter: ?type=wet&status=geldend)
GET /api/v1/regelingen/{bwb_id}                → metadata
GET /api/v1/regelingen/{bwb_id}/tekst          → volledige Markdown
GET /api/v1/regelingen/{bwb_id}/artikelen      → artikellijst
GET /api/v1/regelingen/{bwb_id}/artikelen/{nr} → artikel detail
GET /api/v1/regelingen/{bwb_id}/versies        → historische versies (git log)
GET /api/v1/regelingen/{bwb_id}/diff           → diff (?van=DATE&tot=DATE)
GET /api/v1/regelingen/{bwb_id}/domeinen       → compliance-domein classificatie
GET /api/v1/regelingen/{bwb_id}/referenties    → cross-referenties
GET /api/v1/zoeken                             → search (?q=term&mode=keyword|semantic|hybrid)
GET /api/v1/domeinen                           → lijst van compliance-domeinen
GET /api/v1/feed.xml                           → Atom feed van wijzigingen
GET /api/docs                                  → Swagger UI

Rate limiting: 60 req/min default, 30 req/min voor zoeken (slowapi).

Deployment

# Full deploy
ansible-playbook ansible/site.yml

# Selective
ansible-playbook ansible/site.yml --tags app      # code + deps + services
ansible-playbook ansible/site.yml --tags docker    # Docker stack
ansible-playbook ansible/site.yml --tags nginx     # nginx vhosts + SSL
ansible-playbook ansible/site.yml --tags forgejo   # Forgejo + Redis + cron

# Dry-run
ansible-playbook ansible/site.yml --check --diff

Server: dt-prod-01 via Tailscale (100.98.29.89), user: deploy. Vault password: ansible/.vault_pass

Important: Data lives at /opt/wetgit/app/rijk/ (env var WETGIT_GIT_REPOS_DIR=/opt/wetgit/app).

Shared server rules

This server is shared with dt-platform. Do NOT:

  • Modify global nginx.conf or system packages
  • Use ports 8001 (dt-chatbot) or 8200 (grimoire)
  • Touch /opt/dt-chatbot, /opt/grimoire, /opt/dt-skills-portal

Development

# Enter nix shell (provides Python + dependencies)
nix develop

# Run tests
pytest

# Run locally
uvicorn wetgit.api.app:app --reload

# Lint
ruff check src/
black --check src/

Key directories

src/wetgit/          # Application code
  api/               # FastAPI routes, search, models
  web/               # Jinja2 templates + static
  pipeline/          # BWB parser, SRU client, sync, indexer
  ai/                # Summaries, semantic search, alerts, domains, crossref
  cli/               # CLI tool
  tasks.py           # Celery app (sync, reindex, alerts)
ansible/             # Deployment playbooks
  roles/             # wetgit-forgejo, wetgit-app, wetgit-nginx
  group_vars/wetgit/ # main.yml (vars), vault.yml (secrets)
PRD/                 # Product Requirements Document

Troubleshooting

  • Port 8002 bezet na deploy: ssh deploy@100.98.29.89 "sudo fuser -k 8002/tcp && sudo systemctl restart wetgit"
  • Meilisearch crasht: Check image version — v1.12 data is incompatibel met v1.13
  • Ansible check-mode faalt op wetgit-web.conf: Verwacht — file wordt niet echt geschreven in check-mode