import type { SystemInfoConfig } from './types' export const middlewareConfig: SystemInfoConfig = { title: 'Middleware System-Info', description: 'Middleware-Stack mit Test-Wizard fuer Integration Tests.', version: '1.5', architecture: { layers: [ { title: 'Test Wizard UI', components: ['Test Runner', 'Result Viewer', 'Coverage Report'], color: '#3b82f6' }, { title: 'API Gateway', components: ['Traefik', 'Rate Limiter', 'Auth Proxy'], color: '#8b5cf6' }, { title: 'Services', components: ['Consent', 'Klausur', 'School', 'Backend'], color: '#10b981' }, { title: 'Infrastructure', components: ['PostgreSQL', 'Valkey', 'MinIO', 'Qdrant'], color: '#f59e0b' }, ], }, features: [ { name: 'Integration Tests', status: 'active', description: 'End-to-End API Tests' }, { name: 'Health Checks', status: 'active', description: 'Service-Status Pruefung' }, { name: 'Test Wizard', status: 'active', description: 'Interaktive Test-Suite' }, { name: 'Load Testing', status: 'planned', description: 'Performance-Tests' }, { name: 'Chaos Engineering', status: 'planned', description: 'Resilienz-Tests' }, ], roadmap: [ { phase: 'Phase 1: Testing (Q1)', priority: 'high', items: ['API Test Suite', 'Database Tests', 'Auth Flow Tests', 'Error Handling Tests'] }, { phase: 'Phase 2: Performance (Q2)', priority: 'medium', items: ['k6 Load Tests', 'Latency Benchmarks', 'Throughput Tests', 'Memory Profiling'] }, { phase: 'Phase 3: Resilience (Q3)', priority: 'low', items: ['Chaos Monkey', 'Failover Tests', 'Circuit Breaker', 'Graceful Degradation'] }, ], technicalDetails: [ { component: 'API Gateway', technology: 'Traefik', version: '3.x', description: 'Reverse Proxy' }, { component: 'Cache', technology: 'Valkey', version: '8.x', description: 'In-Memory Store' }, { component: 'Storage', technology: 'MinIO', version: 'Latest', description: 'S3-kompatibel' }, { component: 'Vector DB', technology: 'Qdrant', version: '1.12+', description: 'Similarity Search' }, ], auditInfo: [ { category: 'Service Health', items: [ { label: 'API Gateway (Traefik)', value: 'Online', status: 'ok' }, { label: 'PostgreSQL', value: 'Online', status: 'ok' }, { label: 'Valkey (Cache)', value: 'Online', status: 'ok' }, { label: 'Qdrant', value: 'Online', status: 'ok' }, ], }, { category: 'Test Coverage', items: [ { label: 'Integration Tests', value: 'Aktiv', status: 'ok' }, { label: 'Auth Flow Tests', value: 'Implementiert', status: 'ok' }, { label: 'Load Tests', value: 'Geplant', status: 'warning' }, { label: 'Chaos Tests', value: 'Geplant', status: 'warning' }, ], }, { category: 'Performance', items: [ { label: 'Avg. Response Time', value: '< 100ms', status: 'ok' }, { label: 'Uptime (30 Tage)', value: '> 99.9%', status: 'ok' }, { label: 'Error Rate', value: '< 0.1%', status: 'ok' }, { label: 'Cache Hit Ratio', value: '> 90%', status: 'ok' }, ], }, ], fullDocumentation: `

Middleware & Integration Testing

1. Uebersicht

Das Middleware-Modul verwaltet den gesamten Service-Stack und bietet einen Test-Wizard fuer Integration Tests. Es stellt sicher, dass alle Services korrekt miteinander kommunizieren.

2. Service-Architektur

┌─────────────────────────────────────────────────────────────────────┐
│                          Traefik Gateway                             │
│  ├── TLS Termination                                                │
│  ├── Rate Limiting                                                  │
│  ├── Request Routing                                                │
│  └── Health Checks                                                  │
└────────────────────────────────┬────────────────────────────────────┘
                                 │
          ┌──────────────────────┼──────────────────────┐
          │                      │                      │
          v                      v                      v
┌─────────────────┐   ┌─────────────────┐   ┌─────────────────┐
│  Website (3000) │   │  Backend (8000) │   │ Consent (8081)  │
│    Next.js      │   │    FastAPI      │   │      Gin        │
└────────┬────────┘   └────────┬────────┘   └────────┬────────┘
         │                     │                     │
         └──────────────────┬──┴─────────────────────┘
                            │
          ┌─────────────────┼─────────────────┐
          │                 │                 │
          v                 v                 v
┌─────────────────┐  ┌────────────┐  ┌─────────────────┐
│   PostgreSQL    │  │   Valkey   │  │     Qdrant      │
│     (5432)      │  │   (6379)   │  │     (6333)      │
└─────────────────┘  └────────────┘  └─────────────────┘

3. Test-Wizard Funktionen

Test-KategorieBeschreibungStatus
Health ChecksService-ErreichbarkeitAutomatisch
Auth FlowLogin, Token-Refresh, LogoutImplementiert
Consent CRUDDokumente erstellen, lesen, aktualisierenImplementiert
DatabaseConnection Pool, Query PerformanceImplementiert
CacheSet/Get, InvalidierungImplementiert
Vector SearchEmbedding, Similarity SearchImplementiert

4. API Endpoints

EndpointMethodeBeschreibung
/api/middleware/healthGETAlle Service Health Checks
/api/middleware/testsGETVerfuegbare Test-Suites
/api/middleware/tests/runPOSTTest-Suite ausfuehren
/api/middleware/metricsGETPerformance-Metriken

5. Health Check Format

{
  "status": "healthy",
  "timestamp": "2025-01-14T10:00:00Z",
  "services": {
    "postgres": {
      "status": "up",
      "latency_ms": 2,
      "details": {"connections": 10, "max": 100}
    },
    "valkey": {
      "status": "up",
      "latency_ms": 1,
      "details": {"memory_used": "50MB"}
    },
    "qdrant": {
      "status": "up",
      "latency_ms": 5,
      "details": {"collections": 3}
    }
  }
}

6. Test-Ausfuehrung

Test Request
     │
     v
┌───────────────────────────────────────┐
│         Test Runner Engine            │
├───────────────────────────────────────┤
│  1. Setup (Fixtures, Test Data)       │
│  2. Execute (Sequential/Parallel)     │
│  3. Assert (Expected vs Actual)       │
│  4. Cleanup (Remove Test Data)        │
│  5. Report (Results, Timings)         │
└───────────────────────────────────────┘
     │
     v
┌───────────────────────────────────────┐
│           Test Report                  │
│  ├── Total: 25, Passed: 24, Failed: 1 │
│  ├── Duration: 5.2s                   │
│  └── Details per Test Case            │
└───────────────────────────────────────┘

7. Rate Limiting

Endpoint-TypLimitWindow
Public API100 req1 Minute
Authenticated API1000 req1 Minute
Admin API5000 req1 Minute
File Upload10 req1 Minute

8. Caching-Strategie

9. Monitoring & Alerts

AlertSchwelleAktion
Service Down3 failed checksPagerDuty, Slack
High Latency> 500ms avgSlack
High Error Rate> 1%Slack
DB Connections High> 80%E-Mail

10. Troubleshooting

Problem: Service nicht erreichbar
├── Check: Docker Container Status
├── Check: Port-Mapping
├── Check: Network (docker network ls)
└── Check: Logs (docker logs service-name)

Problem: Hohe Latenz
├── Check: Database Query Performance
├── Check: Cache Hit Ratio
├── Check: CPU/Memory Usage
└── Check: Network Latency
`, }