This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
breakpilot-pwa/BREAKPILOT_CONSENT_MANAGEMENT_PLAN.md
Benjamin Admin 21a844cb8a fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.

This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).

Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 09:51:32 +01:00

25 KiB

BreakPilot Consent Management System - Projektplan

Executive Summary

Dieses Dokument beschreibt den Plan zur Entwicklung eines vollständigen Consent Management Systems (CMS) für BreakPilot. Das System wird komplett neu entwickelt und ersetzt das bestehende Policy Vault System, das Bugs enthält und nicht optimal funktioniert.


Technologie-Entscheidung: Warum welche Sprache?

Backend-Optionen im Vergleich

Kriterium Rust Go Python (FastAPI) TypeScript (NestJS)
Performance Exzellent Sehr gut Gut Gut
Memory Safety Garantiert GC GC GC
Entwicklungsgeschwindigkeit Langsam Mittel Schnell Schnell
Lernkurve Steil Flach Flach Mittel
Ecosystem für Web Wachsend Sehr gut Exzellent Exzellent
Integration mit BreakPilot Neu Neu Bereits vorhanden Möglich
Team-Erfahrung ? ? Vorhanden Möglich

Empfehlung: Python (FastAPI) oder Go

Option A: Python mit FastAPI (Empfohlen für schnelle Integration)

Vorteile:

  • Bereits im BreakPilot-Projekt verwendet
  • Schnelle Entwicklung
  • Exzellente Dokumentation (automatisch generiert)
  • Einfache Integration mit bestehendem Code
  • Type Hints für bessere Code-Qualität
  • Async/Await Support

Nachteile:

  • Langsamer als Rust/Go bei hoher Last
  • GIL-Einschränkungen bei CPU-intensiven Tasks

Option B: Go (Empfohlen für Microservice-Architektur)

Vorteile:

  • Extrem schnell und effizient
  • Exzellent für Microservices
  • Einfache Deployment (Single Binary)
  • Gute Concurrency
  • Statische Typisierung

Nachteile:

  • Neuer Tech-Stack im Projekt
  • Getrennte Codebasis von BreakPilot

Option C: Rust (Für maximale Performance & Sicherheit)

Vorteile:

  • Höchste Performance
  • Memory Safety ohne GC
  • Exzellente Sicherheit
  • WebAssembly-Support

Nachteile:

  • Sehr steile Lernkurve
  • Längere Entwicklungszeit (2-3x)
  • Kleineres Web-Ecosystem
  • Komplexere Fehlerbehandlung

Finale Empfehlung

Für BreakPilot empfehle ich: Go (Golang)

Begründung:

  1. Unabhängiger Microservice - Das CMS sollte als eigenständiger Service laufen
  2. Performance - Consent-Checks müssen schnell sein (bei jedem API-Call)
  3. Einfaches Deployment - Single Binary, ideal für Container
  4. Gute Balance - Schneller als Python, einfacher als Rust
  5. Zukunftssicher - Moderne Sprache mit wachsendem Ecosystem

Systemarchitektur

┌─────────────────────────────────────────────────────────────────────────┐
│                        BreakPilot Ecosystem                             │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│  ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐    │
│  │ BreakPilot      │    │ Consent Admin   │    │ BreakPilot      │    │
│  │ Studio (Web)    │    │ Dashboard       │    │ Mobile Apps     │    │
│  │ (Python/HTML)   │    │ (Vue.js/React)  │    │ (iOS/Android)   │    │
│  └────────┬────────┘    └────────┬────────┘    └────────┬────────┘    │
│           │                      │                      │              │
│           └──────────────────────┼──────────────────────┘              │
│                                  │                                      │
│                                  ▼                                      │
│                    ┌─────────────────────────┐                         │
│                    │   API Gateway / Proxy   │                         │
│                    └────────────┬────────────┘                         │
│                                 │                                       │
│           ┌─────────────────────┼─────────────────────┐                │
│           │                     │                     │                │
│           ▼                     ▼                     ▼                │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐        │
│  │ BreakPilot API  │  │ Consent Service │  │ Auth Service    │        │
│  │ (Python/FastAPI)│  │ (Go)            │  │ (Go)            │        │
│  └────────┬────────┘  └────────┬────────┘  └────────┬────────┘        │
│           │                    │                    │                  │
│           └────────────────────┼────────────────────┘                  │
│                                │                                       │
│                                ▼                                       │
│                    ┌─────────────────────────┐                         │
│                    │    PostgreSQL           │                         │
│                    │    (Shared Database)    │                         │
│                    └─────────────────────────┘                         │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

Projektphasen

Phase 1: Grundlagen & Datenbank (Woche 1-2)

Ziel: Datenbank-Schema und Basis-Services

1.1 Datenbank-Design

  • Users-Tabelle (Integration mit BreakPilot Auth)
  • Legal Documents (AGB, Datenschutz, Community Guidelines, etc.)
  • Document Versions (Versionierung mit Freigabe-Workflow)
  • User Consents (Welcher User hat wann was zugestimmt)
  • Cookie Categories (Notwendig, Funktional, Marketing, Analytics)
  • Cookie Consents (Granulare Cookie-Zustimmungen)
  • Audit Log (DSGVO-konforme Protokollierung)

1.2 Go Backend Setup

  • Projekt-Struktur mit Clean Architecture
  • Database Layer (sqlx oder GORM)
  • Migration System
  • Config Management
  • Logging & Error Handling

Ziel: Kern-Funktionalität für Consent-Management

2.1 Document Management API

  • CRUD für Legal Documents
  • Versionierung mit Diff-Tracking
  • Draft/Published/Archived Status
  • Mehrsprachigkeit (DE, EN, etc.)
  • User Consent erstellen/abrufen
  • Consent History pro User
  • Bulk-Consent für mehrere Dokumente
  • Consent Withdrawal (Widerruf)
  • Cookie-Kategorien verwalten
  • Granulare Cookie-Einstellungen
  • Consent-Banner Konfiguration

Phase 3: Admin Dashboard (Woche 5-6)

Ziel: Web-Interface für Administratoren

3.1 Admin Frontend (Vue.js oder React)

  • Login/Auth (Integration mit BreakPilot)
  • Dashboard mit Statistiken
  • Document Editor (Rich Text)
  • Version Management UI
  • User Consent Übersicht
  • Cookie Management UI

3.2 Freigabe-Workflow

  • Draft → Review → Approved → Published
  • Benachrichtigungen bei neuen Versionen
  • Rollback-Funktion

Phase 4: BreakPilot Integration (Woche 7-8)

Ziel: Integration in BreakPilot Studio

4.1 User-facing Features

  • "Legal" Button in Einstellungen
  • Consent-Historie anzeigen
  • Cookie-Präferenzen ändern
  • Datenauskunft anfordern (DSGVO Art. 15)
  • Cookie-Consent-Modal beim ersten Besuch
  • Granulare Auswahl der Kategorien
  • "Alle akzeptieren" / "Nur notwendige"
  • Persistente Speicherung
  • Automatische Prüfung bei API-Calls
  • Blocking bei fehlender Zustimmung
  • Marketing-Opt-out respektieren

Phase 5: Data Subject Rights (Woche 9-10)

Ziel: DSGVO-Compliance Features

5.1 Datenauskunft (Art. 15 DSGVO)

  • API für "Welche Daten haben wir?"
  • Export als JSON/PDF
  • Automatisierte Bereitstellung

5.2 Datenlöschung (Art. 17 DSGVO)

  • "Recht auf Vergessenwerden"
  • Anonymisierung statt Löschung (wo nötig)
  • Audit Trail für Löschungen

5.3 Datenportabilität (Art. 20 DSGVO)

  • Export in maschinenlesbarem Format
  • Download-Funktion im Frontend

Phase 6: Testing & Security (Woche 11-12)

Ziel: Absicherung und Qualität

6.1 Testing

  • Unit Tests (>80% Coverage)
  • Integration Tests
  • E2E Tests für kritische Flows
  • Performance Tests

6.2 Security

  • Security Audit
  • Penetration Testing
  • Rate Limiting
  • Input Validation
  • SQL Injection Prevention
  • XSS Protection

Datenbank-Schema (Entwurf)

-- Benutzer (Integration mit BreakPilot)
CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    external_id VARCHAR(255) UNIQUE, -- BreakPilot User ID
    email VARCHAR(255) UNIQUE NOT NULL,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Rechtliche Dokumente
CREATE TABLE legal_documents (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    type VARCHAR(50) NOT NULL, -- 'terms', 'privacy', 'cookies', 'community'
    name VARCHAR(255) NOT NULL,
    description TEXT,
    is_mandatory BOOLEAN DEFAULT true,
    is_active BOOLEAN DEFAULT true,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Dokumentversionen
CREATE TABLE document_versions (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    document_id UUID REFERENCES legal_documents(id) ON DELETE CASCADE,
    version VARCHAR(20) NOT NULL, -- Semver: 1.0.0, 1.1.0, etc.
    language VARCHAR(5) DEFAULT 'de', -- ISO 639-1
    title VARCHAR(255) NOT NULL,
    content TEXT NOT NULL, -- HTML oder Markdown
    summary TEXT, -- Kurze Zusammenfassung der Änderungen
    status VARCHAR(20) DEFAULT 'draft', -- draft, review, approved, published, archived
    published_at TIMESTAMPTZ,
    created_by UUID REFERENCES users(id),
    approved_by UUID REFERENCES users(id),
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    UNIQUE(document_id, version, language)
);

-- Benutzer-Zustimmungen
CREATE TABLE user_consents (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID REFERENCES users(id) ON DELETE CASCADE,
    document_version_id UUID REFERENCES document_versions(id),
    consented BOOLEAN NOT NULL,
    ip_address INET,
    user_agent TEXT,
    consented_at TIMESTAMPTZ DEFAULT NOW(),
    withdrawn_at TIMESTAMPTZ,
    UNIQUE(user_id, document_version_id)
);

-- Cookie-Kategorien
CREATE TABLE cookie_categories (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(100) NOT NULL, -- 'necessary', 'functional', 'analytics', 'marketing'
    display_name_de VARCHAR(255) NOT NULL,
    display_name_en VARCHAR(255),
    description_de TEXT,
    description_en TEXT,
    is_mandatory BOOLEAN DEFAULT false,
    sort_order INT DEFAULT 0,
    is_active BOOLEAN DEFAULT true,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Cookie-Zustimmungen
CREATE TABLE cookie_consents (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID REFERENCES users(id) ON DELETE CASCADE,
    category_id UUID REFERENCES cookie_categories(id),
    consented BOOLEAN NOT NULL,
    consented_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    UNIQUE(user_id, category_id)
);

-- Audit Log (DSGVO-konform)
CREATE TABLE consent_audit_log (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID,
    action VARCHAR(50) NOT NULL, -- 'consent_given', 'consent_withdrawn', 'data_export', 'data_delete'
    entity_type VARCHAR(50), -- 'document', 'cookie_category'
    entity_id UUID,
    details JSONB,
    ip_address INET,
    user_agent TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Indizes für Performance
CREATE INDEX idx_user_consents_user ON user_consents(user_id);
CREATE INDEX idx_user_consents_version ON user_consents(document_version_id);
CREATE INDEX idx_cookie_consents_user ON cookie_consents(user_id);
CREATE INDEX idx_audit_log_user ON consent_audit_log(user_id);
CREATE INDEX idx_audit_log_created ON consent_audit_log(created_at);

API-Endpoints (Entwurf)

Public API (für BreakPilot Frontend)

# Dokumente abrufen
GET  /api/v1/documents                    # Alle aktiven Dokumente
GET  /api/v1/documents/:type              # Dokument nach Typ (terms, privacy)
GET  /api/v1/documents/:type/latest       # Neueste publizierte Version

# Consent Management
POST /api/v1/consent                      # Zustimmung erteilen
GET  /api/v1/consent/my                   # Meine Zustimmungen
GET  /api/v1/consent/check/:documentType  # Prüfen ob zugestimmt
DELETE /api/v1/consent/:id                # Zustimmung widerrufen

# Cookie Consent
GET  /api/v1/cookies/categories           # Cookie-Kategorien
POST /api/v1/cookies/consent              # Cookie-Präferenzen setzen
GET  /api/v1/cookies/consent/my           # Meine Cookie-Einstellungen

# Data Subject Rights (DSGVO)
GET  /api/v1/privacy/my-data              # Alle meine Daten abrufen
POST /api/v1/privacy/export               # Datenexport anfordern
POST /api/v1/privacy/delete               # Löschung anfordern

Admin API (für Admin Dashboard)

# Document Management
GET    /api/v1/admin/documents            # Alle Dokumente (mit Drafts)
POST   /api/v1/admin/documents            # Neues Dokument
PUT    /api/v1/admin/documents/:id        # Dokument bearbeiten
DELETE /api/v1/admin/documents/:id        # Dokument löschen

# Version Management
GET    /api/v1/admin/versions/:docId      # Alle Versionen eines Dokuments
POST   /api/v1/admin/versions             # Neue Version erstellen
PUT    /api/v1/admin/versions/:id         # Version bearbeiten
POST   /api/v1/admin/versions/:id/publish # Version veröffentlichen
POST   /api/v1/admin/versions/:id/archive # Version archivieren

# Cookie Categories
GET    /api/v1/admin/cookies/categories   # Alle Kategorien
POST   /api/v1/admin/cookies/categories   # Neue Kategorie
PUT    /api/v1/admin/cookies/categories/:id
DELETE /api/v1/admin/cookies/categories/:id

# Statistics & Reports
GET    /api/v1/admin/stats/consents       # Consent-Statistiken
GET    /api/v1/admin/stats/cookies        # Cookie-Statistiken
GET    /api/v1/admin/audit-log            # Audit Log (mit Filter)

// middleware/consent_check.go

func ConsentCheckMiddleware(requiredConsent string) gin.HandlerFunc {
    return func(c *gin.Context) {
        userID := c.GetString("user_id")

        // Prüfe ob User zugestimmt hat
        hasConsent, err := consentService.CheckConsent(userID, requiredConsent)
        if err != nil {
            c.AbortWithStatusJSON(500, gin.H{"error": "Consent check failed"})
            return
        }

        if !hasConsent {
            c.AbortWithStatusJSON(403, gin.H{
                "error": "consent_required",
                "document_type": requiredConsent,
                "message": "Sie müssen den Nutzungsbedingungen zustimmen",
            })
            return
        }

        c.Next()
    }
}

// Verwendung in BreakPilot
router.POST("/api/worksheets",
    authMiddleware,
    ConsentCheckMiddleware("terms"),
    worksheetHandler.Create,
)

┌─────────────────────────────────────────────────────────────┐
│                    Erster Besuch                            │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  1. User öffnet BreakPilot                                 │
│              │                                              │
│              ▼                                              │
│  2. Check: Hat User Cookie-Consent gegeben?                │
│              │                                              │
│    ┌─────────┴─────────┐                                   │
│    │ Nein              │ Ja                                │
│    ▼                   ▼                                   │
│  3. Zeige Cookie     Lade gespeicherte                    │
│     Banner           Präferenzen                           │
│    │                                                        │
│    ▼                                                        │
│  ┌─────────────────────────────────────────┐               │
│  │        Cookie Consent Banner            │               │
│  ├─────────────────────────────────────────┤               │
│  │ Wir verwenden Cookies, um Ihnen die    │               │
│  │ beste Erfahrung zu bieten.              │               │
│  │                                         │               │
│  │ ☑ Notwendig (immer aktiv)              │               │
│  │ ☐ Funktional                           │               │
│  │ ☐ Analytics                            │               │
│  │ ☐ Marketing                            │               │
│  │                                         │               │
│  │ [Alle akzeptieren] [Auswahl speichern] │               │
│  │ [Nur notwendige]   [Mehr erfahren]     │               │
│  └─────────────────────────────────────────┘               │
│                                                             │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│ Einstellungen > Legal                                       │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │ Meine Zustimmungen                                  │   │
│  ├─────────────────────────────────────────────────────┤   │
│  │                                                     │   │
│  │ ✓ Allgemeine Geschäftsbedingungen                  │   │
│  │   Version 2.1 · Zugestimmt am 15.11.2024          │   │
│  │   [Ansehen] [Widerrufen]                           │   │
│  │                                                     │   │
│  │ ✓ Datenschutzerklärung                             │   │
│  │   Version 3.0 · Zugestimmt am 15.11.2024          │   │
│  │   [Ansehen] [Widerrufen]                           │   │
│  │                                                     │   │
│  │ ✓ Community Guidelines                              │   │
│  │   Version 1.2 · Zugestimmt am 15.11.2024          │   │
│  │   [Ansehen] [Widerrufen]                           │   │
│  │                                                     │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │ Cookie-Einstellungen                                │   │
│  ├─────────────────────────────────────────────────────┤   │
│  │                                                     │   │
│  │ ☑ Notwendige Cookies (erforderlich)                │   │
│  │ ☑ Funktionale Cookies                              │   │
│  │ ☐ Analytics Cookies                                │   │
│  │ ☐ Marketing Cookies                                │   │
│  │                                                     │   │
│  │ [Einstellungen speichern]                          │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │ Meine Daten (DSGVO)                                 │   │
│  ├─────────────────────────────────────────────────────┤   │
│  │                                                     │   │
│  │ [Meine Daten exportieren]                          │   │
│  │ Erhalten Sie eine Kopie aller Ihrer gespeicherten  │   │
│  │ Daten als JSON-Datei.                              │   │
│  │                                                     │   │
│  │ [Account löschen]                                  │   │
│  │ Alle Ihre Daten werden unwiderruflich gelöscht.    │   │
│  │                                                     │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Nächste Schritte

Sofort (diese Woche)

  1. Entscheidung: Go oder Python für Backend?
  2. Projekt-Setup: Repository anlegen
  3. Datenbank: Schema finalisieren und migrieren

Kurzfristig (nächste 2 Wochen)

  1. Core API implementieren
  2. Basis-Integration in BreakPilot

Mittelfristig (nächste 4-6 Wochen)

  1. Admin Dashboard
  2. Cookie Banner
  3. DSGVO-Features

Offene Fragen

  1. Sprache: Go oder Python für das Backend?
  2. Admin Dashboard: Eigenes Frontend oder in BreakPilot integriert?
  3. Hosting: Gleicher Server wie BreakPilot oder separater Service?
  4. Auth: Shared Authentication mit BreakPilot oder eigenes System?
  5. Datenbank: Shared PostgreSQL oder eigene Instanz?

Ressourcen-Schätzung

Phase Aufwand (Tage) Beschreibung
Phase 1 5-7 Datenbank & Setup
Phase 2 8-10 Core Consent Service
Phase 3 10-12 Admin Dashboard
Phase 4 8-10 BreakPilot Integration
Phase 5 5-7 DSGVO Features
Phase 6 5-7 Testing & Security
Gesamt 41-53 ~8-10 Wochen

Dokument erstellt am: 12. Dezember 2024 Version: 1.0