# mathroda/dashcoin architecture

> Architecture diagram of the GitHub repository mathroda/dashcoin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mathroda/dashcoin
- Repository: https://github.com/mathroda/dashcoin

## Overview

##### Project Type and Purpose
- This is a Kotlin Multiplatform Mobile (KMM) full-stack mobile application (Android + iOS)
- Purpose: Crypto-currency tracker using Clean Architecture with shared business logic and UI components, plus native Android and iOS launchers

##### Layers and Modules
A. Presentation Layer
- AndroidApp (Jetpack Compose UIs + AndroidDI/Hilt)
- iOSApp (SwiftUI/AppKit + UIKit integration)
- shared module UI entrypoint (DashCoinApp.kt, SharedViewModel, Navigation graphs)
- Feature UIs (coins, coin-details, chart, news, favorite-coins, onboarding, auth, profile)
B. Domain Layer
- core-domain: Entities, value objects (Coin, Charts, User, News, Events)
- Use-case interfaces reside in core-datasource/usecases (e.g., DashCoinUseCases, GetFavoriteCoinsUseCase)
C. Data Layer
- core-network: Retrofit/Ktor client, DTOs, network module & engine (KtorEngine, OkHttp interceptor)
- core-cache: Room database + DataStore, DAOs, converters, cache module
- core-datasource: Repositories (DashCoinRepository, FirebaseRepository), platform modules (androidMain, iosMain)
D. Infrastructure Layer
- core-infrastructure: Internet connectivity, phone shaking sensor, WorkManager tasks (DashCoinWorker), notifications
- Modules providing platform-abstraction implementations
E. Dependency Injection
- Koin modules defined in shared (Koin.kt, ViewModelsModule) and each core-*/feature module (DataSourceModule, NetworkModule, CacheModule, InfrastructureModule, CoreModule.android/ios)

##### External Services & Platforms
- External REST API: CoinStats (HTTP)
- Firebase Authentication & Firestore
- Local SQLite via Room, DataStore on device
- WorkManager on Android, background tasks on iOS
- Notifications (Android Notification Manager, iOS UNUserNotificationCenter)

##### Relationships & Data Flow
- UI → Shared ViewModels (StateFlow) → Use-cases (core-datasource)
- Use-cases → Repositories (core-datasource)
– Repositories → network client (core-network) for remote data
– Repositories → cache (core-cache) for local persistence
- Infrastructure modules injected where needed (e.g., connectivity checks before network calls, scheduling sync tasks)
- Shared DI modules bootstrap the graph at app launch

##### Architectural Patterns & Principles
- Clean Architecture (Presentation → Domain → Data → Infrastructure)
- MVVM + StateFlow for UI state management
- KMM for code reuse across Android and iOS
- Single-responsibility modules: each feature is its own Gradle submodule
- Dependency inversion: domain/usecases depend on repository interfaces, implementations injected via DI

##### Must-Include Elements
- Component labels (module name + primary classes/tech)

##### Final Checklist
[ ] Presentation/UI layer (AndroidApp, iOSApp, shared DashCoinApp)
[ ] Feature modules (coins, details, chart, auth, etc.)
[ ] Domain layer with entities & use-cases
[ ] Data layer: network, cache, repos
[ ] Infrastructure layer: connectivity, background workers, notifications
[ ] DI modules for each layer
[ ] External dependencies: CoinStats REST, Firebase, local DB

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AndroidApp["AndroidApp\n(Jetpack Compose)"]:::presentation
        DashCoinApplication["DashCoinApplication"]:::presentation
        iOSApp["iOSApp\n(SwiftUI)"]:::presentation
        ContentView["ContentView"]:::presentation
        SharedApp["DashCoinApp\n(Navigation)"]:::presentation
        SharedVM["SharedViewModel"]:::presentation
        Navigation["Navigation Graphs"]:::presentation
        DIShared["DI Modules\n(Koin, ViewModels)"]:::presentation

        AndroidApp -->|launches| DashCoinApplication
        AndroidApp -->|invokes| SharedApp
        iOSApp -->|invokes| SharedApp
        ContentView -->|hosts| SharedApp
        SharedApp -->|uses| SharedVM
        SharedVM -->|uses| Navigation
        SharedApp -->|configured by| DIShared
    end

    subgraph "Feature UIs" 
        direction TB
        CoinsScreen["CoinsScreen"]:::presentation
        CoinDetailScreen["CoinDetailScreen"]:::presentation
        ChartScreen["ChartScreen"]:::presentation
        NewsScreen["NewsScreen"]:::presentation
        FavoriteScreen["FavoriteCoinsScreen"]:::presentation
        OnboardingScreen["OnboardingScreen"]:::presentation
        SignInScreen["SignInScreen"]:::presentation
        SignUpScreen["SignUpScreen"]:::presentation
        ForgotPasswordScreen["ForgotPasswordScreen"]:::presentation
        ProfileScreen["ProfileScreen"]:::presentation

        SharedVM -->|state updates| CoinsScreen
        SharedVM -->|state updates| CoinDetailScreen
        SharedVM -->|state updates| ChartScreen
        SharedVM -->|state updates| NewsScreen
        SharedVM -->|state updates| FavoriteScreen
        SharedVM -->|state updates| OnboardingScreen
        SharedVM -->|state updates| SignInScreen
        SharedVM -->|state updates| SignUpScreen
        SharedVM -->|state updates| ForgotPasswordScreen
        SharedVM -->|state updates| ProfileScreen
    end

    %% Domain Layer
    subgraph "Domain Layer" 
        direction TB
        Entities["Entities\n(core-domain)"]:::domain
        Events["Events"]:::domain
        UseCases["UseCase Interfaces"]:::domain

        SharedVM -->|calls| UseCases
        UseCases -->|emit| Entities
        UseCases -->|emit| Events
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        CoreDatasource["core-datasource\n(Repositories)"]:::data
        CoreNetwork["core-network\n(Ktor + Retrofit)"]:::data
        CoreCache["core-cache\n(Room + DataStore)"]:::data

        UseCases -->|invoke| CoreDatasource
        CoreDatasource -->|remote fetch| CoreNetwork
        CoreDatasource -->|local persistence| CoreCache
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        direction TB
        Connectivity["InternetConnectivityManager"]:::infra
        Sensor["PhoneShakingManager"]:::infra
        WorkerProv["WorkerProviderRepository"]:::infra

        CoreDatasource -->|checks| Connectivity
        CoreDatasource -->|schedules| WorkerProv
    end

    %% External Services
    subgraph "External Services"
        direction TB
        CoinStatsAPI["CoinStats REST API"]:::external
        Firebase["Firebase Auth & Firestore"]:::external
        RoomDB["Room DB"]:::external
        DataStoreExt["DataStore"]:::external
        WorkMgr["WorkManager / iOS Background"]:::external
        Notifications["Notifications"]:::external

        CoreNetwork -->|HTTP| CoinStatsAPI
        CoreDatasource -->|auth data| Firebase
        CoreCache -->|DB ops| RoomDB
        CoreCache -->|preferences| DataStoreExt
        WorkerProv -->|runs on| WorkMgr
        WorkerProv -->|sends| Notifications
    end

    %% Click Events
    click AndroidApp "https://github.com/mathroda/dashcoin/blob/master/androidApp/src/main/java/com/mathroda/dashcoin/MainActivity.kt"
    click DashCoinApplication "https://github.com/mathroda/dashcoin/blob/master/androidApp/src/main/java/com/mathroda/dashcoin/DashCoinApplication.kt"
    click iOSApp "https://github.com/mathroda/dashcoin/blob/master/iosApp/iosApp/iosAppApp.swift"
    click ContentView "https://github.com/mathroda/dashcoin/blob/master/iosApp/iosApp/ContentView.swift"
    click SharedApp "https://github.com/mathroda/dashcoin/blob/master/shared/src/commonMain/kotlin/com/mathroda/shared/DashCoinApp.kt"
    click SharedVM "https://github.com/mathroda/dashcoin/blob/master/shared/src/commonMain/kotlin/com/mathroda/shared/SharedViewModel.kt"
    click Navigation "https://github.com/mathroda/dashcoin/blob/master/shared/src/commonMain/kotlin/com/mathroda/shared/navigation/Navigation.kt"
    click DIShared "https://github.com/mathroda/dashcoin/blob/master/shared/src/commonMain/kotlin/com/mathroda/shared/di/Koin.kt"
    click CoinsScreen "https://github.com/mathroda/dashcoin/blob/master/features/coins/src/commonMain/kotlin/com/mathroda/coins/CoinsScreen.kt"
    click CoinDetailScreen "https://github.com/mathroda/dashcoin/blob/master/features/coin-details/src/commonMain/kotlin/com/mathroda/coin_details/BasicCoinDetailScreen.kt"
    click ChartScreen "https://github.com/mathroda/dashcoin/blob/master/features/chart/src/commonMain/kotlin/com/mathroda/chart/common/BarChartView.kt"
    click NewsScreen "https://github.com/mathroda/dashcoin/blob/master/features/news/src/commonMain/kotlin/com/mathroda/news/NewsScreen.kt"
    click FavoriteScreen "https://github.com/mathroda/dashcoin/blob/master/features/favorite-coins/src/commonMain/kotlin/com/mathroda/favorites/FavoriteCoinsScreen.kt"
    click OnboardingScreen "https://github.com/mathroda/dashcoin/blob/master/features/onboarding/src/commonMain/kotlin/com/mathroda/onboarding/BasicOnBoardingScreen.kt"
    click SignInScreen "https://github.com/mathroda/dashcoin/blob/master/auth/signin/src/commonMain/kotlin/com/mathroda/signin_screen/BasicSignIn.kt"
    click SignUpScreen "https://github.com/mathroda/dashcoin/blob/master/auth/signup/src/commonMain/kotlin/com/mathroda/signup/BasicSignUpScreen.kt"
    click ForgotPasswordScreen "https://github.com/mathroda/dashcoin/blob/master/auth/forgot-password/src/commonMain/kotlin/com/mathroda/forgot_password/BasicForgotPasswordScreen.kt"
    click ProfileScreen "https://github.com/mathroda/dashcoin/blob/master/features/profile/src/commonMain/kotlin/com/mathroda/profile/ProfileViewModel.kt"
    click Entities "https://github.com/mathroda/dashcoin/blob/master/core-domain/src/commonMain/kotlin/com/mathroda/domain/CoinById.kt"
    click Events "https://github.com/mathroda/dashcoin/blob/master/core-domain/src/commonMain/kotlin/com/mathroda/domain/events/FavoriteCoinEvents.kt"
    click UseCases "https://github.com/mathroda/dashcoin/blob/master/core-datasource/src/commonMain/kotlin/com/mathroda.datasource/usecases/DashCoinUseCases.kt"
    click CoreNetwork "https://github.com/mathroda/dashcoin/blob/master/core-network/src/commonMain/kotlin/com/mathroda/network/di/NetworkModule.kt"
    click CoreCache "https://github.com/mathroda/dashcoin/blob/master/core-cache/src/commonMain/kotlin/com/mathroda/cache/di/CacheModule.kt"
    click CoreDatasource "https://github.com/mathroda/dashcoin/blob/master/core-datasource/src/commonMain/kotlin/com/mathroda.datasource/core/DashCoinRepository.kt"
    click Connectivity "https://github.com/mathroda/dashcoin/blob/master/core-infrastructure/src/commonMain/kotlin/com/mathroda/internetconnectivity/InternetConnectivityManger.kt"
    click WorkerProv "https://github.com/mathroda/dashcoin/blob/master/core-infrastructure/src/commonMain/kotlin/com/mathroda/workmanger/WorkerProviderRepository.kt"

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#1E70BF,color:#000
    classDef domain fill:#DFF2D8,stroke:#3C763D,color:#000
    classDef data fill:#FFE5B4,stroke:#BF7700,color:#000
    classDef infra fill:#E0D7FF,stroke:#5D3FD3,color:#000
    classDef external fill:#F0F0F0,stroke:#888,color:#000
```
