/**
 * Module Registry Data - All backend module definitions
 *
 * This file contains the pure data array of module definitions.
 * Helper functions are in module-registry.ts.
 */

import type { BackendModule } from './module-registry'

export const MODULE_REGISTRY: BackendModule[] = [
  // ===========================================
  // COMPLIANCE MODULES
  // ===========================================
  {
    id: 'consent-documents',
    name: 'Consent Dokumente',
    description: 'Verwaltung rechtlicher Dokumente (AGB, Datenschutz, etc.)',
    category: 'compliance',
    backend: {
      service: 'consent-service',
      port: 8081,
      basePath: '/api/consent/admin',
      endpoints: [
        { path: '/documents', method: 'GET', description: 'Liste aller Dokumente' },
        { path: '/documents', method: 'POST', description: 'Dokument erstellen' },
        { path: '/documents/{id}', method: 'GET', description: 'Dokument Details' },
        { path: '/documents/{id}', method: 'PUT', description: 'Dokument aktualisieren' },
        { path: '/documents/{id}', method: 'DELETE', description: 'Dokument loeschen' },
      ]
    },
    frontend: {
      adminV2Page: '/sdk/consent-management',
      oldAdminPage: '/admin/consent',
      status: 'connected'
    },
    priority: 'critical'
  },
  {
    id: 'consent-versions',
    name: 'Dokument-Versionierung',
    description: 'Versionsverwaltung und Freigabe-Workflow fuer rechtliche Dokumente',
    category: 'compliance',
    backend: {
      service: 'consent-service',
      port: 8081,
      basePath: '/api/consent/admin',
      endpoints: [
        { path: '/documents/{id}/versions', method: 'GET', description: 'Versionen eines Dokuments' },
        { path: '/versions', method: 'POST', description: 'Neue Version erstellen' },
        { path: '/versions/{id}', method: 'PUT', description: 'Version aktualisieren' },
        { path: '/versions/{id}', method: 'DELETE', description: 'Version loeschen' },
        { path: '/versions/{id}/submit-review', method: 'POST', description: 'Zur Pruefung einreichen' },
        { path: '/versions/{id}/approve', method: 'POST', description: 'Version genehmigen' },
        { path: '/versions/{id}/reject', method: 'POST', description: 'Version ablehnen' },
        { path: '/versions/{id}/publish', method: 'POST', description: 'Version veroeffentlichen' },
        { path: '/versions/{id}/approval-history', method: 'GET', description: 'Genehmigungsverlauf' },
        { path: '/versions/upload-word', method: 'POST', description: 'Word-Dokument importieren' },
      ]
    },
    frontend: {
      adminV2Page: '/sdk/workflow',
      oldAdminPage: '/admin/consent (Versions Tab)',
      status: 'connected'
    },
    dependencies: ['consent-documents'],
    priority: 'critical'
  },
  {
    id: 'consent-user',
    name: 'Nutzer-Einwilligungen',
    description: 'Tracking von Nutzer-Einwilligungen fuer DSGVO-Compliance',
    category: 'compliance',
    backend: {
      service: 'consent-service',
      port: 8081,
      basePath: '/api/consent',
      endpoints: [
        { path: '/status', method: 'GET', description: 'Einwilligungsstatus pruefen' },
        { path: '/give', method: 'POST', description: 'Einwilligung erteilen' },
        { path: '/withdraw', method: 'POST', description: 'Einwilligung widerrufen' },
        { path: '/history', method: 'GET', description: 'Einwilligungshistorie' },
      ]
    },
    frontend: {
      adminV2Page: '/sdk/einwilligungen',
      oldAdminPage: '/admin/consent (Users Tab)',
      status: 'connected',
    },
    priority: 'critical',
  },
  {
    id: 'dsr-requests',
    name: 'Datenschutzanfragen (DSR)',
    description: 'DSGVO Art. 15-21 Anfragen verwalten',
    category: 'compliance',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/dsr',
      endpoints: [
        { path: '/requests', method: 'GET', description: 'Alle DSR-Anfragen' },
        { path: '/requests', method: 'POST', description: 'Neue Anfrage erstellen' },
        { path: '/requests/{id}', method: 'GET', description: 'Anfrage-Details' },
        { path: '/requests/{id}/process', method: 'POST', description: 'Anfrage bearbeiten' },
        { path: '/requests/{id}/export', method: 'GET', description: 'Daten exportieren' },
      ]
    },
    frontend: {
      adminV2Page: '/sdk/dsr',
      oldAdminPage: '/admin/dsr',
      status: 'connected'
    },
    priority: 'high',
  },
  {
    id: 'dsms',
    name: 'Datenschutz-Management-System',
    description: 'Zentrales DSMS fuer Dokumentation und Compliance',
    category: 'compliance',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/dsms',
      endpoints: [
        { path: '/documents', method: 'GET', description: 'DSMS-Dokumente' },
        { path: '/processes', method: 'GET', description: 'Verarbeitungsverzeichnis' },
        { path: '/toms', method: 'GET', description: 'TOM-Katalog' },
        { path: '/audits', method: 'GET', description: 'Audit-Historie' },
      ]
    },
    frontend: {
      adminV2Page: '/sdk/dsms',
      oldAdminPage: '/admin/dsms',
      status: 'connected'
    },
    priority: 'medium'
  },
  {
    id: 'cookie-categories',
    name: 'Cookie-Kategorien',
    description: 'Verwaltung von Cookie-Kategorien fuer Consent Banner',
    category: 'compliance',
    backend: {
      service: 'consent-service',
      port: 8081,
      basePath: '/api/consent/admin',
      endpoints: [
        { path: '/cookies/categories', method: 'GET', description: 'Alle Cookie-Kategorien' },
        { path: '/cookies/categories', method: 'POST', description: 'Kategorie erstellen' },
        { path: '/cookies/categories/{id}', method: 'PUT', description: 'Kategorie aktualisieren' },
        { path: '/cookies/categories/{id}', method: 'DELETE', description: 'Kategorie loeschen' },
      ]
    },
    frontend: {
      adminV2Page: undefined,
      oldAdminPage: '/admin/consent (Cookies Tab)',
      status: 'not-connected'
    },
    priority: 'medium',
    notes: 'Cookie-Kategorien Tab im alten Admin vorhanden'
  },

  // ===========================================
  // AI MODULES
  // ===========================================
  {
    id: 'ai-agents',
    name: 'AI Agents',
    description: 'Multi-Agent System Verwaltung und Monitoring',
    category: 'ai',
    backend: {
      service: 'voice-service',
      port: 8088,
      basePath: '/api/v1/agents',
      endpoints: [
        { path: '/sessions', method: 'GET', description: 'Agent-Sessions' },
        { path: '/statistics', method: 'GET', description: 'Agent-Statistiken' },
        { path: '/{agentId}', method: 'GET', description: 'Agent-Details' },
        { path: '/{agentId}/soul', method: 'GET', description: 'SOUL-Konfiguration' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/agents',
      oldAdminPage: undefined,
      status: 'connected'
    },
    priority: 'high',
    notes: 'Neues Multi-Agent System'
  },
  {
    id: 'ai-quality',
    name: 'AI Quality (BQAS)',
    description: 'KI-Qualitaetssicherung und Evaluierung',
    category: 'ai',
    backend: {
      service: 'voice-service',
      port: 8088,
      basePath: '/api/bqas',
      endpoints: [
        { path: '/evaluate', method: 'POST', description: 'Antwort evaluieren' },
        { path: '/metrics', method: 'GET', description: 'Qualitaetsmetriken' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/quality',
      oldAdminPage: '/admin/quality',
      status: 'connected'
    },
    priority: 'high'
  },
  {
    id: 'magic-help',
    name: 'Magic Help (TrOCR)',
    description: 'Handschrifterkennung mit TrOCR und LoRA Fine-Tuning',
    category: 'ai',
    backend: {
      service: 'klausur-service',
      port: 8086,
      basePath: '/api/klausur/trocr',
      endpoints: [
        { path: '/status', method: 'GET', description: 'TrOCR Status' },
        { path: '/extract', method: 'POST', description: 'Text aus Bild extrahieren' },
        { path: '/training/examples', method: 'GET', description: 'Trainingsbeispiele' },
        { path: '/training/add', method: 'POST', description: 'Trainingsbeispiel hinzufuegen' },
        { path: '/training/fine-tune', method: 'POST', description: 'Fine-Tuning starten' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/magic-help',
      oldAdminPage: '/admin/magic-help',
      status: 'connected'
    },
    priority: 'medium',
    notes: 'Lokale Handschrifterkennung mit Privacy-by-Design'
  },
  {
    id: 'klausur-korrektur',
    name: 'Klausur-Korrektur',
    description: 'KI-gestuetzte Abitur-Korrektur mit EH-Vorschlaegen',
    category: 'ai',
    backend: {
      service: 'klausur-service',
      port: 8086,
      basePath: '/api/v1',
      endpoints: [
        { path: '/klausuren', method: 'GET', description: 'Alle Klausuren' },
        { path: '/klausuren', method: 'POST', description: 'Klausur erstellen' },
        { path: '/klausuren/{id}/students', method: 'GET', description: 'Studentenarbeiten' },
        { path: '/students/{id}/annotations', method: 'GET', description: 'Anmerkungen' },
        { path: '/students/{id}/gutachten/generate', method: 'POST', description: 'Gutachten generieren' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/klausur-korrektur',
      oldAdminPage: '/admin/klausur-korrektur',
      status: 'not-connected'
    },
    priority: 'high',
    notes: 'Komplexes Modul mit eigenem Backend-Service'
  },
  {
    id: 'ocr-labeling',
    name: 'OCR-Labeling',
    description: 'Handschrift-Training und Label-Verwaltung',
    category: 'ai',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/ocr',
      endpoints: [
        { path: '/samples', method: 'GET', description: 'Training-Samples' },
        { path: '/labels', method: 'GET', description: 'Label-Kategorien' },
        { path: '/train', method: 'POST', description: 'Training starten' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/ocr-labeling',
      oldAdminPage: '/admin/ocr-labeling',
      status: 'not-connected'
    },
    priority: 'medium'
  },
  {
    id: 'rag-management',
    name: 'RAG & Daten',
    description: 'Retrieval Augmented Generation und Training Data',
    category: 'ai',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/rag',
      endpoints: [
        { path: '/documents', method: 'GET', description: 'RAG-Dokumente' },
        { path: '/collections', method: 'GET', description: 'Vector-Collections' },
        { path: '/query', method: 'POST', description: 'RAG-Abfrage' },
      ]
    },
    frontend: {
      adminV2Page: '/ai/rag',
      oldAdminPage: '/admin/rag',
      status: 'connected'
    },
    priority: 'medium'
  },

  // ===========================================
  // INFRASTRUCTURE MODULES
  // ===========================================
  {
    id: 'gpu-infrastructure',
    name: 'GPU Infrastruktur',
    description: 'vast.ai GPU-Management und Monitoring',
    category: 'infrastructure',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/gpu',
      endpoints: [
        { path: '/instances', method: 'GET', description: 'GPU-Instanzen' },
        { path: '/instances', method: 'POST', description: 'Instanz erstellen' },
        { path: '/usage', method: 'GET', description: 'Nutzungsstatistiken' },
      ]
    },
    frontend: {
      adminV2Page: '/infrastructure/gpu',
      oldAdminPage: '/admin/gpu',
      status: 'connected'
    },
    priority: 'medium'
  },
  {
    id: 'security-dashboard',
    name: 'Security Dashboard',
    description: 'DevSecOps Dashboard und Vulnerability Scans',
    category: 'infrastructure',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/security',
      endpoints: [
        { path: '/scans', method: 'GET', description: 'Security-Scans' },
        { path: '/vulnerabilities', method: 'GET', description: 'Schwachstellen' },
        { path: '/compliance', method: 'GET', description: 'Compliance-Status' },
      ]
    },
    frontend: {
      adminV2Page: '/infrastructure/security',
      oldAdminPage: '/admin/security',
      status: 'connected'
    },
    priority: 'high'
  },
  {
    id: 'sbom',
    name: 'SBOM',
    description: 'Software Bill of Materials',
    category: 'infrastructure',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/sbom',
      endpoints: [
        { path: '/components', method: 'GET', description: 'Komponenten-Liste' },
        { path: '/licenses', method: 'GET', description: 'Lizenz-Uebersicht' },
        { path: '/export', method: 'GET', description: 'SBOM exportieren' },
      ]
    },
    frontend: {
      adminV2Page: '/infrastructure/sbom',
      oldAdminPage: '/admin/sbom',
      status: 'connected'
    },
    priority: 'medium'
  },

  {
    id: 'middleware',
    name: 'Middleware Manager',
    description: 'Verwaltung und Monitoring der Backend-Middleware',
    category: 'infrastructure',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/middleware',
      endpoints: [
        { path: '/status', method: 'GET', description: 'Middleware-Status' },
        { path: '/config', method: 'GET', description: 'Konfiguration' },
      ]
    },
    frontend: {
      adminV2Page: '/infrastructure/middleware',
      oldAdminPage: '/admin/middleware',
      status: 'connected'
    },
    priority: 'medium'
  },
  {
    id: 'ci-cd',
    name: 'CI/CD Pipeline',
    description: 'Build-Pipeline und Deployment-Management',
    category: 'infrastructure',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/builds',
      endpoints: [
        { path: '/pipelines', method: 'GET', description: 'Pipeline-Status' },
        { path: '/builds', method: 'GET', description: 'Build-Historie' },
      ]
    },
    frontend: {
      adminV2Page: '/infrastructure/ci-cd',
      oldAdminPage: '/admin/builds',
      status: 'connected'
    },
    priority: 'medium'
  },

  // ===========================================
  // EDUCATION MODULES
  // ===========================================
  {
    id: 'edu-search',
    name: 'Bildungssuche',
    description: 'Suche nach Bildungsinhalten und Ressourcen',
    category: 'education',
    backend: {
      service: 'edu-search-service',
      port: 8089,
      basePath: '/api/edu',
      endpoints: [
        { path: '/search', method: 'GET', description: 'Bildungssuche' },
        { path: '/resources', method: 'GET', description: 'Ressourcen' },
      ]
    },
    frontend: {
      adminV2Page: '/education/edu-search',
      oldAdminPage: '/admin/edu-search',
      status: 'connected'
    },
    priority: 'medium'
  },

  // ===========================================
  // COMMUNICATION MODULES
  // ===========================================
  {
    id: 'alerts',
    name: 'Alerts & Benachrichtigungen',
    description: 'System-Benachrichtigungen und Alerts',
    category: 'communication',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/alerts',
      endpoints: [
        { path: '/notifications', method: 'GET', description: 'Benachrichtigungen' },
        { path: '/alerts', method: 'GET', description: 'Aktive Alerts' },
      ]
    },
    frontend: {
      adminV2Page: '/communication/alerts',
      oldAdminPage: '/admin/alerts',
      status: 'connected'
    },
    priority: 'medium'
  },
  {
    id: 'unified-inbox',
    name: 'Unified Inbox',
    description: 'E-Mail-Konten und KI-Analyse',
    category: 'communication',
    backend: {
      service: 'python-backend',
      port: 8000,
      basePath: '/api/mail',
      endpoints: [
        { path: '/accounts', method: 'GET', description: 'E-Mail-Konten' },
        { path: '/messages', method: 'GET', description: 'Nachrichten' },
        { path: '/analyze', method: 'POST', description: 'KI-Analyse' },
      ]
    },
    frontend: {
      adminV2Page: '/communication/mail',
      oldAdminPage: '/admin/mail',
      status: 'connected'
    },
    priority: 'low'
  },

  // ===========================================
  // DEVELOPMENT MODULES
  // ===========================================
  {
    id: 'voice-service',
    name: 'Voice Service',
    description: 'Voice-First Interface',
    category: 'development',
    backend: {
      service: 'voice-service',
      port: 8088,
      basePath: '/api/voice',
      endpoints: [
        { path: '/transcribe', method: 'POST', description: 'Sprache transkribieren' },
        { path: '/synthesize', method: 'POST', description: 'Text zu Sprache' },
      ]
    },
    frontend: {
      adminV2Page: '/development/voice',
      oldAdminPage: '/admin/voice',
      status: 'not-connected'
    },
    priority: 'low'
  },
]
