Initial commit from Create Next App

This commit is contained in:
colinislit
2025-11-09 14:21:31 +01:00
commit 223161463f
21 changed files with 5121 additions and 0 deletions

41
.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

36
README.md Normal file
View File

@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.

BIN
app/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

26
app/globals.css Normal file
View File

@@ -0,0 +1,26 @@
@import "tailwindcss";
:root {
--background: #ffffff;
--foreground: #171717;
}
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-mono: var(--font-geist-mono);
}
@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}
body {
background: var(--background);
color: var(--foreground);
font-family: Arial, Helvetica, sans-serif;
}

34
app/layout.tsx Normal file
View File

@@ -0,0 +1,34 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
);
}

65
app/page.tsx Normal file
View File

@@ -0,0 +1,65 @@
import Image from "next/image";
export default function Home() {
return (
<div className="flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black">
<main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
<Image
className="dark:invert"
src="/next.svg"
alt="Next.js logo"
width={100}
height={20}
priority
/>
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
To get started, edit the page.tsx file.
</h1>
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
Looking for a starting point or more instructions? Head over to{" "}
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Templates
</a>{" "}
or the{" "}
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="font-medium text-zinc-950 dark:text-zinc-50"
>
Learning
</a>{" "}
center.
</p>
</div>
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
<a
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
<Image
className="dark:invert"
src="/vercel.svg"
alt="Vercel logomark"
width={16}
height={16}
/>
Deploy Now
</a>
<a
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
</div>
</main>
</div>
);
}

View File

@@ -0,0 +1,74 @@
## APItoegang MiniECD
Laatste update: 20251109 • Versie: 0.2 (MVP)
### Overzicht
De MiniECD API biedt serverside endpoints in Next.js voor AIfunctionaliteit (Claude / Anthropic). In de MVP is één endpoint beschikbaar.
### Base URL
- Ontwikkel (lokaal): `http://localhost:3000`
- Productie: n.t.b. (Vercel)
### Authenticatie
- **MVP**: geen externe clientauth; endpoints dienen alleen in trusted context gebruikt te worden (serverside calls of demoomgeving).
- Claude AI authenticatie verloopt serverside via Anthropic API key.
### Headers
- `Content-Type: application/json`
### Endpoints
#### POST `/api/ai/summarize`
- **Doel**: vat NL intaketekst samen in puntsgewijze bullets (max 6), neutraal en feitelijk.
- **Request body**
```json
{
"text": "string (1..20000)",
"language": "string (optioneel, default: nl)"
}
```
- **Voorbeeld (PowerShell)**
```powershell
Invoke-RestMethod -Uri http://localhost:3000/api/ai/summarize -Method POST -Body (@{ text = "Korte intake tekst" } | ConvertTo-Json) -ContentType "application/json"
```
- **Voorbeeld (curl)**
```bash
curl -X POST http://localhost:3000/api/ai/summarize \
-H "Content-Type: application/json" \
-d '{"text":"Korte intake tekst"}'
```
- **Response (200)**
```json
{
"summary": "- Bullet 1\n- Bullet 2\n..."
}
```
- **Fouten**
- 400: ongeldige body (validatie faalt)
- 500: Claude AI fout of configuratie ontbreekt
### Omgevingsvariabelen
- **Claude AI**
- `ANTHROPIC_API_KEY` (bv. `sk-ant-...`) — vereist voor alle AI-endpoints
- **Optioneel**
- `ANTHROPIC_MODEL` (default `claude-3-5-sonnet-20241022`)
Voorbeeld in `.env.local` (lokaal): zie `/.env.example`.
### Implementatiedetails
- Server helper: `src/lib/server/claude.ts` initialiseert Claude client met API key.
- Endpoint: `src/app/api/ai/summarize/route.ts` (Next.js Route Handler met Zodvalidatie, Claude API call).
### Beveiliging (MVP)
- Houd `ANTHROPIC_API_KEY` uit de client; uitsluitend serverside gebruiken.
- Gebruik Vercel Environment Variables in productie.
### Roadmap (volgende endpoints)
- `POST /api/ai/readability` herschrijf naar B1niveau.
- `POST /api/ai/extract` extracteer categorie/severity uit intake.
- `POST /api/ai/generate-plan` genereer behandelplan (Doelen, Interventies, etc.).
### Changelog
- 0.2 (20251109): Migratie naar Next.js + Claude AI (Anthropic); update van base URL naar :3000.
- 0.1 (20250902): Eerste versie met `summarize` endpoint en envrichtlijnen.

138
docs/prd-mini-ecd.md Normal file
View File

@@ -0,0 +1,138 @@
# 📄 Product Requirements Document (PRD)
**Product:** Mini-ECD Prototype
**Doel:** Demo tijdens AI-inspiratiesessie bij PinkRoccade GGZ
**Versie:** 1.1 (MVP met DSM-light simulatie)
**Datum:** aug 2025
---
## 1. Doelstelling
Een werkend **mini-ECD prototype** waarmee we tijdens de workshop de kernprocessen uit de GGZ kunnen demonstreren: **intake → probleemclassificatie → behandelplan**.
Focus ligt op het **zichtbaar maken van AI-waarde** (samenvatten, structureren, plan genereren) in een herkenbare workflow.
---
## 2. Doelgroep
* **Product Owners & Managers** → inzicht in AI als hulpmiddel.
* **Developers** → inspiratie voor AI-integratie.
* **Consultants / GGZ-professionals** → herkenbare ECD-structuur.
---
## 3. Kernfunctionaliteiten (MVP)
1. **Cliënt inschrijven**
* Velden: Voornaam, Achternaam, Geboortedatum.
* Automatische ClientID.
* Verschijnt in Cliëntenlijst.
2. **Overzicht (Cliëntdashboard)**
* Tegels:
* Basisgegevens: ClientID, Naam, Geboortedatum.
* Intake: verkorte weergave laatste intakeverslag.
* Probleemprofiel: DSM-light categorie + severity-badge.
* Behandelplan: doelen in bullets + status.
* Afspraken: laatste afspraak + eerstvolgende 3 afspraken.
* Configuratie: gebruiker kan via een instellingen-knop kiezen welke tegels zichtbaar zijn.
3. **Intake-verslag maken**
* Rich text editor.
* Tags: Intake / Evaluatie / Plan.
* Opslaan & koppelen aan cliënt.
4. **Probleemprofiel (DSM-light simulatie)**
* Dropdown categorieën (simulatie DSM-5 hoofdcategorieën):
* Stemming / Depressieve klachten
* Angststoornissen
* Gedrags- en impulsstoornissen
* Middelengebruik / Verslaving
* Cognitieve stoornissen
* Context / Psychosociaal
* Severity: Laag / Middel / Hoog.
* Vrij veld: opmerkingen.
* **AI-suggestie:** intake analyseren → voorstel categorie + severity.
5. **AI-ondersteuning bij verslag**
* Knoppen:
* *Samenvatten* (in bullets).
* *Verbeter leesbaarheid* (B1-niveau).
* *Extract problemen* (AI vult categorie/severity suggestie in).
6. **AI-voorstel behandelplan**
* Genereert secties: Doelen, Interventies, Frequentie/Duur, Meetmomenten.
* Gebruiker kan bewerken of accepteren.
7. **Mini-agenda (optioneel, stretch)**
* Afspraak plannen gekoppeld aan cliënt.
8. **Rapport export (stretch)**
* PDF: cliëntgegevens + intake + probleemprofiel + behandelplan.
---
## 4. Demo-flows
1. **Nieuwe cliënt → Intake maken → AI Samenvatten.**
2. **Probleemprofiel genereren → AI suggestie → severity kiezen.**
3. **Behandelplan genereren → Accept → Opslaan.**
*(Optioneel: afspraak plannen en rapport exporteren.)*
---
## 5. Niet in scope
* Autorisaties en rollenbeheer.
* Externe koppelingen (Teams, TOPdesk, etc.).
* Volledige DSM-5 implementatie (alleen simulatie).
* Dit prototype is geen gevalideerd medisch hulpmiddel en dient enkel voor demonstratiedoeleinden.
---
## 6. Technische randvoorwaarden
* **Framework:** Next.js
* **Styling:** Tailwind
* **Database:** Supabase
* **AI:** Claude AI
* **Hosting:** Vercel (EU).
---
## 7. Succescriteria
* Demo duurt max. 10 minuten.
* Herkenbare flow (intake → profiel → plan).
* AI-output direct zichtbaar en bewerkbaar.
* Minimaal 1 deelnemer kan live een cliënt toevoegen.
* Deelnemers aan de workshop begrijpen de toegevoegde waarde van AI in het ECD-proces.
---
## 8. Risicos
* **Privacy:** uitsluitend fictieve data.
* **AI-output inconsistent:** prompts vooraf testen.
* **Scope creep:** strak houden bij intake → plan.
---
## 9. Roadmap (post-demo)
* Autorisaties en auditlog.
* Trendanalyse (stemming/voortgang).
* Integratie met PinkRoccade modules.
* Compliance en security uitbreiden.

390
docs/to-mini-ecd.md Normal file
View File

@@ -0,0 +1,390 @@
# ⚙️ Technisch Ontwerp — MiniECD (MVP)
**Datum:** aug 2025
**Scope:** MVP voor demo tijdens AIinspiratiesessie (≤10 min)
**Bronnen:** PRD (v1.1), UX/UIspecificatie, FO (MVP)
---
## 0) TL;DR Stack & Keuzes
* **Framework**: **Next.js** (App Router)
* **UI**: **Tailwind CSS** (v4; fallback v3.4 bij frictie) + **lucide-react** iconen; lichte componentlaag (shadcn/ui of eigen + headless)
* **Editor**: **TipTap** (ProseMirror) met StarterKit + BasicNodes
* **Auth & Data**: **Supabase** (PostgreSQL + Auth + Storage)
* **AI**: **Claude** (Anthropic) via API
* **Hosting**: **Vercel** (Next.js)
* **PDF (stretch)**: serverside HTML→PDF via **Chromium (playwright/puppeteer)** of cloudfunctie.
* **Test**: **Vitest** (unit) + **Playwright** (e2e).
> ✅ Past bij MVP: minimale libs, AIcalls serverside, EUdataregio (Supabase EU), TipTap voor rijke tekst.
---
## 1) Architectuur
### 1.1 Overzicht
```
Browser (UI)
└─ Next.js (App Router)
├─ Supabase (PostgreSQL + Auth + Storage)
├─ Claude AI (Anthropic)
└─ (Stretch) PDF service (Chromium in serverless)
```
* **Serverside AIcalls**: keys blijven op de server; UI krijgt alleen resultaten.
* **Dataflow (kern)**: Intake (TipTap) → AIsamenvat → AIextract → Probleemprofiel → AIplan → Plan (concept → publiceer).
### 1.2 Routing & lagen
* **Pages** (App Router): `/clients`, `/clients/[id]` (tabs: overzicht/intakes/profiel/plan).
* **API** (Next.js Route Handlers): `/api/clients`, `/api/intakes`, `/api/problem-profile`, `/api/treatment-plan`, `/api/ai/*`.
### 1.3 State
De state van de applicatie wordt beheerd met **React Context API** + **Zustand** (lichtgewicht state library). Dit is eenvoudig genoeg voor de MVP-scope. State wordt georganiseerd in `src/lib/stores/` of `src/contexts/`.
* **`clientStore.ts` (Zustand)**: Beheert de state gerelateerd aan cliëntdata.
* `selectedClientId: string | null`: Houdt het ID van de actieve cliënt bij. Dit is de centrale spil van de applicatie-staat.
* `clients: Client[]`: De lijst van alle cliënten voor de overzichtspagina.
* `currentClientDossier: Dossier | null`: Reageert op wijzigingen in `selectedClientId`. Wanneer de ID verandert, haalt de store automatisch de volledige dossierinhoud (intakes, profiel, plan) op via Supabase.
* **`uiStore.ts` (Zustand)**: Beheert globale UI-state.
* `toasts: ToastMessage[]`: Een array met actieve 'toast'-notificaties die globaal getoond kunnen worden.
* **Dataflow Patroon**:
1. De UI update `selectedClientId` via Zustand action.
2. De store triggert een Supabase query om dossierdata op te halen.
3. React componenten die subscribed zijn via `useClientStore()` updaten automatisch.
* **Alternatief (MVP)**: Voor kleinere state kan ook React Context + `useState` volstaan zonder externe library.
Dit patroon zorgt voor een efficiënte, voorspelbare en reactieve dataflow door de hele applicatie.
---
## 2) Datamodel (Supabase / PostgreSQL)
### 2.1 Entiteiten
* **clients** — basisgegevens
* **intake\_notes** — TipTap JSON + afgeleide velden
* **problem\_profiles** — DSMlight categorie + severity
* **treatment\_plans** — JSONB plan (doelen/interventies/frequentie/meetmomenten), versie/status
* **ai\_events** — prompts/completions (telemetrie, debugging)
* *(Stretch)* **appointments**, **reports**
### 2.2 Relaties (PostgreSQL)
```
clients (id UUID PRIMARY KEY)
├── intake_notes (client_id → clients.id, FK)
├── problem_profiles (client_id → clients.id, FK)
└── treatment_plans (client_id → clients.id, FK)
ai_events (id UUID PRIMARY KEY, client_id + note_id als optionele FKs)
```
**Row Level Security (RLS)**: Alle tables hebben RLS policies voor auth.users().
### 2.3 Tables (PostgreSQL schema)
> **NB**: Enums als TEXT met CHECK constraints; plan inhoud als JSONB voor flexibiliteit in MVP.
```typescript
// PostgreSQL Tables Schema (TypeScript types)
// clients table
interface Client {
id: string; // UUID (auto-generated)
first_name: string;
last_name: string;
birth_date: string; // DATE (ISO 8601: YYYY-MM-DD)
created_at: string; // TIMESTAMPTZ
updated_at: string; // TIMESTAMPTZ
}
// intake_notes table
interface IntakeNote {
id: string; // UUID
client_id: string; // FK → clients.id
title?: string;
tag: 'Intake' | 'Evaluatie' | 'Plan'; // TEXT with CHECK
content_json: object; // JSONB (ProseMirror document)
content_text?: string; // TEXT (for full-text search)
author?: string; // FK → auth.users.id (optioneel)
created_at: string; // TIMESTAMPTZ
updated_at: string; // TIMESTAMPTZ
}
// problem_profiles table
interface ProblemProfile {
id: string; // UUID
client_id: string; // FK → clients.id
category: 'stemming_depressie' | 'angst' | 'gedrag_impuls' |
'middelen_gebruik' | 'cognitief' | 'context_psychosociaal'; // TEXT with CHECK
severity: 'laag' | 'middel' | 'hoog'; // TEXT with CHECK
remarks?: string; // TEXT
source_note_id?: string; // FK → intake_notes.id
created_at: string; // TIMESTAMPTZ
updated_at: string; // TIMESTAMPTZ
}
// treatment_plans table
interface TreatmentPlan {
id: string; // UUID
client_id: string; // FK → clients.id
version: number; // INTEGER
status: 'concept' | 'gepubliceerd'; // TEXT with CHECK
plan: { // JSONB
doelen: string[];
interventies: string[];
frequentie: string;
meetmomenten: string[];
};
created_by?: string; // FK → auth.users.id
created_at: string; // TIMESTAMPTZ
published_at?: string; // TIMESTAMPTZ
updated_at: string; // TIMESTAMPTZ
}
// ai_events table (telemetrie)
interface AiEvent {
id: string; // UUID
kind: 'summarize' | 'readability' | 'extract' | 'plan'; // TEXT with CHECK
client_id?: string; // FK → clients.id (nullable)
note_id?: string; // FK → intake_notes.id (nullable)
request: object; // JSONB
response: object; // JSONB
duration_ms: number; // INTEGER
created_at: string; // TIMESTAMPTZ
}
```
**SQL voorbeelden** voor table creation beschikbaar in `/supabase/migrations/`.
**Supabase TypeScript types** kunnen automatisch gegenereerd worden via `supabase gen types typescript`.
### 2.4 Row Level Security (basis)
Voor demo kunnen RLS policies simpel zijn: **alle rows zichtbaar voor authenticated users**. In productie: per organisatie/therapeut scheiden met `org_id` kolom.
```sql
-- Demo RLS policies (apply to all tables)
-- Enable RLS
ALTER TABLE clients ENABLE ROW LEVEL SECURITY;
ALTER TABLE intake_notes ENABLE ROW LEVEL SECURITY;
ALTER TABLE problem_profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE treatment_plans ENABLE ROW LEVEL SECURITY;
ALTER TABLE ai_events ENABLE ROW LEVEL SECURITY;
-- Authenticated users kunnen alles lezen/schrijven (demo only!)
CREATE POLICY "Allow all for authenticated users" ON clients
FOR ALL USING (auth.uid() IS NOT NULL);
CREATE POLICY "Allow all for authenticated users" ON intake_notes
FOR ALL USING (auth.uid() IS NOT NULL);
CREATE POLICY "Allow all for authenticated users" ON problem_profiles
FOR ALL USING (auth.uid() IS NOT NULL);
CREATE POLICY "Allow all for authenticated users" ON treatment_plans
FOR ALL USING (auth.uid() IS NOT NULL);
CREATE POLICY "Allow all for authenticated users" ON ai_events
FOR ALL USING (auth.uid() IS NOT NULL);
```
**Productie**: Voeg `org_id` toe en filter op `auth.jwt() ->> 'org_id'`.
---
## 3) API & Endpoints (Next.js Route Handlers)
### 3.1 CRUD
* `POST /api/clients` — create
* `GET /api/clients?query=` — list/search
* `GET /api/clients/:id` — detail
* `PATCH /api/clients/:id` — update
* `POST /api/intakes` — create intake
* `GET /api/intakes?clientId=` — list
* `GET /api/intakes/:id` — detail
* `PATCH /api/intakes/:id` — update
* `POST /api/problem-profile` — create/update current
* `GET /api/problem-profile?clientId=` — latest
* `POST /api/treatment-plan` — create (concept)
* `PATCH /api/treatment-plan/:id/publish` — publish vN
### 3.2 AIacties
* `POST /api/ai/summarize` — TipTap JSON → bullets
* `POST /api/ai/readability` — TipTap JSON → B1
* `POST /api/ai/extract` — TipTap JSON → {category, severity, rationale}
* `POST /api/ai/generate-plan` — {noteId | profile} → plan JSON
**Patroon**: alle AIendpoints valideren input, roepen Claude API aan serverside, loggen in `ai_events`, geven **preview** terug. UI beslist *Insert/Apply*.
---
## 4) AIintegratie (Claude / Anthropic)
### 4.1 Model & API
* **Model**: Claude 3.5 Sonnet (of nieuwere versie) via Anthropic API.
* **Regio**: Anthropic API is globally distributed; data blijft binnen EU waar mogelijk.
* **SDK**: `@anthropic-ai/sdk` (officiële Node.js SDK).
### 4.2 Prompttemplates (schets)
* **Summarize**: *“Vat het onderstaande intakeverslag samen in 58 bullets. Schrijf in NL, klinisch neutraal, zonder PII.”*
* **Readability (B1)**: *“Herschrijf leesbaar op B1niveau. Behoud medische betekenis, vermijd jargon waar mogelijk.”*
* **Extract**: *"Haal uit de tekst: DSMlight categorie (uit 6), severity (laag/middel/hoog), met korte toelichting en quotebronnen."*
* **Plan**: *"Genereer behandelplan (Doelen, Interventies, Frequentie/Duur, Meetmomenten) op basis van intake/profiel. SMARTformuleer doelen."*
**Parameters (startwaarden)**:
- `model`: "claude-3-5-sonnet-20241022" (of nieuwer)
- `temperature`: 0.3 (deterministischer)
- `max_tokens`: passend per taak (samenvat 8001200, plan 16002400)
**Veiligheid**: PII-verwijdering in post-processing (heuristiek); gebruik system prompt voor extra context guards.
---
## 5) Frontend implementatie
### 5.1 UIskelet
* **Layout**: Topbar (cliëntcontext) + LeftNav (dossier) + Main (detail) + Toast area.
* **Componenten**: Button, Card, Input, Select, Tabs, Badge, Dialog, Drawer, Toast, Tooltip, Breadcrumb.
### 5.2 TipTap
* **Nodes**: paragraph, heading, bold/italic/underline, bullet/ordered list, blockquote, code (optioneel).
* **Opslag**: `content_json` (ProseMirror doc).
* **AIRightrail**: tabs: Samenvatten, B1, Extract; acties **Preview → Insert**.
### 5.4 Haalbaarheidsonderzoek: AI Source Highlighting
Een belangrijke UX-vereiste is het visueel aanduiden (highlighten) van de bronzinnen in de intaketekst die de AI heeft gebruikt voor een suggestie. Dit is technisch goed haalbaar.
**Aanpak:**
1. **Backend API Aanpassing**: Het AI-endpoint (bv. `/api/ai/extract`) moet niet alleen de suggestie retourneren, maar ook een array van de exacte bronzinnen (`sourceSentences: string[]`).
2. **Frontend TipTap Implementatie**:
* De frontend gebruikt de [TipTap Decorations API](https://tiptap.dev/api/decorations) om de highlighting te realiseren. Decorations passen styling toe zonder de onderliggende content te wijzigen.
* Bij ontvangst van de `sourceSentences` doorzoekt de frontend het TipTap-document naar de posities (`from`, `to`) van deze zinnen.
* Voor elke gevonden positie wordt een `Decoration.inline(from, to, { class: 'ai-source-highlight' })` aangemaakt.
3. **Styling**: Een simpele CSS-klasse `.ai-source-highlight` (bv. met een lichtgele achtergrond) wordt toegevoegd aan de globale stylesheet.
4. **Lifecycle**: De highlights worden gewist zodra de gebruiker de suggestie accepteert, negeert, of een nieuwe AI-actie initieert.
**Conclusie**: De aanpak is robuust en de complexiteit is laag tot gemiddeld. Het wordt meegenomen in de PoC voor de TipTap-editor.
### 5.3 Toetsenbord & UX
* `Ctrl/Cmd+S` opslaan, `Ctrl/Cmd+K` zoek, `Ctrl/Cmd+N` nieuw verslag.
* Leegstaten met CTAs; skeletons bij laden; nonblocking spinners bij AI.
---
## 6) Security, Privacy & Compliance (MVPproof)
* **Data**: uitsluitend fictieve demodata; geen echte PII.
* **Regio's**: EUhosting (Supabase EU: Frankfurt/London; Claude API global).
* **Secret handling**: API keys via Vercel Envs; nooit in client bundelen.
* **RLS Policies**: minimaal aan; authenticated users krijgen toegang (demo).
* **Audit (lichtgewicht)**: `ai_events` + timestamps op alle tables.
* **CORS**: beperken tot demodomain.
---
## 7) Deployment & Environments
* **Dev**: `.env.local` met Supabase keys + Claude API key
* **Preview/Prod**: Vercel project → `VERCEL_ENV` gates; RLS policies via Supabase migrations.
* **Supabase**: EU-regio (Frankfurt of London), schema deploy via `supabase db push` of migrations.
### 7.1 Environment variables (voorbeeld)
```bash
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://xyz.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... # Public anon key (frontend safe)
SUPABASE_SERVICE_ROLE_KEY=eyJ... # Service role key (server only!)
# Claude AI
ANTHROPIC_API_KEY=sk-ant-... # Claude API key (server only!)
# App
NEXT_PUBLIC_APP_URL=https://mini-ecd.example
NODE_ENV=production
```
**Security**:
- `SUPABASE_SERVICE_ROLE_KEY` en `ANTHROPIC_API_KEY` alleen server-side gebruiken
- Vercel Environment Variables voor productie
- Gebruik `.env.local` voor lokale ontwikkeling (niet in git!)
---
## 8) Setup stappen (korte gids)
1. **Repo & deps**: init Next.js (App Router) + Tailwind + TipTap + Supabase client + Anthropic SDK.
2. **Supabase**: project aanmaken (EU-regio) → Tables uit §2.3 aanmaken via migrations → RLS policies activeren.
3. **Env**: Vercel + lokale `.env.local` vullen (Supabase keys + Claude API key).
4. **Endpoints**: CRUD + AIroutes implementeren als Next.js Route Handlers (serverside).
5. **Screens**: Clients list/detail, Intake editor + AIrail, Profiel form, Plan cards.
6. **Smoke test**: Flow A/B/C endtoend met mock data.
7. **(Optioneel)** PDF export & afspraken tab.
---
## 9) Test & Kwaliteit
* **Unit**: parsers, validators, AIresponse mappers (Zod schemas).
* **E2E (Playwright)**: Flow A/B/C met seeded data.
* **Prompt tests**: vaste inputs → snapshot op kernvelden (niet volledige tekst).
---
## 10) Bekende beperkingen & risico's
* **TipTap** content search: extra index/afgeleide `content_text` nodig voor snelle zoek (PostgreSQL full-text search).
* **Claude API rate limits**: monitor gebruik; overweeg caching voor veelvoorkomende prompts.
* **Serverless PDF**: kan coldstart of memory issues geven → overweeg queue/edge function.
* **RLS Policies (demo)**: simplistisch; voor productie per organisatie/rol modelleren met `org_id`.
---
## 11) Wat ontbrak nog in je stack (aanvullingen)
* **Tailwind CSS** (UIbasis) en **iconen (lucide-react)**.
* **Auth**: Supabase Auth (magic link, email/password, of OAuth).
* **Validatie**: **Zod** voor request/response schemas.
* **Logging**: lichte audit via `ai_events` table + Next.js middleware.
* **Testing**: Vitest/Playwright.
* **PDF (stretch)**: keuze voor renderer (Puppeteer/Playwright).
* **Typesafety**: Supabase auto-generated types via `supabase gen types typescript`.
---
## 12) Roadmap na demo
* Rollen & rechten, multitenant (org\_id) + stricte RLS policies.
* Templates per zorgpad (verslag/plan).
* Trendanalyse (meetmomenten) + grafieken.
* Integraties (PinkRoccade modules), exportprofielen.
* Real-time collaboratie via Supabase Realtime (optioneel).
---

194
docs/ux-stylesheet.md Normal file
View File

@@ -0,0 +1,194 @@
# 🎨 Kleur Stylesheet MiniECD (v2, UXgeoptimaliseerd)
> Doel: consistente, toegankelijke kleuren met **lage cognitieve belasting**. Accentpalet teruggebracht tot **3 modules** (Afspraken, Medicatie/Herinneringen, Lab/Resultaten). Inclusief duidelijke states en contrastrichtlijnen.
---
## 🌐 Basiskleuren
* **Appachtergrond**: `#F8FAFC`
* **Oppervlak (kaarten/modals)**: `#FFFFFF`
* **Suboppervlak** (sekundair paneel/rightrail): `#F1F5F9`
* **Tekst primair**: `#0F172A`
* **Tekst secundair**: `#475569`
* **Borders/Dividers**: `#E2E8F0`
**WCAG tip:** tekst op witte of zachte pastelfondsen ≥ `#0F172A` / `#1E293B` voor AAcontrast.
---
## 🔹 Merk & Primaire UI
* **Primary / Brand**: `#3B82F6`
* Hover: `#2563EB`
* Active: `#1D4ED8`
* Subtle bg (chips, emptystates): `#EFF6FF`
* OnPrimary text/icon: `#FFFFFF`
* **Neutral CTA (secundair/terug)**: `#334155`
* Hover: `#1F2937`
* OnNeutral: `#FFFFFF`
---
## 📊 Moduleaccenten (gereduceerd)
Gebruik **max. drie** accentfamilies. Pastel voor kaarten + een verzadigd accent voor iconen/teksten.
1. **Afspraken**
* Card bg: `#E8F8EF`
* Accent (icon/label): `#16A34A`
* Border: `#CDECDC`
2. **Medicatie / Herinneringen**
* Card bg: `#FEF6DC`
* Accent: `#F59E0B`
* Border: `#F6E7B6`
3. **Lab / Resultaten**
* Card bg: `#FFEBDC`
* Accent: `#F97316`
* Border: `#FFD2B8`
> **Toegankelijkheid:** tekst op pastelkaarten in **donkergrijs `#0F172A`**. Accentkleur enkel voor iconen/badges/kleine headings.
---
## ⚠️ Status & Feedback
* **Success**: `#16A34A`
* **Warning**: `#EAB308`
* **Error**: `#DC2626`
* **Info**: `#3B82F6`
**Subtle backgrounds**
* Success subtle: `#ECFDF5`
* Warning subtle: `#FEFCE8`
* Error subtle: `#FEF2F2`
* Info subtle: `#EFF6FF`
**Toasts/alerts**
* Tekst: `#0F172A`
* Icon: statuskleur
* Border: statuskleur op 30% (bijv. mix met wit)
---
## 🏷️ Badges & Labels (Severity DSMlight)
* **Laag**: bg `#E5E7EB`, text `#374151`
* **Middel**: bg `#FEF3C7`, text `#92400E`
* **Hoog**: bg `#FEE2E2`, text `#991B1B`
---
## ✍️ Formulieren & Invoervelden
* **Input bg**: `#FFFFFF`
* **Input text**: `#0F172A`
* **Placeholder**: `#94A3B8`
* **Border default**: `#CBD5E1`
* **Border hover**: `#94A3B8`
* **Focus**: 2px ring `#3B82F6` + 1px inset border `#2563EB`
* **Disabled**: bg `#F1F5F9`, text `#94A3B8`, border `#E2E8F0`
* **Invalid**: border `#DC2626`, helptext `#B91C1C`
**Select/Dropdown**
* Menu bg: `#FFFFFF`
* Hover option: `#F1F5F9`
* Active/selected: left bar `#3B82F6`
---
## 🧩 Componentstates (Buttons/Links/Cards)
**Primary button**
* Default: bg `#3B82F6`, text `#FFFFFF`
* Hover: bg `#2563EB`
* Active: bg `#1D4ED8`
* Disabled: bg `#BFDBFE`, text `#FFFFFF` @ 70%
**Secondary button**
* Default: bg `#334155`, text `#FFFFFF`
* Hover: bg `#1F2937`
* Disabled: bg `#CBD5E1`, text `#FFFFFF` @ 60%
**Ghost button**
* Text: `#334155`; hover bg: `#F1F5F9`
**Links**
* Default: `#2563EB`
* Hover/Focus: underline + `#1D4ED8`
* Visited: `#4F46E5`
**Cards**
* Default: bg `#FFFFFF`, border `#E2E8F0`, shadow sm
* Hoverable variant: shadow md + translateY(1px)
---
## 🗺️ Navigatie
* **Sidebar item**
* Default text: `#334155`
* Active: text `#0F172A`, bg `#E2E8F0`, left accent bar `#3B82F6`
* Disabled: text `#94A3B8`
* **Topbar**
* Bg: `#FFFFFF`, borderbottom: `#E2E8F0`
---
## 🌫️ Elevation & Focus
* **Shadows**
* sm: `0 1px 2px rgba(15,23,42,0.06)`
* md: `0 2px 6px rgba(15,23,42,0.08)`
* lg: `0 8px 20px rgba(15,23,42,0.10)`
* **Focus ring (universeel)**: 2px `#3B82F6` buiten het element + 1px contrastborder.
---
## ♿ Toegankelijkheidsrichtlijnen
* Minimale contrastverhouding **AA**:
* Bodytekst op wit ≥ 4.5:1 (gebruik `#0F172A`/`#1E293B`)
* Tekst op gekleurde knoppen altijd **wit** (`#FFFFFF`) en check contrast.
* Gebruik niet alleen kleur: combineer status met **icoon**, **label** of **shape**.
* Focus is altijd zichtbaar (geen `outline: none`).
---
## 🔧 Semantische tokens (aliasing)
Gebruik semantische namen in code i.p.v. ruwe HEXwaarden:
* `--color-bg`, `--color-surface`, `--color-text`, `--color-border`
* `--color-brand`, `--color-brand-hover`, `--color-info`, `--color-success`, `--color-warning`, `--color-error`
* `--color-module-appointments`, `--color-module-meds`, `--color-module-labs`
---
## 📌 Notities
* Accentpalet bewust klein gehouden → minder visuele ruis, sneller scannen.
* Kaarten tonen **accent** alleen in icoon/badge of kleine titel; content blijft donker op licht voor leesbaarheid.
* Voor donker thema kunnen bovenstaande waarden gespiegeld worden met lichtere teksten en donkerder oppervlakken.

18
eslint.config.mjs Normal file
View File

@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);
export default eslintConfig;

7
next.config.ts Normal file
View File

@@ -0,0 +1,7 @@
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
};
export default nextConfig;

26
package.json Normal file
View File

@@ -0,0 +1,26 @@
{
"name": "15-mini-epd-prototype",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev --webpack",
"build": "next build --webpack",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"react": "19.2.0",
"react-dom": "19.2.0",
"next": "16.0.1"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@tailwindcss/postcss": "^4",
"tailwindcss": "^4",
"eslint": "^9",
"eslint-config-next": "16.0.1"
}
}

4026
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

7
postcss.config.mjs Normal file
View File

@@ -0,0 +1,7 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;

1
public/file.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

After

Width:  |  Height:  |  Size: 391 B

1
public/globe.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

1
public/next.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

1
public/vercel.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 128 B

1
public/window.svg Normal file
View File

@@ -0,0 +1 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

After

Width:  |  Height:  |  Size: 385 B

34
tsconfig.json Normal file
View File

@@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts",
"**/*.mts"
],
"exclude": ["node_modules"]
}