# joker-x-dev/coolmallkotlin architecture

> Architecture diagram of the GitHub repository joker-x-dev/coolmallkotlin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joker-x-dev/coolmallkotlin
- Repository: https://github.com/joker-x-dev/coolmallkotlin

## Overview

##### Project Type and Purpose
- This is a modularized Android e-commerce application (“CoolMall”) built in Kotlin with Jetpack Compose.
- It follows MVVM + Clean Architecture, dividing code into layers (presentation, domain, data) and modules (core, feature, navigation, app entry).
- Purpose: demonstrate a modern Android architecture with complete e-commerce flows (auth, product browsing, cart, orders, feedback, chat, user profile).

##### High-Level File Structure Analysis
Top‐level directories:
- app/           → Android application entry point
- build-logic/   → Custom Gradle conventions/plugins
- core/          → “Clean” architecture shared modules:
– common: utilities, base UI states/ViewModels, app config, login manager
– data: repository interfaces, DI modules
– database: Room database, DAOs, data sources, DI
– datastore: key-value store (MMKV) data sources, DI
– designsystem: shared Compose components and theme
– model: data models (entities, requests, responses, previews)
– network: Retrofit services, network data sources, interceptors, DI
– result: unified Result wrapper and handler
– ui: shared UI components (cards, lists, scaffolds, loading, etc)
– util: logging, permission, notification, storage, time, toast utilities
- feature/       → One module per business domain (auth, main, goods, order, market, cs, feedback, user, common, launch)
- navigation/    → Centralized navigation/event router logic
- docs/, template/ → Documentation and code templates

##### Architectural Patterns and Key Technologies
- Architectural style: MVVM + Clean Architecture, modularized by layer and feature
- DI: Hilt for injecting repositories, data sources, database, network clients
- Networking: Retrofit + OkHttp + Coroutines/Flow
- Local persistence: Room (SQLite) + MMKV (DataStore)
- UI: Jetpack Compose + Navigation Compose
- Shared design: custom design system module for consistent theming/components
- Build: Gradle Kotlin DSL with custom convention plugins

##### Main Components
a. Presentation Layer (Client)
- app module: AndroidManifest, Application.kt, MainActivity + NavHost
- Feature modules: Composable screens + ViewModels
- navigation module: AppNavigator, RouteInterceptor → orchestrates Compose NavController
b. Domain/Data Layer (Core Modules)
- core/data: Repository interfaces & DI modules
- core/network: NetworkDataSource implementations → Retrofit services → external API
- core/database & core/datastore: Local data sources (Room DAOs, MMKV)
- core/model: Data models, requests, responses
- core/result: Result wrapper for success/error handling
c. Shared UI & Utils (Core)
- core/designsystem + core/ui: Reusable UI building blocks
- core/util: Logging, permission, notification, validation
d. External Services & Storage
- Remote API (domain-specific e-commerce endpoints)
- Room database (Cart, Footprint, SearchHistory tables)
- MMKV (AuthStore, UserInfoStore)

##### Relationships and Data Flows
1. User interacts with Composable Screen in a Feature module
2. Screen sends events to its ViewModel (core/common BaseViewModel → feature ViewModel)
3. ViewModel calls domain repositories (in core/data) injected by Hilt
4. Repository delegates to:
– NetworkDataSource (core/network) → Retrofit → remote API
– LocalDataSource (core/database / core/datastore) → Room / MMKV
5. Data mapped to core/model entities → wrapped in core/result → returned as Flow/LiveData
6. ViewModel exposes UI state → Compose renders UI
7. Navigation events handled by navigation module

##### Architectural Patterns to Highlight
- Clean separation of concerns: presentation ⇄ domain ⇄ data
- One repository per entity (UserRepository, OrderRepository, etc.)
- DI graph: ApplicationComponent → modules (NetworkModule, DatabaseModule, DataStoreModule, AppStateModule)
- Feature modules depend only on core abstractions, not on each other
- Navigation layer isolating route definitions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External UX
    User["\"Android Device / UX\""]:::external

    %% App Layer
    subgraph "App Layer" 
        direction TB
        AppApp["Application.kt"]:::presentation
        MainAct["MainActivity"]:::presentation
        MainVM["MainActivityViewModel"]:::presentation
        AppNavHost["AppNavHost"]:::presentation
    end

    %% Navigation Layer
    subgraph "Navigation Layer"
        direction TB
        AppNav["AppNavigator"]:::presentation
        RouteInt["RouteInterceptor"]:::presentation
        RouteDefs["Route Definitions"]:::presentation
    end

    %% Feature Modules
    subgraph "Feature Modules"
        direction TB
        AuthFeat["Auth Module"]:::presentation
        LaunchFeat["Launch Module"]:::presentation
        MainFeat["Main Module"]:::presentation
        GoodsFeat["Goods Module"]:::presentation
        OrderFeat["Order Module"]:::presentation
        MarketFeat["Market Module"]:::presentation
        CSFeat["CS Module"]:::presentation
        FeedbackFeat["Feedback Module"]:::presentation
        UserFeat["User Module"]:::presentation
        CommonFeat["Common UI Module"]:::presentation
    end

    %% Core Modules
    subgraph "Core Modules"
        direction TB
        CommonCore["core/common"]:::shared
        DataCore["core/data"]:::domain
        NetworkCore["core/network"]:::data
        DatabaseCore["core/database"]:::data
        DatastoreCore["core/datastore"]:::data
        ModelCore["core/model"]:::shared
        ResultCore["core/result"]:::shared
        DesignCore["core/designsystem"]:::shared
        UICore["core/ui"]:::shared
        UtilCore["core/util"]:::shared
    end

    %% External Services & Storage
    API["Remote API"]:::cloud
    DB["Room Database"]:::database
    KV["MMKV Store"]:::database

    %% Connections
    User --> MainAct
    MainAct --> AppNavHost
    AppNavHost --> AuthFeat & LaunchFeat & MainFeat & GoodsFeat & OrderFeat & MarketFeat & CSFeat & FeedbackFeat & UserFeat & CommonFeat
    AuthFeat & LaunchFeat & MainFeat & GoodsFeat & OrderFeat & MarketFeat & CSFeat & FeedbackFeat & UserFeat & CommonFeat --> CommonCore
    CommonCore --> DataCore
    DataCore --> NetworkCore & DatabaseCore & DatastoreCore
    NetworkCore --> API
    DatabaseCore --> DB
    DatastoreCore --> KV
    DataCore --> ModelCore
    NetworkCore --> ResultCore
    DatabaseCore --> ResultCore
    DatastoreCore --> ResultCore
    ResultCore --> CommonCore
    CommonCore --> AuthFeat & LaunchFeat & MainFeat & GoodsFeat & OrderFeat & MarketFeat & CSFeat & FeedbackFeat & UserFeat & CommonFeat

    AppNavHost --> AppNav
    AppNav --> RouteInt
    AppNav --> RouteDefs

    %% Click Events - App Layer
    click AppApp "https://github.com/joker-x-dev/coolmallkotlin/blob/main/app/src/main/java/com/joker/coolmall/Application.kt"
    click MainVM "https://github.com/joker-x-dev/coolmallkotlin/blob/main/app/src/main/java/com/joker/coolmall/MainActivityViewModel.kt"
    click AppNavHost "https://github.com/joker-x-dev/coolmallkotlin/blob/main/app/src/main/java/com/joker/coolmall/navigation/AppNavHost.kt"

    %% Click Events - Navigation Layer
    click AppNav "https://github.com/joker-x-dev/coolmallkotlin/blob/main/navigation/src/main/java/com/joker/coolmall/navigation/AppNavigator.kt"
    click RouteInt "https://github.com/joker-x-dev/coolmallkotlin/blob/main/navigation/src/main/java/com/joker/coolmall/navigation/RouteInterceptor.kt"
    click RouteDefs "https://github.com/joker-x-dev/coolmallkotlin/tree/main/navigation/src/main/java/com/joker/coolmall/navigation/routes"

    %% Click Events - Feature Modules
    click AuthFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/auth/src/main/java/com/joker/coolmall/feature/auth"
    click LaunchFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/launch/src/main/java/com/joker/coolmall/feature/launch"
    click MainFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/main/src/main/java/com/joker/coolmall/feature/main"
    click GoodsFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/goods/src/main/java/com/joker/coolmall/feature/goods"
    click OrderFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/order/src/main/java/com/joker/coolmall/feature/order"
    click MarketFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/market/src/main/java/com/joker/coolmall/feature/market"
    click CSFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/cs/src/main/java/com/joker/coolmall/feature/cs"
    click FeedbackFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/feedback/src/main/java/com/joker/coolmall/feature/feedback"
    click UserFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/user/src/main/java/com/joker/coolmall/feature/user"
    click CommonFeat "https://github.com/joker-x-dev/coolmallkotlin/tree/main/feature/common/src/main/java/com/joker/coolmall/feature/common"

    %% Click Events - Core Modules
    click CommonCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/common/src/main/java/com/joker/coolmall/core/common/base"
    click CommonCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/common/src/main/java/com/joker/coolmall/core/common/manager/QQLoginManager.kt"
    click DataCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/data/src/main/java/com/joker/coolmall/core/data/repository"
    click DataCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/data/src/main/java/com/joker/coolmall/core/data/di/AppStateModule.kt"
    click NetworkCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/network/src/main/java/com/joker/coolmall/core/network/datasource"
    click NetworkCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/network/src/main/java/com/joker/coolmall/core/network/service"
    click NetworkCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/network/src/main/java/com/joker/coolmall/core/network/di"
    click DatabaseCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/database/src/main/java/com/joker/coolmall/core/database/AppDatabase.kt"
    click DatabaseCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/database/src/main/java/com/joker/coolmall/core/database/dao"
    click DatabaseCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/database/src/main/java/com/joker/coolmall/core/database/datasource"
    click DatabaseCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/database/src/main/java/com/joker/coolmall/core/database/di/DatabaseModule.kt"
    click DatastoreCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/datastore/src/main/java/com/joker/coolmall/core/datastore/datasource"
    click DatastoreCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/datastore/src/main/java/com/joker/coolmall/core/datastore/di/DataStoreModule.kt"
    click ModelCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/model/src/main/java/com/joker/coolmall/core/model"
    click ModelCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/model/src/main/java/com/joker/coolmall/core/model/preview"
    click ResultCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/result/src/main/java/com/joker/coolmall/result/Result.kt"
    click ResultCore "https://github.com/joker-x-dev/coolmallkotlin/blob/main/core/result/src/main/java/com/joker/coolmall/result/ResultHandler.kt"
    click DesignCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/designsystem/src/main/java/com/joker/coolmall/core/designsystem"
    click UICore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/ui/src/main/java/com/joker/coolmall/core/ui/component"
    click UICore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/ui/src/main/java/com/joker/coolmall/core/ui"
    click UtilCore "https://github.com/joker-x-dev/coolmallkotlin/tree/main/core/util/src/main/java/com/joker/coolmall/core/util"

    %% Styles
    classDef presentation fill:#b3e6b3,stroke:#3c763d,color:#000
    classDef domain fill:#cce0ff,stroke:#337ab7,color:#000
    classDef data fill:#ffe0b3,stroke:#8a6d3b,color:#000
    classDef shared fill:#f2f2f2,stroke:#999,color:#000
    classDef external fill:#ffffff,stroke:#999,color:#000
    classDef cloud fill:#e6f7ff,stroke:#3399ff,color:#000
    classDef database fill:#fff0e6,stroke:#ff9933,color:#000
```
