Skip to content

About

Demo-Prototyp: Sachbearbeiter-Werkzeug, das Mieter-Widersprüche gegen Betriebskostenabrechnungen atomisiert, gegen eine Rechts-Wissensbasis prüft (inkl. Halluzinations-Detektion) und quellengestützte Antwort-Entwürfe vorschlägt.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

BKO-Widerspruchs-Assistent

Demo prototype for the GWH Wohnungsgesellschaft mbH Hessen. A caseworker tool that atomizes incoming tenant objections against operating-cost statements, checks them against a German legal knowledge base (including hallucination detection on cited rulings), and proposes source-backed response drafts — orchestrated by the human, not by the system.

Status: Functional demo prototype. All four conceptual cornerstones (Atomization, Citation/Hallucination Check, Material-Issue Filter, Human-in-the-Lead drafting with per-sentence source duty) are live, tested against Claude Opus 4.7, and were shown in the client demo on 2026-05-20. This is a demo prototype, not a production system — see docs/HANDOVER.md for the production-readiness gaps.

See docs/Plan.md for the full build plan and demo script.

Tech

Next.js 16 (App Router, Turbopack) · React 19 · TypeScript · Tailwind CSS v4 · shadcn/ui · Anthropic SDK (claude-opus-4-7, fallback claude-sonnet-4-6).

Local setup

npm install
cp .env.local.example .env.local
# Add ANTHROPIC_API_KEY in .env.local
npm run dev

App is then on http://localhost:3030.

Why port 3030 and the env -u prefix?

npm run dev runs env -u ANTHROPIC_API_KEY -u ANTHROPIC_BASE_URL next dev -p 3030. The unset is needed because Claude Code (or another parent shell) often exposes an empty ANTHROPIC_API_KEY to its child processes; Next.js does not override pre-existing env vars from system environment with values from .env.local. Unsetting in the wrapper lets .env.local be the source of truth. Port 3030 avoids collisions with other local dev servers on 3000.

Demo walkthrough

The demo script in docs/Plan.md §3 targets ~6–8 minutes on Mieter C (Hanau). Recommended flow:

  1. Start at / — three cases as cards in GWH design.
  2. Open Mieter C (Hanau, Korrekturabrechnung 2022 + Einwohnermeldeamt).
  3. Schreiben atomisieren → 3 atomic Einwendungen with ampel colours and the cited sources extracted (incl. BGH XV ZR 999/24 and a verfristungs- argument citing § 556 Abs. 3 BGB).
  4. Zitate prüfen → BGH XV ZR 999/24 is flagged as halluziniert with a fundamental explanation (no XV. Zivilsenat at BGH); § 556 Abs. 3 BGB is flagged as sinnverdreht because the tenant inverts the condition.
  5. Antwort-Entwurf Sachlich-kurz → 9 sentences, every one with at least one clickable source pill. Clicking a pill opens the source's full text. Hallucination is handled with a sachlicher Hinweis ("Wir bitten um Bekanntgabe der Fundstelle"), never triumph.
  6. Folgeschreiben simulieren → Stufe-3 follow-up is appended.
  7. Material-Issue prüfen → classified as rhetorische_wiederholung, Empfehlung Schlussmitteilung (the Schlussmitteilung draft button gets an "Empfohlen" pill).
  8. Schlussmitteilung erzeugen → Wiederholungsverweis-Textbaustein wird eingesetzt, Verweis auf BGH VIII ZR 209/15.

Use Demo zurücksetzen on / to wipe the client-side session state (sessionStorage) between runs and start fresh.

Project structure

app/                          # Next.js App Router
  api/
    atomize/                  # POST: letter → Einwendungen + Marker
    check-citations/          # POST: validate cited Normen + Urteile
    material-issue/           # POST: classify follow-up letter
    draft-response/           # POST: per-sentence source-backed draft
    inject-followup/          # POST: demo-only, appends Stufe-3 letter
    reset/                    # POST: wipe runtime store
  case/[id]/                  # case detail page (server component)
components/
  case/                       # case-view components
    CaseView.tsx              # client orchestrator (state + handlers)
    OriginalSchreibenView.tsx # left column
    EinwendungCard.tsx        # ampel + cards
    OrchestrationsKonsole.tsx # right column action panel
    MaterialIssuePanel.tsx    # follow-up analysis panel
    MarkerBanner.tsx          # mineko/conny/VZ banner over letter
    AntwortEntwurfView.tsx    # modal: draft with clickable sources
    QuelleSheet.tsx           # side panel: source's full text
  ui/                         # shadcn primitives (button)
  DemoResetButton.tsx
lib/
  anthropic.ts                # SDK client + model constants
  case.ts                     # demo-case loader + in-memory store
  knowledge.ts                # KB loader + lookup helpers
  format.ts                   # German date/EUR formatters
  types.ts                    # domain types (Case, Einwendung, …)
prompts/                      # markdown system prompts per API
data/
  knowledge_base/             # BetrKV, BGB, case law, text modules, markers
  demo_cases/                 # three Mieterschreiben + Stufe-3 follow-up
docs/
  Plan.md                     # the master build plan
  STYLE_GUIDE.md              # GWH visual design tokens
  code-style-guide.md         # Koerting code conventions

API latencies (Opus 4.7)

Measured during build, end-to-end (network + Anthropic):

Endpoint Latency Tokens (in / out)
POST /api/atomize 20–25 s ~5,000 / ~1,500
POST /api/check-citations 10–14 s ~7,000 / ~1,200
POST /api/material-issue 8–10 s ~3,000 / ~600
POST /api/draft-response 25–35 s ~18,000 / ~2,200
POST /api/inject-followup <100 ms —
POST /api/reset <50 ms —

max_tokens for draft-response is set to 8192 because 4096 was sometimes cut off mid-JSON.

Deployment

Deployed on Vercel (Pro), auto-deploying on push to main. vercel.json sets a per-route maxDuration (60 s for the four AI routes, 10 s for the demo helpers) — the long draft-response/atomize calls need that headroom.

  1. Push this repo to GitHub.
  2. Import the repo into Vercel.
  3. Add ANTHROPIC_API_KEY under Project → Settings → Environment Variables (optionally BASIC_AUTH_USER / BASIC_AUTH_PASSWORD to gate the production deployment — see proxy.ts).
  4. Deploy.

Netlify was the initial target, but its hard function-duration cap (26 s on Pro) killed the ~33 s draft-response call even with SSE streaming. Vercel Pro handles it. See docs/HANDOVER.md for the full story.

About

Demo-Prototyp: Sachbearbeiter-Werkzeug, das Mieter-Widersprüche gegen Betriebskostenabrechnungen atomisiert, gegen eine Rechts-Wissensbasis prüft (inkl. Halluzinations-Detektion) und quellengestützte Antwort-Entwürfe vorschlägt.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages