Commit graph

8 commits

Author SHA1 Message Date
Jens Reinemann
2387c6ee5a feat(server): add Exposed ORM database layer with H2
server/db/Tables.kt:
- Exposed table definitions for Categories, Locations, Items, Settings
- Schema mirrors Room entities from app module
- Foreign keys on Items referencing Categories and Locations

server/db/DatabaseFactory.kt:
- H2 file-based DB initialization (jdbc:h2:file:./data/krisenvorrat)
- Parameterized for testability (in-memory DB for tests)
- Schema auto-creation via SchemaUtils.create()

server/repository/InventoryRepository.kt:
- Full CRUD: saveInventory() and loadInventory()
- Atomic replace via transaction (deleteAll + insert)
- Direct mapping between Exposed rows and shared DTOs

4 repository tests with H2 in-memory covering:
- Empty DB, full round-trip, overwrite, nullable fields

Closes #41
2026-05-14 20:15:07 +02:00
Jens Reinemann
cb190e61e9 feat(server): add Ktor server module with health endpoint
New Gradle module :server (Kotlin/JVM) with Ktor 3.1.2 framework,
configured as an embedded Netty HTTP server.

server/src/main/kotlin/de/krisenvorrat/server/:
- Application.kt: entry point using EngineMain for HOCON config
- plugins/Routing.kt: GET /health endpoint returning 200 OK
- plugins/Serialization.kt: ContentNegotiation with kotlinx.json

Configuration:
- application.conf (HOCON): host 0.0.0.0, port 8080, module reference
- logback.xml: SLF4J/Logback console logging

Build config:
- server/build.gradle.kts: Ktor plugin with Fat JAR (server.jar)
- libs.versions.toml: Ktor 3.1.2, Logback 1.5.18 dependencies
- settings.gradle.kts: include(:server)
- :server depends on :shared for common DTO models

Tests: 2 tests (health endpoint, 404 on unknown route) via
Ktor testApplication.

Closes #40
2026-05-14 20:06:40 +02:00
Jens Reinemann
c0c4978ccf feat(shared): add shared module with common DTO models
New Gradle module :shared (pure Kotlin/JVM) containing @Serializable
DTO classes for use by both the Android app and future Ktor server.

shared/src/main/kotlin/de/krisenvorrat/shared/model/:
- InventoryDto: root DTO replacing ExportData (version, categories,
  locations, items, settings)
- CategoryDto, LocationDto, ItemDto, SettingDto: extracted from
  the former *Export data classes in :app

Migration in :app:
- ExportData.kt deleted (classes moved to :shared)
- ImportExportRepositoryImpl now imports from de.krisenvorrat.shared.model
- app/build.gradle.kts adds implementation(project(:shared))

Build config:
- libs.versions.toml: added kotlin-jvm plugin entry
- build.gradle.kts (root): registered kotlin-jvm plugin
- settings.gradle.kts: include(:shared)

JSON wire format is unchanged; all 165 existing tests pass.

Closes #39
2026-05-14 19:50:23 +02:00
Jens Reinemann
8193445939 feat(settings): add JSON/Markdown export via Share Intent
Implement export functionality in the Settings screen allowing users to
share their inventory data as JSON (via FileProvider + ACTION_SEND with
EXTRA_STREAM) or Markdown (via ACTION_SEND with EXTRA_TEXT).

Key changes:
- ShareContent sealed interface for export events (Json with URI,
  Markdown with text)
- SettingsViewModel: exportJson() writes to cache file and creates
  FileProvider URI; exportMarkdown() provides text directly
- SettingsUiState: isExporting, shareContent, exportError fields
- SettingsScreen: LaunchedEffect consumes share events and opens
  Android Share Sheet via Intent.createChooser
- FileProvider registered in AndroidManifest with cache-path config
- MockK added as test dependency for FileProvider static mocking
- 8 new unit tests covering export success, failure, and state cleanup

Closes #37
2026-05-14 03:26:15 +02:00
Jens Reinemann
a4c0dc63b4 feat(navigation): implement Bottom Navigation Bar with 4 tabs and app shell
MainScreen.kt: new app shell with Scaffold + Material 3 NavigationBar
providing 4 tabs (Uebersicht, Inventur, Warnungen, Einstellungen).

TopLevelDestination.kt: enum defining tab routes, icons (Home, Inventory2,
Warning, Settings), and labels for the navigation bar.

Screen.kt: added Warnings and Settings sealed interface members.

KrisenvorratNavGraph.kt: accepts Modifier, added Warnings/Settings
composables, removed obsolete DashboardScreen navigation callback.

DashboardScreen.kt: removed Scaffold wrapper and onNavigateToItems param,
now uses Column layout (TopAppBar handled inline).

ItemListScreen.kt: removed onDashboardClick param and Dashboard menu entry
(no longer needed with tab navigation).

WarningsScreen.kt, SettingsScreen.kt: placeholder screens for future impl.

MainActivity.kt: delegates to MainScreen instead of NavGraph directly.

Added material-icons-extended dependency for Inventory2 icon.

Closes #33
2026-05-14 02:25:47 +02:00
Jens Reinemann
a27660fd4a feat(ui): add category and location management screens
Closes #25

ui/category/:
- CategoryListViewModel: StateFlow-based ViewModel with add/delete
  dialog state management, backed by CategoryRepository
- CategoryListScreen: Material 3 Scaffold with LazyColumn, FAB for
  adding, delete confirmation dialog with CASCADE warning

ui/location/:
- LocationListViewModel: same pattern for LocationRepository
- LocationListScreen: same UI pattern for location management

Tests:
- CategoryListViewModelTest: 11 tests covering init, add, delete,
  dialog state, blank name rejection
- LocationListViewModelTest: 11 tests (same coverage)

Dependencies:
- Added lifecycle-runtime-compose for collectAsStateWithLifecycle
- Added kotlinx-coroutines-test for ViewModel unit tests
2026-05-14 00:56:36 +02:00
Jens Reinemann
b719739451 feat(db): Room-Datenbank & DAOs implementieren (#18)
- KrisenvorratDatabase mit allen 4 Entities und LocalDateConverter
- CategoryDao, LocationDao, ItemDao, SettingsDao mit CRUD und Flow-Queries
- ItemDao.getExpiringSoon(daysUntil) als Default-Interface-Methode
- SettingsDao mit @Upsert (Room 2.6.1)
- Instrumentierungstests für alle 4 DAOs (in-memory DB)
- androidx.room:room-testing zu Dependencies ergänzt
2026-05-13 23:18:48 +02:00
Jens Reinemann
040f007cd5 feat: Android-Projekt-Gerüst anlegen (#13)
- Gradle Kotlin DSL (settings.gradle.kts, build.gradle.kts)
- Version Catalog (libs.versions.toml) mit Compose BOM, Hilt, Room,
  Navigation Compose, kotlinx.serialization
- App-Modul (app/build.gradle.kts), minSdk 26, compileSdk 35
- AndroidManifest.xml mit KrisenvorratApp + MainActivity
- KrisenvorratApp (@HiltAndroidApp)
- MainActivity (@AndroidEntryPoint, Jetpack Compose + Material3)
- KrisenvorratTheme (ui/theme/Theme.kt)
- MVVM-Paketstruktur: data/, domain/, presentation/, di/
- Adaptive Launcher-Icons (mipmap-anydpi-v26)
- Gradle Wrapper 8.11.1 (gradlew, gradlew.bat, gradle-wrapper.jar)
2026-05-13 15:24:39 +02:00