# hoangthan/note-app architecture

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

- Interactive diagram: https://gitdiagram.com/hoangthan/note-app
- Repository: https://github.com/hoangthan/note-app

## Overview

##### Project type and purpose
- This is a full-stack Android application (“Note App”) built with Clean Architecture.
- Purpose: allow users to create, read, update, delete and mark notes complete, with dynamic backgrounds and theming.

##### File structure
- Top-level Gradle modules:
- **app** – the Android application entry point
- **features** – UI modules, one per feature (`core`, `dynamic-background`, `note`)
- **libraries** – domain+data libraries, mirroring the features (`core`, `dynamic-background`, `note`)
- Each feature/library follows a layered package structure (e.g. domain/usecase, data/repository, data/datasource).
- Configuration files: Gradle scripts (`build.gradle`, `common.gradle`, `settings.gradle`), ProGuard rules, `AndroidManifest.xml`.

##### README for additional insights
- Architecture: Clean Architecture with three layers (Data, Domain, Features) that are modularized into `libraries` and `features` Gradle modules.
- Tech stack: Kotlin, Jetpack Compose, MVVM, Coroutines, Flow, Hilt DI, Room, Paging.

a. Main components
- **App Module**: `MainApplication`, `MainActivity`, Hilt setup
- **Feature UI Modules**:
- Core UI (themes, typography)
- UI (Compose screens + ViewModels)
- Dynamic-Background UI (ViewModel + Composables)
- **Library Modules (Domain+Data)**:
- Core Data/Domain (DispatcherProvider, extensions)
- Domain & Data (UseCases, Repository, Room DAO, Entities, Mappers)
- Dynamic-Background Domain & Data (UseCase, repository interface, local image repository)
- **External Services & Components**:
- Room Database
- Hilt dependency graph
- Android Framework (Activity lifecycle, resource system)

b. Relationships and interactions
- App → depends on all **Feature UI Modules**
- Each **Feature UI Module** → depends on its corresponding **Library Module**
- **Library Module** domain layer → exposes `UseCase` APIs
- **Library Module** data layer → implements repository, data sources (Room, local files)
- UI (Compose) → ViewModel → UseCase → Repository → DAO/DB
- Hilt DI provides binding between layers

c. Architectural patterns/design principles
- Clean Architecture (separation of Data/Domain/UI)
- MVVM in UI modules (ViewModel mediating UI & domain)
- Dependency Inversion (UI depends on abstractions (use cases), not concrete repos)
- Package-by-feature and module-by-layer

d. Key technologies/frameworks
- Kotlin & Jetpack Compose for UI
- AndroidX ViewModel, LiveData/StateFlow
- Hilt for DI
- Room for local persistence
- Coroutines + Flow for asynchronous streams
- Paging for large lists

##### Detailed capture of essential elements
- Package names or module names on containers
- Call out Hilt modules and injection points

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Module
    subgraph "App Module" 
        MA["MainActivity"]:::android
        MB["MainApplication"]:::android
        AM["AndroidManifest"]:::android
    end

    %% Feature UI Modules
    subgraph "Feature UI Modules"
        subgraph "Core UI"
            Colors["Colors"]:::ui
            click Colors "https://github.com/hoangthan/note-app/blob/main/features/core/src/main/java/com/note/features/core/ui/Colors.kt"
            Dimens["Dimens"]:::ui
            click Dimens "https://github.com/hoangthan/note-app/blob/main/features/core/src/main/java/com/note/features/core/ui/Dimens.kt"
            Theme["Theme"]:::ui
            click Theme "https://github.com/hoangthan/note-app/blob/main/features/core/src/main/java/com/note/features/core/ui/Theme.kt"
            Typography["Typography"]:::ui
            click Typography "https://github.com/hoangthan/note-app/blob/main/features/core/src/main/java/com/note/features/core/ui/Typography.kt"
        end
        subgraph "Note UI"
            NLS["NoteListScreen"]:::ui
            click NLS "https://github.com/hoangthan/note-app/blob/main/features/note/src/main/java/com/note/features/note/list/NoteListScreen.kt"
            NVM["NoteListViewModel"]:::ui
            click NVM "https://github.com/hoangthan/note-app/blob/main/features/note/src/main/java/com/note/features/note/list/NoteListViewModel.kt"
        end
        subgraph "Dynamic-Background UI"
            DBC["DynamicBackgroundContainer"]:::ui
            click DBC "https://github.com/hoangthan/note-app/blob/main/features/dynamic-background/src/main/java/com/note/features/dynamic_background/DynamicBackgroundContainer.kt"
            DBVM["DynamicBackgroundViewModel"]:::ui
            click DBVM "https://github.com/hoangthan/note-app/blob/main/features/dynamic-background/src/main/java/com/note/features/dynamic_background/DynamicBackgroundViewModel.kt"
        end
    end

    %% Library Modules
    subgraph "Library Modules"
        subgraph "Core Library"
            DP["DispatcherProvider"]:::lib
            click DP "https://github.com/hoangthan/note-app/blob/main/libraries/core/src/main/java/com/note/data/core/coroutine/DispatcherProvider.kt"
            Ext["Extensions"]:::lib
            click Ext "https://github.com/hoangthan/note-app/blob/main/libraries/core/src/main/java/com/note/data/core/utils/Extension.kt"
        end
        subgraph "Dynamic-Background Library"
            DBMod["DynamicBackgroundModule"]:::lib
            click DBMod "https://github.com/hoangthan/note-app/blob/main/libraries/dynamic-background/src/main/java/com/note/libraries/dynamic_background/data/DynamicBackgroundModule.kt"
            LocRepo["LocalImageRepository"]:::lib
            click LocRepo "https://github.com/hoangthan/note-app/blob/main/libraries/dynamic-background/src/main/java/com/note/libraries/dynamic_background/data/repository/LocalImageRepository.kt"
            GetImg["GetRandomImageUseCase"]:::lib
            click GetImg "https://github.com/hoangthan/note-app/blob/main/libraries/dynamic-background/src/main/java/com/note/libraries/dynamic_background/domain/usecase/GetRandomImageUseCase.kt"
            ImgRepo["ImageRepository"]:::lib
            click ImgRepo "https://github.com/hoangthan/note-app/blob/main/libraries/dynamic-background/src/main/java/com/note/libraries/dynamic_background/domain/repository/ImageRepository.kt"
            ImgModel["ImageSource"]:::lib
            click ImgModel "https://github.com/hoangthan/note-app/blob/main/libraries/dynamic-background/src/main/java/com/note/libraries/dynamic_background/domain/model/ImageSource.kt"
        end
        subgraph "Note Library"
            NoteMod["NoteModule"]:::lib
            click NoteMod "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/NoteModule.kt"
            NoteDAO["NoteDao"]:::external
            click NoteDAO "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/datasource/local/NoteDao.kt"
            NoteDB["NoteDatabase"]:::external
            click NoteDB "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/datasource/local/NoteDatabase.kt"
            NoteEntity["NoteEntity"]:::lib
            click NoteEntity "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/datasource/local/entity/NoteEntity.kt"
            NoteMap["NoteMapper"]:::lib
            click NoteMap "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/datasource/mapper/NoteMapper.kt"
            RepoImpl["NoteRepositoryImpl"]:::lib
            click RepoImpl "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/data/repository/NoteRepositoryImpl.kt"
            NoteModel["Note"]:::lib
            click NoteModel "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/model/Note.kt"
            NoteRepo["NoteRepository"]:::lib
            click NoteRepo "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/repository/NoteRepository.kt"
            CreateUC["CreateNoteUseCase"]:::lib
            click CreateUC "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/usecase/CreateNoteUseCaseImpl.kt"
            DeleteUC["DeleteNoteUseCase"]:::lib
            click DeleteUC "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/usecase/DeleteNoteUseCaseImpl.kt"
            GetUC["GetNoteUseCase"]:::lib
            click GetUC "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/usecase/GetNoteUseCaseImpl.kt"
            UpdateUC["UpdateNoteUseCase"]:::lib
            click UpdateUC "https://github.com/hoangthan/note-app/blob/main/libraries/note/src/main/java/com/note/libraries/note/domain/usecase/UpdateNoteUseCaseImpl.kt"
        end
    end

    %% Dependencies and Data Flow
    MA -->|depends on| Colors
    MA -->|depends on| NLS
    MA -->|depends on| DBC

    NLS -->|uses| NVM
    NVM -->|calls| GetUC
    GetUC -->|uses| NoteRepo
    NoteRepo -->|implemented by| RepoImpl
    RepoImpl -->|uses| NoteDAO
    NoteDAO -->|reads/writes| NoteDB
    NoteDB -->|stores| NoteEntity

    DBC -->|uses| DBVM
    DBVM -->|calls| GetImg
    GetImg -->|uses| ImgRepo
    ImgRepo -->|implemented by| LocRepo
    LocRepo -->|reads| ImgModel

    Colors -->|optional utils| Ext
    DP -->|injected by| MB
    DBMod -->|provides| ImgRepo
    NoteMod -->|provides| NoteRepo

    %% Styles
    classDef appMod fill:#f9f,stroke:#333,stroke-width:1px
    classDef ui fill:#bbf,stroke:#333,stroke-width:1px
    classDef lib fill:#bfb,stroke:#333,stroke-width:1px
    classDef android fill:#f99,stroke:#333,stroke-width:1px
    classDef external fill:#fbf,stroke:#333,stroke-width:1px
```
