# robot156/winenote architecture

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

- Interactive diagram: https://gitdiagram.com/robot156/winenote
- Repository: https://github.com/robot156/winenote

## Overview

##### Project Type & Purpose
- This is a full-stack Android application (mobile client only) for capturing, storing, and viewing wine tasting notes.
- Key indicators: multiple Gradle modules (`app`, `core/*`, `feature/*`), AndroidManifest.xml in `app` and feature modules, Compose + Hilt + Room in README.

##### File Structure & Architectural Patterns
Top-level modules:
- `app` – Android application entry point, DI setup, initializers, Google services, Proguard rules.
- `build-logic` – custom Gradle convention/plugins for consistent module setup.
- `core/` – layered “clean architecture” cores:
– `core/data` (data-layer: Room DB, DataStore, remote sources, repositories, DI modules)
– `core/domain` (domain-layer: use cases, repository interfaces, dispatchers)
– `core/model` (shared data models & navigation routes)
– `core/ui` (shared UI components, base ViewModel, state management utilities)
– `core/designsystem` (theming, reusable Compose components)
- `feature/*` – feature modules for each screen: splash, main, wine-list, wine-detail, wine-write, wine-bin, setting. Each contains its own navigation, UI, ViewModel.

Architectural pattern: Clean/Onion/Clean Architecture with Modularization. Android-Compose MVVM with Hilt DI.

##### Extract Additional Insights from README
- Uses Kotlin, Jetpack Compose + Navigation, Coroutines/Flow, Paging3, Room, AAC ViewModel, Hilt.
- README’s “Module Graph” shows high-level module dependencies.

##### Main Components & Interactions
a. Presentation Layer (UI)
– Feature Modules (Compose Screens + Navigation + ViewModels)
– Shared UI modules (`core/ui`, `core/designsystem`)
b. Domain Layer
– Use Case classes in `core/domain/usecase/*`
c. Data Layer
– Repositories in `core/data` implementing domain interfaces
– Local: Room DB (`WineNoteDatabase`, DAOs), DataStore (`PreferenceStorage`)
– Remote: Firebase or custom remote data source
d. Application Layer
– `app` module: `WineNoteApplication` initializes DI, Timber, Firebase
e. Build Logic
– Custom Gradle plugins in `build-logic` for consistent module conventions
f. External Services
– Firebase (Analytics, Crashlytics, Storage)
– (Optional) cloud backend if remote data sync exists

Interaction Flow (example “View Wine List”):
UI Screen → ViewModel
→ UseCase (GetWineRecords)
→ Repository
↙︎             ↘︎
Room DAO         Remote Data Source
↘︎             ↙︎
WineRecord Entities
↘︎
Flow<PagingData>
↘︎
UI displays list

##### Important Architectural Patterns & Principles
- Clean-architecture separation of concerns.
- Dependency inversion via Hilt (DataModule, DomainModule, UI injection).
- Modularization isolating features and shared cores.
- MVVM + unidirectional data flow (Flow / State).
- Compose Navigation per feature.

##### Essential Elements
- Clear component labels.
- Arrowheads for flow direction.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer: Feature Modules
    subgraph "Presentation Layer" 
        direction TB
        subgraph "Splash Module" 
            direction TB
            SplashScreen["SplashScreen"]:::ui
            SplashViewModel["SplashViewModel"]:::ui
        end
        subgraph "Main Module"
            direction TB
            MainActivity["MainActivity"]:::ui
            MainViewModel["MainViewModel"]:::ui
        end
        subgraph "Wine List Module"
            direction TB
            WineListScreen["WineListScreen"]:::ui
            WineListViewModel["WineListViewModel"]:::ui
        end
        subgraph "Wine Detail Module"
            direction TB
            WineDetailScreen["WineDetailScreen"]:::ui
            WineDetailViewModel["WineDetailViewModel"]:::ui
        end
        subgraph "Wine Write Module"
            direction TB
            WineWriteScreen["WineWriteScreen"]:::ui
            WineWriteViewModel["WineWriteViewModel"]:::ui
        end
        subgraph "Wine Bin Module"
            direction TB
            WineBinScreen["WineBinScreen"]:::ui
            WineBinViewModel["WineBinViewModel"]:::ui
        end
        subgraph "Settings Module"
            direction TB
            SettingScreen["SettingScreen"]:::ui
            SettingViewModel["SettingViewModel"]:::ui
        end
    end

    %% Domain Layer
    subgraph "Domain Layer" 
        direction TB
        GetWineRecordsUseCase["GetWineRecordsUseCase"]:::domain
        SetThemeUseCase["SetThemeUseCase"]:::domain
        GetThemeUseCase["GetThemeUseCase"]:::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        WineRecordRepositoryImpl["WineRecordRepositoryImpl"]:::data
        SettingRepositoryImpl["SettingRepositoryImpl"]:::data
        subgraph "Local Sources"
            direction TB
            WineRecordLocalDataSourceImpl["WineRecordLocalDataSourceImpl"]:::data
            PreferenceStorageImpl["PreferenceStorageImpl"]:::data
            WineNoteDatabase["WineNoteDatabase"]:::data
            WineRecordDao["WineRecordDao"]:::data
        end
        subgraph "Remote Sources"
            direction TB
            WineRecordRemoteDataSourceImpl["WineRecordRemoteDataSourceImpl"]:::data
            CloudBackend["Cloud Backend"]:::external
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        WineNoteApplication["WineNoteApplication"]:::infra
        CoroutineModule["CoroutineModule"]:::infra
        FirebaseInitializer["FirebaseInitializer"]:::infra
        TimberInitializer["TimberInitializer"]:::infra
    end

    %% Build Logic
    BuildLogic["build-logic (Gradle Plugins)"]:::infra

    %% Shared Core Modules
    subgraph "Core Modules"
        direction TB
        subgraph "core/model"
            WineRecordModel["WineRecord"]:::model
            ThemeConfig["ThemeConfig"]:::model
            Route["Route"]:::model
        end
        subgraph "core/ui"
            BaseViewModel["BaseViewModel"]:::ui
            WineRecordCard["WineRecordCard"]:::ui
        end
        subgraph "core/designsystem"
            DesignTheme["Theme"]:::design
        end
    end

    %% External Services
    Firebase["Firebase Services"]:::external

    %% Data Flow Connections
    WineListViewModel -->|calls| GetWineRecordsUseCase
    MainViewModel -->|calls| GetThemeUseCase
    SettingViewModel -->|calls| SetThemeUseCase

    GetWineRecordsUseCase -->|uses| WineRecordRepositoryImpl
    SetThemeUseCase -->|uses| SettingRepositoryImpl
    GetThemeUseCase -->|uses| SettingRepositoryImpl

    WineRecordRepositoryImpl -->|reads| WineRecordLocalDataSourceImpl
    WineRecordRepositoryImpl -->|reads| WineRecordRemoteDataSourceImpl
    SettingRepositoryImpl -->|reads/writes| PreferenceStorageImpl

    WineRecordLocalDataSourceImpl -->|DAO| WineRecordDao
    WineRecordDao -->|stores| WineNoteDatabase

    WineRecordRemoteDataSourceImpl -->|sync| CloudBackend

    WineNoteApplication -->|initializes| FirebaseInitializer
    WineNoteApplication -->|initializes| TimberInitializer
    WineNoteApplication -->|provides| CoroutineModule

    WineNoteApplication -->|includes| BuildLogic

    FirebaseInitializer -->|configures| Firebase

    %% Click Events
    click WineNoteApplication "https://github.com/robot156/winenote/blob/develop/app/src/main/java/com/winenote/WineNoteApplication.kt"
    click CoroutineModule "https://github.com/robot156/winenote/blob/develop/app/src/main/java/com/winenote/util/CoroutineModule.kt"
    click FirebaseInitializer "https://github.com/robot156/winenote/blob/develop/app/src/main/java/com/winenote/util/initialize/FirebaseInitializer.kt"
    click TimberInitializer "https://github.com/robot156/winenote/blob/develop/app/src/main/java/com/winenote/util/initialize/TimberInitializer.kt"
    click BuildLogic "https://github.com/robot156/winenote/tree/develop/build-logic/src/main/java/com/winenote/convention/"
    click WineNoteDatabase "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/database/WineNoteDatabase.kt"
    click WineRecordDao "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datasource/record/local/WineRecordDao.kt"
    click WineRecordLocalDataSourceImpl "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datasource/record/local/WineRecordLocalDataSourceImpl.kt"
    click WineRecordRemoteDataSourceImpl "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datasource/record/remote/WineRecordRemoteDataSourceImpl.kt"
    click WineRecordRepositoryImpl "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datasource/record/WineRecordRepositoryImpl.kt"
    click SettingRepositoryImpl "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datasource/setting/SettingRepositoryImpl.kt"
    click PreferenceStorageImpl "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/datastore/PreferenceStorageImpl.kt"
    click DataModule "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/di/DataModule.kt"
    click DatabaseModule "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/di/DatabaseModule.kt"
    click DataStoreModule "https://github.com/robot156/winenote/blob/develop/core/data/src/main/java/com/winenote/core/data/di/DataStoreModule.kt"
    click GetWineRecordsUseCase "https://github.com/robot156/winenote/blob/develop/core/domain/src/main/java/com/winenote/core/domain/usecase/record/GetWineRecordsUseCase.kt"
    click UseCase "https://github.com/robot156/winenote/blob/develop/core/domain/src/main/java/com/winenote/core/domain/usecase/UseCase.kt"
    click FlowUseCase "https://github.com/robot156/winenote/blob/develop/core/domain/src/main/java/com/winenote/core/domain/usecase/FlowUseCase.kt"
    click DispatcherQualifiers "https://github.com/robot156/winenote/blob/develop/core/domain/src/main/java/com/winenote/core/domain/di/DispatcherQualifiers.kt"
    click WineRecordModel "https://github.com/robot156/winenote/blob/develop/core/model/src/main/java/com/winenote/core/model/WineRecord.kt"
    click ThemeConfig "https://github.com/robot156/winenote/blob/develop/core/model/src/main/java/com/winenote/core/model/ThemeConfig.kt"
    click Route "https://github.com/robot156/winenote/blob/develop/core/model/src/main/java/com/winenote/core/route/Route.kt"
    click BaseViewModel "https://github.com/robot156/winenote/blob/develop/core/ui/src/main/java/com/winenote/core/ui/base/BaseViewModel.kt"
    click WineRecordCard "https://github.com/robot156/winenote/blob/develop/core/ui/src/main/java/com/winenote/core/ui/common/WineRecordCard.kt"
    click DesignTheme "https://github.com/robot156/winenote/blob/develop/core/designsystem/src/main/java/com/winenote/core/designsystem/theme/Theme.kt"
    click MainActivity "https://github.com/robot156/winenote/blob/develop/feature/main/src/main/java/com/winenote/feature/main/MainActivity.kt"
    click MainViewModel "https://github.com/robot156/winenote/blob/develop/feature/main/src/main/java/com/winenote/feature/main/MainViewModel.kt"
    click WineListScreen "https://github.com/robot156/winenote/blob/develop/feature/wine-list/src/main/java/com/winenote/feature/winelist/WineListScreen.kt"
    click WineListViewModel "https://github.com/robot156/winenote/blob/develop/feature/wine-list/src/main/java/com/winenote/feature/winelist/WineListViewModel.kt"

    %% Styles
    classDef ui fill:#FFA500,stroke:#333,stroke-width:1px
    classDef domain fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#87CEEB,stroke:#333,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#C0C0C0,stroke:#333,stroke-width:1px
    classDef model fill:#F5DEB3,stroke:#333,stroke-width:1px
    classDef design fill:#FFD700,stroke:#333,stroke-width:1px
```
