How jonesstoen/fiskeklar works
Project Type and Purpose
• This is a full-stack mobile application (Android) named FiskeKlar, built in Kotlin with Jetpack Compose.
• Its goal is to display real-time maritime data (vessel AIS, weather alerts, currents, wind, waves) on an interactive map, let users log catches and favorites, and provide SOS/emergency features.
High-Level Architectural Patterns
• MVVM (Model-View-ViewModel) throughout the app:
• Presentation: Jetpack Compose UI + Navigation
• ViewModel: State + LiveData/StateFlow, injected via KSP (Room, Hilt optional)
• Domain/Use Cases: Pure business logic (drift calculations, parsing)
• Data: Repositories coordinating between local (Room, DataStore) and remote (Retrofit services, GRIB parser)
• Layered Architecture with clear separation of concerns
• Repository Pattern for decoupling data sources
• Dependency Injection (KSP) to wire ViewModels to Repositories
A. Presentation Layer (Client)
• UI Screens & Composables (HomeScreen, MapScreen, SOS, Catch Log, Profile)
• AppNavHost for navigation
• Jetpack Compose + Material 3 for rendering
B. ViewModel Layer
• HomeViewModel, MapViewModel, GribViewModel, FishingLogViewModel, etc.
• Expose UI state (LiveData/StateFlow)
C. Domain Layer (Use Cases)
• calculateDriftVectors, calculateDriftImpact, weather data aggregators
• Pure Kotlin functions and models
D. Data Layer
1. Repositories: AisRepository, GribRepository, MetAlertsRepository, FishLogRepository, etc.
2. Local Data Source
– Room Database (AppDatabase + DAOs for FishingLog, FishType, User, Favorites, Suggestions)
– DataStore for preferences (AppDataStore)
3. Remote Data Source
– Retrofit Instances: BarentsWatchRetrofitInstance, GeocodingRetrofitInstance, GribRetrofitInstance, MetAlertsRetrofitInstance
– API Service Interfaces: WeatherService, BarentsWatchAuthService, etc.
– Datasources wrapping raw calls: BarentsWatchDataSource, GribDataSource, etc.
4. Local Parser (GribParser via NetCDF-Java/CDM)
E. External Systems & Services
• BarentsWatch API (AIS + forbud zones)
• MET Norway/MetAlerts API
• MapTiler Tiles / MapLibre GL
• Stadia Maps (Geocoding)
• Media3 (audio alerts)
• Device Platform (Android Location Services, Camera, Storage)
Relationships & Data Flow
• UI → ViewModel: User actions and events
• ViewModel → Domain Use Case: Invoke business logic
• ViewModel → Repository: Fetch or update data
• Repository → Local/Remote Data Source:
• If cache exists → Room/Datastore
• Else → Retrofit → parse → emit results
• Remote Data Source → Repository: Return parsed models
• Repository → ViewModel: Wrap in Result<T>, expose state
• ViewModel → UI: Observe and render changes
• Device Sensors/Permissions: UI requests location or camera; results flow back to ViewModel
Essential Architectural Elements to Capture
• MVVM layer separation
• Repository pattern between Domain and Data
• Dual data sources (local cache vs remote APIs)
• Parsing sub-system (NetCDF/CDM) as its own component
• External API endpoints and authentication flows
• Android platform dependencies (Permissions, Sensors, Camera)