diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..07a6a36 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,104 @@ +# 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 + +```bash +# 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 + +```bash +# 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 diff --git a/PRD/WetGit-PRD-v1.0.docx b/PRD/WetGit-PRD-v1.0.docx new file mode 100644 index 0000000..9636782 Binary files /dev/null and b/PRD/WetGit-PRD-v1.0.docx differ diff --git a/PRD/WetGit-PRD-v1.0.pdf b/PRD/WetGit-PRD-v1.0.pdf new file mode 100644 index 0000000..51b2cf9 Binary files /dev/null and b/PRD/WetGit-PRD-v1.0.pdf differ