fix(compose): Change server host port mapping to 8081 to avoid local conflict

This commit is contained in:
2025-04-20 16:19:17 +02:00
parent c175e53646
commit 2ba54b4e11
17 changed files with 644 additions and 167 deletions
+122 -91
View File
@@ -1,103 +1,134 @@
# Analysis of Meldestelle Project Setups
# Projektanalyse: Meldestelle
## Project Overview
Meldestelle is a Kotlin Multiplatform project targeting three platforms:
1. Web (Kotlin/Wasm)
2. Desktop (JVM)
3. Server (Ktor on JVM)
## Projektübersicht
Dieses Projekt ist eine Kotlin Multiplatform-Anwendung, die aus drei Hauptmodulen besteht:
1. **shared** - Gemeinsam genutzte Klassen und Funktionen für alle Plattformen
2. **server** - Ktor-basierter Backend-Server mit PostgreSQL-Datenbankanbindung
3. **composeApp** - Compose Multiplatform UI-Anwendung für Desktop und Web (WASM/JS)
The project uses a shared module for common code and platform-specific implementations.
## Shared Modul
## Shared Module Setup
- **Purpose**: Contains code shared between all platforms
- **Configuration**:
- Uses Kotlin Multiplatform plugin
- Targets JVM and Wasm/JS
- No explicit dependencies in commonMain
- **Key Components**:
- `Constants.kt`: Defines server port (8080)
- `Greeting.kt`: Common greeting functionality
- `Platform.kt`: Interface with expect/actual pattern for platform-specific implementations
- **Platform Implementations**:
- JVM: Returns "Java [version]"
- Wasm/JS: Returns "Web with Kotlin/Wasm"
### Gemeinsame Klassen und Interfaces
- **Platform** (Interface)
- Eigenschaften: `name: String`
- Zweck: Abstraktion für plattformspezifische Implementierungen
## Web (Wasm/JS) Setup
- **Configuration**:
- Uses experimental Wasm/JS target
- Configures webpack for browser output
- Sets up static paths for debugging
- **UI Implementation**:
- Uses ComposeViewport to attach to document body
- Uses common App composable
- **Resources**:
- Simple HTML template with title "Meldestelle"
- Basic CSS for full viewport styling
- Empty JS file (likely generated during build)
- **Build Output**: Generates composeApp.js
- **Greeting** (Klasse)
- Methoden: `greet(): String`
- Zweck: Einfache Beispielklasse, die eine plattformspezifische Begrüßung zurückgibt
## Desktop Setup
- **Configuration**:
- Uses JVM target
- Configures native distributions (DMG, MSI, DEB)
- Sets main class to "at.mocode.MainKt"
- **UI Implementation**:
- Uses Compose for Desktop's Window API
- Sets window title to "Meldestelle"
- Uses common App composable
- **Dependencies**:
- Compose Desktop for current OS
- Kotlinx Coroutines Swing
- **Constants** (Klasse)
- Aktuell leer, vermutlich für zukünftige Konstanten vorgesehen
## Server Setup
- **Configuration**:
- Uses Kotlin JVM plugin
- Uses Ktor plugin
- Sets main class to "at.mocode.ApplicationKt"
- **Implementation**:
- Uses Ktor with Netty engine
- Runs on port 8080 (from shared Constants)
- Simple GET endpoint at "/"
- Returns "Ktor: [greeting]" using shared Greeting class
- **Dependencies**:
- Shared module
- Logback for logging
- Ktor server core and Netty
- Testing dependencies
### Datenmodelle
- **Turnier** (Data Class)
- Eigenschaften:
- `id: String` - Eindeutige ID für das Turnier
- `name: String` - Name des Turniers
- `datum: String` - Datum oder Zeitraum als Text
- `logoUrl: String?` - Optionaler Link zum Logo
- `ausschreibungUrl: String?` - Optionaler Link zur Ausschreibungs-PDF
- Annotationen: `@Serializable` für JSON-Serialisierung
## Common UI
- **Implementation**:
- Simple Material Design UI
- Button to toggle content visibility
- Shows Compose Multiplatform logo and greeting when visible
- Uses platform-specific greeting implementation
- **Nennung** (Data Class)
- Eigenschaften:
- `turnierId: String` - Referenz zum zugehörigen Turnier
- `riderName: String` - Name des Reiters
- `horseName: String` - Name des Pferdes
- `email: String` - E-Mail-Adresse
- `comments: String?` - Optionale Kommentare
- Annotationen: `@Serializable` für JSON-Serialisierung
## Observations and Recommendations
### Plattformspezifische Implementierungen
- **JVMPlatform** (Klasse, JVM-spezifisch)
- Implementiert: `Platform`
- Eigenschaften: `name = "Java ${System.getProperty("java.version")}"`
### Strengths
1. **Code Sharing**: Effectively shares code between platforms
2. **Platform Abstraction**: Good use of expect/actual pattern
3. **Build Configuration**: Clean separation of build configurations
- **WasmPlatform** (Klasse, WASM/JS-spezifisch)
- Implementiert: `Platform`
- Eigenschaften: `name = "Web with Kotlin/Wasm"`
### Potential Improvements
1. **Dependencies**: The shared module has no explicit dependencies in commonMain
2. **Documentation**: Limited inline documentation
3. **Testing**: No visible tests for client-side code
4. **Resource Handling**: Basic resource handling, could be expanded
5. **Error Handling**: No visible error handling in server endpoints
6. **Configuration**: Hard-coded server port, could use configuration file
7. **Security**: No visible security measures in server setup
8. **Logging**: Minimal logging configuration
- **getPlatform()** (Expect/Actual Funktion)
- Rückgabetyp: `Platform`
- Implementierungen für JVM und WASM/JS
### Recommendations
1. Add proper dependency management in shared module
2. Implement comprehensive testing for all platforms
3. Add proper error handling in server endpoints
4. Use configuration files for server settings
5. Implement security measures for server (CORS, authentication)
6. Enhance logging configuration
7. Add more inline documentation
8. Consider adding a CI/CD pipeline configuration
## Server Modul
## Conclusion
The Meldestelle project demonstrates a well-structured Kotlin Multiplatform application targeting Web, Desktop, and Server. The project effectively shares code between platforms while allowing for platform-specific implementations. With some improvements in areas like testing, error handling, and configuration, the project could be more robust and production-ready.
### Hauptanwendung
- **main** (Funktion)
- Parameter: `args: Array<String>`
- Zweck: Startet den Ktor-Server mit Netty-Engine
- **module** (Erweiterungsfunktion für Application)
- Konfiguriert die Datenbank
- Definiert Routing:
- GET "/" - Zeigt eine HTML-Seite mit Turnieren aus der Datenbank
### Plugins
- **configureDatabase** (Funktion)
- Konfiguriert die Datenbankverbindung mit HikariCP
- Liest Konfiguration aus Umgebungsvariablen
- Initialisiert das Datenbankschema
### Datenbanktabellen
- **TurniereTable** (Object, erbt von Table)
- Tabellenname: "turniere"
- Spalten:
- `id: Column<String>` - Primärschlüssel
- `name: Column<String>` - Name des Turniers
- `datum: Column<String>` - Datum als Text
- `logoUrl: Column<String?>` - Optionaler Logo-URL
- `ausschreibungUrl: Column<String?>` - Optionaler Ausschreibungs-URL
### Tests
- **ApplicationTest** (Klasse)
- Testmethoden:
- `testRootRouteShowsTournamentList()` - Testet die Root-Route und Datenbankinteraktion
- Prüft HTTP-Status, HTML-Inhalt und Anzeige von Turnierdaten
## ComposeApp Modul
### UI-Komponenten
- **App** (Composable Funktion)
- Einfache UI mit Button, der bei Klick einen Begrüßungstext und das Compose-Logo anzeigt
- Verwendet die Greeting-Klasse aus dem Shared-Modul
### Plattformspezifische Implementierungen
- **Desktop** (JVM)
- Verwendet Compose for Desktop's Window API
- Setzt Fenstertitel auf "Meldestelle"
- **Web** (WASM/JS)
- Verwendet Compose für Web
- Generiert composeApp.js für Browser-Ausführung
## Datenbankintegration
- **PostgreSQL** mit **Exposed ORM**
- Verbindungspooling mit HikariCP
- Transaktionsbasierte Datenbankoperationen
- Schema-Initialisierung mit SchemaUtils
## Stärken und Verbesserungspotenzial
### Stärken
1. **Multiplatform-Architektur**: Effektive Codewiederverwendung zwischen Plattformen
2. **Datenbankintegration**: Solide Implementierung mit Connection Pooling und ORM
3. **Modularisierung**: Klare Trennung zwischen Shared, Server und UI-Code
4. **Serialisierung**: Konsistente Datenmodelle mit kotlinx.serialization
### Verbesserungspotenzial
1. **Testabdeckung**: Bisher nur grundlegende Tests für den Server
2. **Fehlerbehandlung**: Minimale Fehlerbehandlung in Datenbankoperationen
3. **Dokumentation**: Begrenzte Inline-Dokumentation
4. **Client-Server-Kommunikation**: Noch keine API-Endpunkte für CRUD-Operationen
## Zusammenfassung
Das Projekt implementiert eine Multiplatform-Anwendung für die Verwaltung von Turnieren und Nennungen. Es besteht aus:
- **5 Klassen**: Greeting, JVMPlatform, WasmPlatform, Turnier, Nennung
- **1 Interface**: Platform
- **1 Datenbanktabelle**: TurniereTable
- **4 Hauptfunktionen**: main, module, configureDatabase, App
- **1 Testklasse** mit 1 Testmethode
Die Anwendung befindet sich in einem frühen Entwicklungsstadium mit grundlegender Funktionalität für die Anzeige von Turnieren aus einer Datenbank. Die Modellklassen und Datenbankstruktur sind für zukünftige Erweiterungen vorbereitet, wie in den Kommentaren im Code angedeutet.