* MP-8 OTHER Implementiere JWT-Authentifizierungs-Filter im Gateway * Fix(ci): Update upload-artifact action to v4 * Fix(ci): Add start command for Keycloak and failure logs * Fix(ci): Remove invalid 'command' property from Keycloak service * Fix(ci): Use KC_DEV_MODE env var to start Keycloak * Fix(ci): Keycloak service was removed from GitHub Actions services and replaced with a manual docker run step that starts Keycloak with the start-dev command. * dev(ci): vereinheitliche Keycloak auf 26.4.2; aktiviere Health im CI (MP-8) * Fix(ci): Stabilize Keycloak startup in integration tests via matrix - Add `dev-file` Keycloak variant to matrix for stability fallback. - Improve wait logic and health checks for Keycloak and Postgres. - Unify Keycloak version to 26.4.2 across codebase. - Add log dumps on failure. * Fix(ci): Die betroffene Datei docs/Visionen-Ideen/Infrastruktur-Strategie_DSGVO-Konformität.md endet aktuell mit genau einer leeren Zeile (Zeile 87). Das entspricht der Regel MD047 („Files should end with a single newline character“). Damit ist deine Korrektur korrekt. * Fix(ci): Repository-wide auto-fix for Markdown files was implemented with a GitHub Actions workflow and a local helper script. EditorConfig and markdownlint ignore files were added to ensure consistent formatting. Instructions for using the auto-fix both via GitHub Actions and locally were provided. * fix(gradle): build.gradle.kts jsBrowser testTask disabled * fix(gradle): build.gradle.kts jsBrowser testTask disabled * Fix(ci): Stabilize integration tests with Keycloak matrix build (MP-8) Introduces a matrix strategy (`keycloak_db: [postgres, dev-file]`) in the integration-tests workflow to mitigate flaky Keycloak starts when using the Postgres service container. - Adds a `dev-file` Keycloak variant for stability fallback. - Improves wait logic and health checks for Keycloak/Postgres. - Unifies Keycloak version to 26.4.2 across codebase (Dockerfile, Compose, ADR, README, tests). - Adds log dumps on failure in CI. - Ensures `KC_HEALTH_ENABLED=true` is set. - Updates related documentation (README, Schlachtplan). - Includes broader Docker SSoT cleanup (versions.toml as source, script updates, env file cleanup, validator hardening). This resolves recurring CI failures related to Keycloak startup and ensures required checks for PRs (#15) are reliable, while also improving overall Docker build consistency. * feat(docs, ci): Implement YouTrack SSoT strategy with Dokka sync (MP-8) - Add Dokka multi-module Gradle configuration and KDoc style guide. - Add GitHub Actions workflow (docs-kdoc-sync.yml) and Python script (youtrack-sync-kb.py) to sync Dokka GFM output to YouTrack KB. - Extend front-matter schema (bc, doc_type) and update relevant pages/stubs. - Adapt CI scripts (validate-frontmatter, check-docs-drift, ci-docs link ignore). - Update README.md to reference YouTrack KB. * feat(docs, ci): Implement YouTrack SSoT strategy with Dokka sync (MP-8) - Add Dokka multi-module Gradle configuration and KDoc style guide. - Add GitHub Actions workflow (docs-kdoc-sync.yml) and Python script (youtrack-sync-kb.py) to sync Dokka GFM output to YouTrack KB. - Extend front-matter schema (bc, doc_type) and update relevant pages/stubs. - Adapt CI scripts (validate-frontmatter, check-docs-drift, ci-docs link ignore). - Update README.md to reference YouTrack KB. * Fix(ci): Replace OpenAPI validator with Spectral Replaces the deprecated 'char0n/swagger-editor-validate' action, which failed due to sandbox issues in GitHub Actions, with the modern '@stoplight/spectral-cli'. This ensures robust OpenAPI specification validation without requiring a headless browser environment. The 'generate-api-docs' job now depends on the successful completion of the Spectral validation. Part of resolving CI failures for PR #15 (MP-8). * Fix(ci): Specify spectral:oas ruleset for OpenAPI validation (MP-8) * Fix(ci): Remove explicit ruleset argument for Spectral validation (MP-8) * Fix(ci): Added a .spectral.yaml file to fix Spectral linting errors. Corrected markdown lint issues in two documentation files. Updated README.md with a new guidelines section to fix link validation errors. * Fix(ci): Markdownlint errors were fixed by adding required blank lines. The Guidelines Validation error was resolved by updating the README.md link. The API Documentation Generator workflow was stabilized by updating paths, tasks, and validation steps. * Fix(ci): Alle vier fehlerhaften GitHub-Action-Prüfungen wurden behoben. Fehler in der OpenAPI-Spezifikation, Probleme mit der Markdown-Linting-Analyse und Validierungsfehler bei Querverweisen wurden korrigiert. Die README.md enthält nun alle erforderlichen Links zu den Richtlinien. * Fix(ci): Markdown linting errors in docs/api/README.md were fixed by specifying languages in fenced code blocks. OpenAPI specification errors in documentation.yaml were resolved by correcting example property types to strings. Cross-reference validation errors in README.md were fixed by adding the missing link to project-standards/coding-standards.md. * Fix(ci): Duplicate heading errors in docs/api/members-api.md were fixed. Cross-reference validation errors for docker-architecture.md were resolved. All originally reported issues passed validation successfully. * Fix(ci): The markdown heading levels in docs/api/members-api.md were corrected from h5 to h4 to fix linting errors. The missing cross-reference link from technology-guides/docker/docker-development.md to docker-overview.md was added. These fixes resolved the original validation and linting errors causing the process to fail. * Fix(ci): Duplicate heading warnings in docs/api/members-api.md were resolved. Cross-reference validation for docker-development.md to docker-architecture.md was fixed. A new unrelated warning about docker-production.md was identified but not addressed. * refactor(ci,docs): Simplify CI pipeline and migrate docs to YouTrack SSoT BREAKING CHANGE: Documentation structure radically simplified - Consolidate 9 GitHub Actions workflows into 1 main pipeline (ci-main.yml) - Remove redundant workflows: ci-docs, markdownlint-autofix, guidelines-validation, api-docs - Delete documentation migrated to YouTrack: api/, BCs/, Visionen-Ideen/, reference/, now/, overview/ - Keep only ADRs, C4 diagrams, and essential dev guides in repo - Update README.md with YouTrack KB links - Create new docs/README.md as documentation gateway - Relax markdown-lint config for pragmatic developer experience Kept workflows: - ssot-guard.yml (Docker SSoT validation) - docs-kdoc-sync.yml (KDoc → YouTrack sync) - integration-tests.yml (Integration tests) - deploy-proxmox.yml (Deployment) - youtrack-sync.yml (YouTrack integration) Related: MP-DOCS-001 * refactor(ci,docs): Simplify CI pipeline and migrate docs to YouTrack SSoT BREAKING CHANGE: Documentation structure radically simplified - Consolidate 9 GitHub Actions workflows into 1 main pipeline (ci-main.yml) - Remove redundant workflows: ci-docs, markdownlint-autofix, guidelines-validation, api-docs - Delete documentation migrated to YouTrack: api/, BCs/, Visionen-Ideen/, reference/, now/, overview/ - Keep only ADRs, C4 diagrams, and essential dev guides in repo - Update README.md with YouTrack KB links - Create new docs/README.md as documentation gateway - Relax markdown-lint config for pragmatic developer experience Kept workflows: - ssot-guard.yml (Docker SSoT validation) - docs-kdoc-sync.yml (KDoc → YouTrack sync) - integration-tests.yml (Integration tests) - deploy-proxmox.yml (Deployment) - youtrack-sync.yml (YouTrack integration) Related: MP-DOCS-001 * refactor(ci,docs): README.md und einige andere Dokumentationen überarbeitet. ports-and-urls.md hinzugefügt. Related: MP-DOCS-001 * refactor(ci,docs): Die Markdownlint-Fehler in README.md und docs/README.md wurden behoben, indem die Überschriftenebenen angepasst, überflüssige Satzzeichen am Ende entfernt und die notwendigen Leerzeilen um Überschriften, Listen, Tabellen und Codeblöcke eingefügt wurden. Das problematische Leerzeichen am Ende in docs/README.md wurde ebenfalls entfernt. Die Dateien entsprechen nun den vorgegebenen Markdownlint-Regeln und sollten die CI-Validierung bestehen. Related: MP-DOCS-001 * refactor(ci,docs): Docker guideline cross-references were fixed and normalized to lowercase labels. Validation scripts confirmed zero cross-reference warnings and consistent metadata. Documentation was updated with a changelog and enhanced README navigation. Related: MP-DOCS-001 * refactor(ci,docs): Docker guideline cross-references were fixed and normalized to lowercase labels. Validation scripts confirmed zero cross-reference warnings and consistent metadata. Documentation was updated with a changelog and enhanced README navigation. Related: MP-DOCS-001 * refactor(ci,docs): Dead links in docs/architecture/adr were fixed by updating URLs to stable sources and adding an ignore pattern for a placeholder link. Specific ADR files had their broken links replaced with valid ones. The markdown-link-check GitHub Action is expected to pass with zero dead links now. Related: MP-DOCS-001 * refactor(ci,docs): Links in ADR checked Related: MP-DOCS-001 * refactor(ci,docs): Links in ADR checked Related: MP-DOCS-001 * refactor(ci,docs): Markdown Regeln ausgebessert Related: MP-DOCS-001 * refactor(ci,docs): Markdown Regeln ausgebessert Related: MP-DOCS-001 * refactor(ci,docs): Markdown Regeln ausgebessert Related: MP-DOCS-001 * Chore: Rerun CI checks with updated branch protection rules
14 KiB
Infrastructure Module
Überblick
Das Infrastructure-Modul stellt die technische Grundlage für das gesamte Meldestelle-System bereit. Es implementiert alle querschnittlichen Infrastrukturkomponenten, die von den Geschäftsmodulen (members, horses, events, masterdata) benötigt werden. Das Modul folgt dem Prinzip der Separation of Concerns und bietet wiederverwendbare, skalierbare Infrastrukturdienste.
Architektur
Das Infrastructure-Modul ist in 6 Hauptkomponenten unterteilt:
infrastructure/
├── auth/ # Authentifizierung und Autorisierung
│ ├── auth-client/ # Client-seitige Auth-Komponenten
│ └── auth-server/ # Server-seitige Auth-Services
├── cache/ # Caching-Infrastruktur
│ ├── cache-api/ # Cache-Abstraktionen
│ └── redis-cache/ # Redis-basierte Cache-Implementierung
├── event-store/ # Event Sourcing
│ ├── event-store-api/ # Event Store Abstraktionen
│ └── redis-event-store/ # Redis-basierte Event Store Implementierung
├── gateway/ # API Gateway
│ ├── src/ # Gateway-Implementierung
│ ├── docs/ # Gateway-Dokumentation
│ └── build/ # Build-Artefakte
├── messaging/ # Messaging-System
│ ├── messaging-client/ # Messaging-Client
│ └── messaging-config/ # Messaging-Konfiguration
└── monitoring/ # Monitoring und Observability
├── monitoring-client/ # Monitoring-Client
└── monitoring-server/ # Monitoring-Server
Komponenten-Übersicht
1. Authentication & Authorization (auth/)
Zentrale Authentifizierungs- und Autorisierungskomponente basierend auf OAuth 2.0 und JWT.
Features
- JWT Token Management - Erstellung, Validierung und Refresh von JWT-Tokens
- OAuth 2.0 Integration - Unterstützung für OAuth 2.0 Flows
- Role-Based Access Control (RBAC) - Rollenbasierte Zugriffskontrolle
- Keycloak Integration - Integration mit Keycloak Identity Provider
- Session Management - Sichere Session-Verwaltung
Komponenten
- auth-client: Client-seitige Authentifizierungslogik
- auth-server: Server-seitige Authentifizierungsdienste
Verwendung
// JWT Token validieren
val tokenValidator = JwtTokenValidator()
val claims = tokenValidator.validate(token)
// Benutzer authentifizieren
val authService = AuthenticationService()
val user = authService.authenticate(credentials)
2. Caching (cache/)
Hochperformante Caching-Lösung für verbesserte Anwendungsleistung.
Features
- Redis Integration - Redis als primärer Cache-Store
- Multi-Level Caching - L1 (In-Memory) und L2 (Redis) Cache
- Cache Invalidation - Intelligente Cache-Invalidierungsstrategien
- TTL Management - Flexible Time-To-Live Konfiguration
- Cache Statistics - Monitoring und Metriken
Komponenten
- cache-api: Cache-Abstraktionen und Interfaces
- redis-cache: Redis-basierte Cache-Implementierung
Verwendung
// Cache-Service verwenden
val cacheService = RedisCacheService()
cacheService.put("key", value, Duration.ofMinutes(30))
val cachedValue = cacheService.get<String>("key")
// Cache invalidieren
cacheService.invalidate("pattern:*")
3. Event Store (event-store/)
Event Sourcing Infrastruktur für Domain Events und CQRS-Pattern.
Features
- Event Sourcing - Persistierung von Domain Events
- Event Replay - Wiederherstellung von Aggregaten aus Events
- Snapshots - Performance-Optimierung durch Snapshots
- Event Versioning - Versionierung von Event-Schemas
- Stream Processing - Event-Stream-Verarbeitung
Komponenten
- event-store-api: Event Store Abstraktionen
- redis-event-store: Redis-basierte Event Store Implementierung
Verwendung
// Events speichern
val eventStore = RedisEventStore()
eventStore.saveEvents(aggregateId, events, expectedVersion)
// Events laden
val events = eventStore.getEventsForAggregate(aggregateId)
// Event-Stream abonnieren
eventStore.subscribeToStream("member-events") { event ->
// Event verarbeiten
}
4. API Gateway (gateway/)
Zentraler Eingangspoint für alle API-Anfragen mit Routing, Load Balancing und Sicherheit.
Features
- Request Routing - Intelligentes Routing zu Microservices
- Load Balancing - Lastverteilung zwischen Service-Instanzen
- Rate Limiting - Schutz vor Überlastung
- API Versioning - Unterstützung für API-Versionierung
- Request/Response Transformation - Datenformat-Transformationen
- Security - Authentifizierung und Autorisierung
- Monitoring - Request-Tracking und Metriken
Konfiguration
# gateway-config.yml
routes:
- id: members-service
uri: http://members-service:8082
predicates:
- Path=/api/members/**
filters:
- StripPrefix=2
- RateLimit=100,1m
5. Messaging (messaging/)
Asynchrone Kommunikation zwischen Services über Message Queues.
Features
- Apache Kafka Integration - Kafka als Message Broker
- Event-Driven Architecture - Unterstützung für Event-driven Patterns
- Message Serialization - JSON und Avro Serialisierung
- Dead Letter Queues - Fehlerbehandlung für nicht verarbeitbare Nachrichten
- Consumer Groups - Skalierbare Message-Verarbeitung
Komponenten
- messaging-client: Kafka-Client-Bibliothek
- messaging-config: Messaging-Konfiguration
Verwendung
// Message Producer
val producer = KafkaMessageProducer()
producer.send("member-events", memberCreatedEvent)
// Message Consumer
val consumer = KafkaMessageConsumer()
consumer.subscribe("member-events") { message ->
// Message verarbeiten
}
6. Monitoring (monitoring/)
Umfassende Monitoring- und Observability-Lösung.
Features
- Metrics Collection - Sammlung von Anwendungsmetriken
- Distributed Tracing - Zipkin-Integration für Request-Tracing
- Health Checks - Service-Gesundheitsprüfungen
- Alerting - Automatische Benachrichtigungen bei Problemen
- Dashboards - Grafana-Integration für Visualisierung
Komponenten
- monitoring-client: Client-seitige Monitoring-Bibliothek
- monitoring-server: Monitoring-Server und Aggregation
Metriken
// Custom Metrics
val meterRegistry = PrometheusMeterRegistry()
val counter = Counter.builder("member.created")
.register(meterRegistry)
counter.increment()
// Timing
Timer.Sample.start(meterRegistry)
.stop(Timer.builder("member.creation.time")
.register(meterRegistry))
Technologie-Stack
Datenbanken und Speicher
- Redis 7.0 - Caching und Event Store
- PostgreSQL 16 - Relationale Datenbank (über Domain-Module)
Message Broker
- Apache Kafka 7.5.0 - Event Streaming und Messaging
Monitoring und Observability
- Prometheus - Metriken-Sammlung
- Grafana - Dashboards und Visualisierung
- Zipkin - Distributed Tracing
Security
- Keycloak 26.4.2 - Identity und Access Management
- JWT - Token-basierte Authentifizierung
API Gateway
- Spring Cloud Gateway - API Gateway Implementierung
- Nginx - Reverse Proxy und Load Balancer
Konfiguration
Docker Compose
# docker-compose.yml (Auszug)
services:
redis:
image: redis:7-alpine
ports:
- "6379:6379"
command: redis-server --appendonly yes
kafka:
image: confluentinc/cp-kafka:7.5.0
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
keycloak:
image: quay.io/keycloak/keycloak:26.4.2
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: admin
ports:
- "8080:8080"
Umgebungsvariablen
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
# Kafka Configuration
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
KAFKA_GROUP_ID=meldestelle-group
# Keycloak Configuration
KEYCLOAK_URL=http://localhost:8080
KEYCLOAK_REALM=meldestelle
KEYCLOAK_CLIENT_ID=meldestelle-client
# Monitoring Configuration
PROMETHEUS_URL=http://localhost:9090
ZIPKIN_URL=http://localhost:9411
Service Discovery
Consul Integration
// Service Registration
val consulClient = ConsulClient()
val service = NewService().apply {
id = "members-service-1"
name = "members-service"
address = "localhost"
port = 8082
check = NewService.Check().apply {
http = "http://localhost:8082/actuator/health"
interval = "10s"
}
}
consulClient.agentServiceRegister(service)
Sicherheit
JWT Token Struktur
{
"sub": "user123",
"iss": "meldestelle-auth",
"aud": "meldestelle-api",
"exp": 1640995200,
"iat": 1640991600,
"roles": ["MEMBER", "TRAINER"],
"permissions": ["READ_HORSES", "WRITE_EVENTS"]
}
RBAC Rollen
- ADMIN - Vollzugriff auf alle Ressourcen
- TRAINER - Zugriff auf Pferde und Veranstaltungen
- MEMBER - Zugriff auf eigene Daten
- GUEST - Nur Lesezugriff auf öffentliche Daten
Performance und Skalierung
Caching-Strategien
- Application-Level Caching - In-Memory Cache für häufig verwendete Daten
- Database Query Caching - Redis-Cache für Datenbankabfragen
- HTTP Response Caching - Gateway-Level Caching für API-Responses
- CDN Caching - Content Delivery Network für statische Inhalte
Load Balancing
# nginx.conf
upstream members-service {
server members-service-1:8082;
server members-service-2:8082;
server members-service-3:8082;
}
location /api/members/ {
proxy_pass http://members-service;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
Monitoring und Alerting
Prometheus Metriken
# prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'meldestelle-services'
static_configs:
- targets:
- 'members-service:8082'
- 'horses-service:8083'
- 'events-service:8084'
- 'gateway:8080'
Grafana Dashboards
- System Overview - Gesamtsystem-Metriken
- Service Health - Service-spezifische Gesundheitsindikatoren
- API Performance - Request-Zeiten und Durchsatz
- Error Rates - Fehlerquoten und -trends
- Infrastructure - Redis, Kafka, Database Metriken
Alerting Rules
# alerting-rules.yml
groups:
- name: meldestelle-alerts
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
for: 5m
annotations:
summary: "High error rate detected"
- alert: ServiceDown
expr: up == 0
for: 1m
annotations:
summary: "Service is down"
Deployment
Kubernetes
# infrastructure-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-gateway
spec:
replicas: 3
selector:
matchLabels:
app: api-gateway
template:
spec:
containers:
- name: gateway
image: meldestelle/api-gateway:latest
ports:
- containerPort: 8080
env:
- name: REDIS_HOST
value: "redis-service"
- name: KAFKA_BOOTSTRAP_SERVERS
value: "kafka-service:9092"
Helm Charts
# values.yml
redis:
enabled: true
auth:
enabled: false
master:
persistence:
enabled: true
size: 8Gi
kafka:
enabled: true
replicaCount: 3
persistence:
enabled: true
size: 10Gi
monitoring:
prometheus:
enabled: true
grafana:
enabled: true
adminPassword: "admin"
Entwicklung
Lokale Entwicklung
# Infrastructure Services starten
docker-compose up -d redis kafka keycloak prometheus grafana zipkin
# Gateway starten
./gradlew :infrastructure:gateway:bootRun
# Tests ausführen
./gradlew :infrastructure:test
Integration Tests
@SpringBootTest
@Testcontainers
class InfrastructureIntegrationTest {
@Container
val redis = GenericContainer<Nothing>("redis:7-alpine")
.withExposedPorts(6379)
@Container
val kafka = KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.0"))
@Test
fun `should cache data in Redis`() {
// Test Redis Caching
}
@Test
fun `should send and receive Kafka messages`() {
// Test Kafka Messaging
}
}
Troubleshooting
Häufige Probleme
Redis Connection Issues
# Redis Verbindung testen
redis-cli -h localhost -p 6379 ping
# Redis Logs prüfen
docker logs redis-container
Kafka Connection Issues
# Kafka Topics auflisten
kafka-topics --bootstrap-server localhost:9092 --list
# Consumer Group Status
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group meldestelle-group
Gateway Routing Issues
# Gateway Health Check
curl http://localhost:8080/actuator/health
# Route Configuration prüfen
curl http://localhost:8080/actuator/gateway/routes
Best Practices
Caching
- Cache Warming - Wichtige Daten beim Start vorwärmen
- Cache Invalidation - Konsistente Invalidierungsstrategien
- TTL Configuration - Angemessene Time-To-Live Werte
- Cache Monitoring - Hit/Miss Ratios überwachen
Messaging
- Idempotenz - Message-Handler idempotent implementieren
- Error Handling - Retry-Mechanismen und Dead Letter Queues
- Schema Evolution - Backward-kompatible Schema-Änderungen
- Monitoring - Message-Durchsatz und Latenz überwachen
Security
- Token Rotation - Regelmäßige JWT-Token-Rotation
- HTTPS Only - Ausschließlich verschlüsselte Verbindungen
- Rate Limiting - Schutz vor Brute-Force-Angriffen
- Audit Logging - Vollständige Audit-Trails
Zukünftige Erweiterungen
- Service Mesh - Istio/Linkerd Integration
- Advanced Monitoring - OpenTelemetry Integration
- Multi-Region Deployment - Geografische Verteilung
- Chaos Engineering - Resilience Testing
- GraphQL Gateway - GraphQL API-Unterstützung
- Event Sourcing Enhancements - Advanced Event Store Features
- AI/ML Integration - Machine Learning Pipeline Integration
- Blockchain Integration - Distributed Ledger für Audit-Trails
Letzte Aktualisierung: 25. Juli 2025
Für weitere Informationen zur Gesamtarchitektur siehe README.md.