How lainmorchon/openmise works
1. This is a Kotlin Multiplatform Compose app with one shared application core in composeApp and thin platform entry points for Android, iOS, Desktop/JVM, Web/JS, and WebAssembly. The shared code contains most of the architecture; platform folders mainly provide startup glue and platform-specific wiring.
2. The repo is organized around a classic layered split: UI → ViewModel/state → domain → data/repository → local database. There is no obvious remote API layer in the tree, so the main persistence boundary appears to be a local embedded database rather than a backend service.
3. The user interface is shared Compose UI in commonMain, with screens grouped by feature: login, registro, home, and recetas. Each screen has a matching State and ViewModel, which suggests a unidirectional flow from UI events into state updates and back into Compose rendering.
4. Navigation is centralized in ui/core/navigation/Rutas.kt. That file likely acts as the route registry or screen contract for moving between authentication and recipe flows, rather than letting screens hardcode navigation details.
5. The domain layer is intentionally small and stable: Usuario, Receta, Ingrediente, and Alimento live under domain/model, with repository interfaces under domain/repository. This is the boundary that the UI and business logic should depend on, not on database entities.
6. The data layer implements those repository interfaces in data/repository, with RecetaRepositoryImpl and UsuarioRepositoryImpl as the main concrete adapters. This layer bridges the domain model to persistence and likely contains the app’s core use-case logic around users and recipes.
7. Persistence is local and schema-backed. AppDatabase, DAOs, entities, and the generated schema snapshots indicate a Room-style SQLite database. The database model includes UsuarioEntity, AlimentoEntity, DetalleRecetaEntity, and IngredienteRecetaEntity, plus RecetaRelaciones for joined/query-oriented views of recipe data.
8. RecetaMapper is the explicit translation boundary between database entities and domain models. That means the architecture keeps persistence concerns out of the rest of the app and treats the domain objects as the canonical shape for UI and business logic.
9. Dependency wiring is centralized in di/DIConfigurator.kt, DataModule.kt, and UIModule.kt. Those modules likely assemble repositories, database access, and view models so the rest of the app can stay platform-agnostic and avoid manual object creation.
10. Platform-specific code is very thin. Android has MainActivity and a DatabaseBuilder implementation plus the manifest/resources; iOS has MainViewController and a SwiftUI shell in iosApp; JVM/Web/Wasm each have their own small main.kt or platform file. This suggests the same shared UI is reused across targets, with only app bootstrap differing.
11. The Android-specific DatabaseBuilder.kt is an important architecture boundary because database creation must be adapted per platform in KMP. The shared AppDatabase definition is in common code, but the actual instantiation is platform-dependent.
12. Overall, the likely end-to-end data flow is: platform entry point launches shared Compose app, navigation selects a feature screen, the screen talks to its ViewModel, the ViewModel uses domain repositories, repositories read/write the local database through DAOs, and mappers convert between entities and domain models. For an architecture diagram, the key boxes are the shared UI feature modules, the domain/repository abstraction, the local database layer, and the platform startup layer around them.
Main entry points: App.kt Compose app · UIModule.kt UI module · RecetaRepository.kt Receta repo · RecetaRepositoryImpl.kt Receta impl
Components 29
Platform entrypoints
Thin startup layers for each target runtime.
- Android app · Android bootstrap and Activity host.
composeApp/src/androidMain/kotlin/com/morchon/lain/MainActivity.kt - iOS app · iOS view controller and SwiftUI shell.
composeApp/src/iosMain/kotlin/com/morchon/lain/MainViewController.kt - JVM app · Desktop/JVM main launcher.
composeApp/src/jvmMain/kotlin/com/morchon/lain/main.kt - Web app · Web target launcher.
composeApp/src/webMain/kotlin/com/morchon/lain/main.kt - Wasm app · WebAssembly target launcher.
composeApp/src/wasmJsMain/kotlin/com/morchon/lain/Platform.wasmJs.kt
Shared app core
Multiplatform Compose app shared across targets.
- Compose app · Shared multiplatform application composition.
composeApp/src/commonMain/kotlin/com/morchon/lain/App.kt
UI flow
Shared Compose screens, state, and navigation.
- Routes · Central screen route registry.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/core/navigation/Rutas.kt - Login · Authentication screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/login/LoginScreen.kt - Registro · User registration screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/registro/RegistroScreen.kt - Home · Landing screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/home/HomeScreen.kt - Recetas list · Recipe listing screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/recetas/listado/ListadoRecetasScreen.kt - Receta detail · Recipe detail screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/recetas/detalle/DetalleRecetaScreen.kt - Crear receta · Recipe creation screen, state, and view model.
composeApp/src/commonMain/kotlin/com/morchon/lain/ui/recetas/crear/CrearRecetaScreen.kt
Domain layer
Stable business models and repository contracts.
- Usuario · User domain model.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/model/Usuario.kt - Receta · Recipe domain model.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/model/Receta.kt - Ingrediente · Ingredient domain model.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/model/Ingrediente.kt - Alimento · Food domain model.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/model/Alimento.kt - Usuario repo · Domain contract for user persistence and lookup.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/repository/UsuarioRepository.kt - Receta repo · Domain contract for recipe persistence and queries.
composeApp/src/commonMain/kotlin/com/morchon/lain/domain/repository/RecetaRepository.kt
Data layer
Repository implementations and local persistence.
- Usuario impl · Data adapter implementing user repository logic.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/repository/UsuarioRepositoryImpl.kt - Receta impl · Data adapter implementing recipe repository logic.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/repository/RecetaRepositoryImpl.kt - Receta mapper · Translates between database entities and domain models.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/mapper/RecetaMapper.kt - App database · Shared database definition and schema.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/database/AppDatabase.kt - Receta DAO · Recipe data access interface.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/database/dao/RecetaDao.kt - Usuario DAO · User data access interface.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/database/dao/UsuarioDao.kt - DB entities · Persistent entities and joined recipe views.
composeApp/src/commonMain/kotlin/com/morchon/lain/data/database/entity/UsuarioEntity.kt
Dependency wiring
Modules that assemble the app graph.
- DI config · Dependency injection assembly entrypoint.
composeApp/src/commonMain/kotlin/com/morchon/lain/di/DIConfigurator.kt - Data module · Registers repositories and persistence wiring.
composeApp/src/commonMain/kotlin/com/morchon/lain/di/DataModule.kt - UI module · Registers shared UI and view model wiring.
composeApp/src/commonMain/kotlin/com/morchon/lain/di/UIModule.kt
Connections 35
- Android app → Compose app: starts · Android launches the shared Compose app.
- iOS app → Compose app: starts · iOS hosts the shared Compose UI.
- JVM app → Compose app: starts · Desktop/JVM launches shared app code.
- Web app → Compose app: starts · Web launcher enters shared app code.
- Wasm app → Compose app: starts · Wasm launcher enters shared app code.
- Compose app → Routes: uses · App shell relies on centralized route definitions.
- Compose app → Login: shows · Shared app can render authentication flow.
- Compose app → Registro: shows · Shared app can render registration flow.
- Compose app → Home: shows · Shared app can render home flow.
- Compose app → Recetas list: shows · Shared app can render recipe listing flow.
- Compose app → Receta detail: shows · Shared app can render recipe detail flow.
- Compose app → Crear receta: shows · Shared app can render recipe creation flow.
- Login → Usuario repo: depends on · Login state delegates to user domain contract.
- Registro → Usuario repo: depends on · Registration state delegates to user domain contract.
- Home → Receta repo: depends on · Home flow reads recipe-related domain data.
- Recetas list → Receta repo: depends on · Listing flow depends on recipe repository contract.
- Receta detail → Receta repo: depends on · Detail flow depends on recipe repository contract.
- Crear receta → Receta repo: depends on · Creation flow writes through recipe repository contract.
- Usuario impl → Usuario repo: implements · Concrete adapter fulfills the user repository contract.
- Receta impl → Receta repo: implements · Concrete adapter fulfills the recipe repository contract.
- Usuario impl → App database: reads/writes · User repository works through local database access.
- Receta impl → Receta mapper: maps · Recipe repository uses mapper for entity/domain translation.
- Receta impl → App database: reads/writes · Recipe repository works through local database access.
- App database → Receta DAO: exposes · Database exposes recipe DAO.
- App database → Usuario DAO: exposes · Database exposes user DAO.
- Receta DAO → DB entities: persists · Recipe DAO operates on persistent entities.
- Usuario DAO → DB entities: persists · User DAO operates on persistent entities.
- DI config → Data module: loads · DI configuration assembles data layer module.
- DI config → UI module: loads · DI configuration assembles UI module.
- Data module → Usuario impl: provides · Module binds user repository implementation.
- Data module → Receta impl: provides · Module binds recipe repository implementation.
- UI module → Login: provides · Module wires login state and view model.
- UI module → Registro: provides · Module wires registration state and view model.
- UI module → Home: provides · Module wires home state and view model.
- UI module → Recetas list: provides · Module wires recipe listing state and view model.