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.
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).
npm install
cp .env.local.example .env.local
# Add ANTHROPIC_API_KEY in .env.local
npm run devApp is then on http://localhost:3030.
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.
The demo script in docs/Plan.md §3 targets ~6–8 minutes on Mieter C (Hanau). Recommended flow:
- Start at
/— three cases as cards in GWH design. - Open Mieter C (Hanau, Korrekturabrechnung 2022 + Einwohnermeldeamt).
- Schreiben atomisieren → 3 atomic Einwendungen with ampel colours and
the cited sources extracted (incl.
BGH XV ZR 999/24and a verfristungs- argument citing§ 556 Abs. 3 BGB). - Zitate prüfen →
BGH XV ZR 999/24is flagged as halluziniert with a fundamental explanation (no XV. Zivilsenat at BGH);§ 556 Abs. 3 BGBis flagged as sinnverdreht because the tenant inverts the condition. - 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.
- Folgeschreiben simulieren → Stufe-3 follow-up is appended.
- Material-Issue prüfen → classified as
rhetorische_wiederholung, Empfehlung Schlussmitteilung (the Schlussmitteilung draft button gets an "Empfohlen" pill). - 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.
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
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.
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.
- Push this repo to GitHub.
- Import the repo into Vercel.
- Add
ANTHROPIC_API_KEYunder Project → Settings → Environment Variables (optionallyBASIC_AUTH_USER/BASIC_AUTH_PASSWORDto gate the production deployment — seeproxy.ts). - Deploy.
Netlify was the initial target, but its hard function-duration cap (26 s on Pro) killed the ~33 s
draft-responsecall even with SSE streaming. Vercel Pro handles it. See docs/HANDOVER.md for the full story.