GWÖ-Antragsprüfer: Automatische Gemeinwohl-Bilanzierung von Parlamentsanträgen nach der GWÖ-Matrix 2.0
Go to file
Dotty Dotter f1867d463c Bundesland filter & transparency: stringent split + visible source (#8)
Brings the Bundesland-Dropdown from a cosmetic header widget to a real
filter that propagates through every layer (Listing, internal search,
statistics, party/tag filters, upload mode), and at the same time makes
the source parliament visible in every place where assessments from
multiple bundesländer can be mixed.

Backend
- database.get_all_assessments(bundesland=None) — new optional filter,
  "ALL" treated as None.
- database.search_assessments — bug fix: previous `if bundesland:`
  branch incorrectly added a `WHERE bundesland='ALL'` clause; now
  guarded with `bundesland and bundesland != "ALL"`.
- main.list_assessments — accepts ?bundesland= query param, includes the
  bundesland field in the response so the frontend can render badges.
- main.get_single_assessment — also includes bundesland in the response
  so the detail header can show the source parlament.
- main.search_landtag — early HTTP 400 when bundesland is missing or
  "ALL"; the live Landtag adapter cannot serve a synthetic Bundesweit
  request.
- main.index() and main.list_bundeslaender — synthetic "🌍 Bundesweit"
  entry prepended to the bundesländer list (kept out of bundeslaender.py
  on purpose — ALL is not a real state). Both endpoints additionally
  expose a parlament_names map so the frontend can render the source
  parliament without an extra round-trip.

Report (PDF + HTML)
- generate_html_report / generate_pdf_report — new optional bundesland
  parameter. When set, the report header carries the parliament name
  ("Landtag von Sachsen-Anhalt", "Landtag Nordrhein-Westfalen", …)
  beside the title. Three call sites updated: run_analysis,
  run_drucksache_analysis, download_assessment_pdf.

Frontend (templates/index.html)
- Header dropdown gets the synthetic ALL entry as first option;
  initial currentBundesland is now 'ALL' (was 'NRW').
- localStorage persistence: changeBundesland writes, DOMContentLoaded
  reads and validates against the visible options.
- changeBundesland resets the score / party / tag filter state, syncs
  the upload-mode bundesland select, disables the Landtag-Suche button
  + tooltip when ALL, and toggles a data-mode attribute on
  .list-content (used by CSS to show/hide the per-item bundesland
  badge).
- loadAssessments now sends ?bundesland=… so the API does the actual
  filtering. updateStats renders an additional per-bundesland average
  block (Ø NRW: x · Ø LSA: y) when in ALL mode and the loaded list
  spans more than one bundesland.
- renderList prepends a small "bl-badge" beside the Drucksachen-Nummer.
  Hidden in single-bundesland mode via CSS selector to avoid clutter.
- showDetail header now shows the parliament name as its own line
  (.detail-parlament).
- searchLandtag has an early-out alert if currentBundesland === 'ALL',
  saving a network round-trip.
- Upload-Mode bundesland select now starts with a "— Bundesland wählen
  —" placeholder (no auto-default), and startAnalysis validates that a
  concrete bundesland was chosen.

CSS
- .bl-badge plus the .list-content[data-mode="single"] hide rule.
- .detail-parlament for the detail header line.
- .header-parlament for the PDF report header line.

Resolves #8.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 23:00:39 +02:00
app Bundesland filter & transparency: stringent split + visible source (#8) 2026-04-07 23:00:39 +02:00
.dockerignore Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
.env.example Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
.gitignore Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
.tarignore Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
docker-compose.yml Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
Dockerfile Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
LICENSE Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
README.md Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00
requirements.txt Initial commit: GWÖ-Antragsprüfer v1.0 2026-03-28 22:30:24 +01:00

GWÖ-Antragsprüfer

Automatische Gemeinwohl-Bilanzierung von Parlamentsanträgen nach der GWÖ-Matrix 2.0 für Gemeinden

Python FastAPI License

🎯 Was ist das?

Der GWÖ-Antragsprüfer analysiert Anträge aus Landesparlamenten (aktuell NRW) und bewertet sie nach den Kriterien der Gemeinwohl-Ökonomie (GWÖ):

  • GWÖ-Score (0-10): Wie gut entspricht der Antrag den GWÖ-Werten?
  • Matrix-Zuordnung: Welche Felder der GWÖ-Matrix werden adressiert?
  • Programmtreue: Passt der Antrag zu Wahl- und Parteiprogrammen?
  • Verbesserungsvorschläge: Konkrete Textänderungen mit GWÖ-Begründung

Features

  • 🔍 Landtag-Suche: Direkte Anbindung an OPAL (NRW Parlamentsdokumentation)
  • 📊 GWÖ-Matrix-Visualisierung: 5×5-Tabelle mit Bewertungssymbolen
  • 🏷️ Tag-Wolke: Filter nach Themen mit Multi-Select
  • 🎯 Partei-Filter: Durchschnittswerte pro Fraktion
  • 📄 PDF-Export: Professionelle Berichte im GWÖ-Design
  • 🔒 Security: CSP, CORS, Rate Limiting

🚀 Schnellstart

Voraussetzungen

  • Python 3.12+
  • Docker & Docker Compose
  • DashScope API-Key (Qwen LLM)

Installation

# Repository klonen
git clone https://github.com/tobiasroedel/gwoe-antragspruefer.git
cd gwoe-antragspruefer

# Environment-Variablen
cp .env.example .env
# DASHSCOPE_API_KEY eintragen

# Mit Docker starten
docker compose up -d

# Oder lokal entwickeln
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Die App läuft auf http://localhost:8000

📁 Projektstruktur

webapp/
├── app/
│   ├── main.py           # FastAPI-Endpoints
│   ├── analyzer.py       # LLM-Analyse-Logik
│   ├── database.py       # SQLite-Persistenz
│   ├── models.py         # Pydantic-Modelle
│   ├── parlamente.py     # Landtag-Adapter (OPAL)
│   ├── report.py         # PDF-Generierung
│   ├── config.py         # Settings
│   ├── kontext/          # GWÖ-Matrix, Wahlprogramme
│   ├── templates/        # Jinja2-HTML
│   └── static/           # CSS, JS, Assets
├── data/                 # SQLite-DBs (Volume)
├── reports/              # Generierte PDFs (Volume)
├── docker-compose.yml
├── Dockerfile
└── requirements.txt

🔧 Konfiguration

Environment-Variablen

Variable Beschreibung Default
DASHSCOPE_API_KEY Alibaba DashScope API-Key (required)
LLM_MODEL_DEFAULT Standard-Modell qwen-plus-latest
LLM_MODEL_PREMIUM Premium-Modell qwen-max

Unterstützte Bundesländer

Code Name Status
NRW Nordrhein-Westfalen Aktiv
BY Bayern 🔜 Geplant
BW Baden-Württemberg 🔜 Geplant

📊 API-Endpoints

Methode Pfad Beschreibung
GET / Web-UI
GET /api/assessments Alle Bewertungen
GET /api/assessment?drucksache=18/12345 Einzelne Bewertung
POST /api/analyze-drucksache Neue Analyse starten
GET /api/search?q=Klima Interne Suche
GET /api/search-landtag?q=Klima Landtag-Suche
GET /api/assessment/pdf?drucksache=18/12345 PDF-Download

🧠 GWÖ-Prompt (v5)

Der Analyse-Prompt basiert auf:

  • GWÖ-Matrix 2.0 für Gemeinden (Arbeitsbuch)
  • ECOnGOOD Corporate Design Manual 2024
  • Wahlprogramme der NRW-Landtagsparteien 2022

Ausgabe-Format:

  • GWÖ-Score mit Matrix-Feldern und Symbolen (++/+/○//)
  • Wahlprogramm- und Parteiprogrammtreue
  • Verbesserungsvorschläge im Redline-Format (Original → Vorschlag → Begründung)
  • Themen-Tags für Kategorisierung

🛠️ Entwicklung

# Tests ausführen
pytest

# Linting
ruff check app/

# Type-Checking
mypy app/

📝 Lizenz

MIT License - siehe LICENSE

🙏 Credits


Entwickelt von Tobias Rödel · tobiasroedel.de