# Datenschutz View: Datenklassen fuer Prompt-Flow

Status: 2026-06-13

Ziel: Kompakte DPA/Audit-Sicht auf Datenarten, Transfers und Speicherorte im ALICE Prompt-Prozess.

## 1) Datenklassen

- Klasse A: Identifikations- und Steuerdaten
  - user_id, organization_id, chat_session_id, conversation_id, model_type, status, timestamps
- Klasse B: Fachlicher Inhalt
  - user_prompt, Kontextzeilen (SavedRow), Chat-History, LLM-Antwort, RAG-Excerpts, Suchergebnisse
- Klasse C: Datei-/Medienpayloads
  - Upload-Dateiinhalt, image data URL (base64), extrahierter Dokumenttext
- Klasse D: Nachweis- und Metadaten
  - sources, source_references, ingestion_status, token usage, generated file metadata

## 2) Transfer-Matrix

| Sender | Empfaenger | Datenklasse | Zweck | Extern |
|---|---|---|---|---|
| Browser | ALICE API | A, B | Chat-Start | Nein |
| Browser | ALICE Upload API | A, C | Datei-Upload | Nein |
| ALICE Orchestrator | LLM Provider | B (optional C indirekt via enhanced prompt) | Antwortgenerierung | Ja |
| ALICE Orchestrator | Web Search Provider | B | Internet-Recherche | Ja |
| ALICE File Worker | Vision Endpoint | C | Bildbeschreibung | Ja |
| ALICE Orchestrator | RAG Retrieval (intern) | A, B | Dokumentsuche | Nein |
| ALICE API | Browser | A, B, D | Polling-Ergebnis | Nein |

## 3) Speicher-Matrix

| Speichersystem | Datenklasse | Beispiele |
|---|---|---|
| PostgreSQL (AIConversation) | A, B, D | prompt, response, status, sources, tokens_used |
| PostgreSQL (SavedRow) | B, D | anbieter, thema, details_markdown, quellenpassus |
| PostgreSQL (OrganizationDocument) | A, C, D | file, library_type, single_use, ingestion_status, content_text |
| PGVector (RAG) | B, D | Dokument-Chunks + Metadaten (org_id, source_doc_id, chunk_index) |
| GeneratedChatFile Storage | B, D | erzeugte Datei + Metadaten |

## 4) UML (Kompakte Klassensicht)

```mermaid
classDiagram
    class PromptRequest {
      +user_id : int
      +chat_session_id : int
      +prompt : text
      +context_row_ids : int[]
      +model_type : string
    }

    class AIConversation {
      +id : int
      +prompt : text
      +response : text
      +sources : json[]
      +source_references : json[]
      +processing_status : string
      +tokens_used : int
      +created_at : datetime
    }

    class SavedRow {
      +anbieter : string
      +thema : string
      +details_markdown : text
      +quellenpassus : text
      +conversation_id : int
    }

    class OrganizationDocument {
      +id : int
      +library_type : string
      +single_use : bool
      +chat_session_id : int
      +content_text : text
      +ingestion_status : string
    }

    class LLMOutboundPayload {
      +system_context : text[]
      +history : text[]
      +user_prompt : text
    }

    class WebSearchRequest {
      +query : text
      +provider : string
      +topic : string
    }

    class RAGToolPayload {
      +query : text
      +results : excerpt[]
      +sources : string[]
    }

    class GeneratedChatFile {
      +filename : string
      +file_type : string
      +mime_type : string
      +file_size : int
      +conversation_id : int
    }

    PromptRequest --> AIConversation : creates
    AIConversation --> SavedRow : links generated rows
    AIConversation --> GeneratedChatFile : links generated files
    AIConversation ..> LLMOutboundPayload : builds
    LLMOutboundPayload ..> WebSearchRequest : optional tool call
    LLMOutboundPayload ..> RAGToolPayload : optional tool call
    OrganizationDocument --> RAGToolPayload : provides excerpts
```

## 5) Datenschutz-Hinweise (kurz)

- Externe Transfers entstehen nur bei LLM/Web/Vision-Aufrufen.
- RAG-Zugriffe sind auf organization + user scope + optional chat_session_id gefiltert.
- Single-use Dokumente sind fuer den jeweiligen Chat-Kontext begrenzt.
- Polling gibt nur konversationsgebundene Resultate an den anfragenden User zurueck.
