# cirilobido/focus-timer-yt architecture

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

- Interactive diagram: https://gitdiagram.com/cirilobido/focus-timer-yt
- Repository: https://github.com/cirilobido/focus-timer-yt

## Overview

- Application (Entry Point) Layer: Represent the “FocusTimerApp” as the starting point of the Android application.
- Presentation Layer: Include components such as MainActivity, ViewModels (e.g., HomeScreenViewModel), and screen Composables (HomeScreen, custom UI components like AutoResizedText, CustomButton, etc.). Indicate that these are responsible for UI and user interaction.
- Domain Layer: Show the business logic that includes models (e.g., TimerSessionModel, Resource, TimerTypeEnum) and use case classes (e.g., GetTimerSessionByDateUseCase, SaveTimerSessionUseCase). This layer abstracts and implements key functionalities.
- Data Layer: Highlight the repository pattern with LocalStorageRepository and its implementation (LocalStorageRepositoryImpl). Also include the database component (Room’s AppDatabase, TimerSessionDao, TimerSessionEntity) in this layer.
- Dependency Injection (DI) Module: Represent your DI setup using DatabaseModule and RepositoryModule, which wire the layers together.

##### Data Flow & Relationships
- The FocusTimerApp (application entry point) initializes the DI setup.
- MainActivity (UI) interacts with its ViewModel, which then invokes the corresponding use cases in the Domain layer.
- The Use Case classes call the Repository interface (LocalStorageRepository) in the Domain layer.
- The Repository implementation interacts with the local Room database (AppDatabase) via DAOs.

##### Architectural Patterns
- MVVM pattern in the Presentation layer where the UI (View) communicates with ViewModels.
- Point out that the project adheres to Clean Architecture principles with clear separation between Presentation, Domain, and Data layers.
- Use of dependency injection (evidenced by the di package) for managing and wiring dependencies.

##### Relevant Technologies and Frameworks
- Android Native with Kotlin.
- Jetpack Compose for the modern UI.
- ROOM for local database storage.
- Dependency Injection (could be Dagger/Hilt or manual DI as indicated).
- Testing folders indicate unit tests and instrumented tests for UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    subgraph "Application Layer"
        A_App("FocusTimerApp (Application)"):::application
    end

    %% DI Modules
    subgraph "Dependency Injection"
        E_DBModule("DatabaseModule (DI)"):::di
        E_RepoModule("RepositoryModule (DI)"):::di
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        B_Main("MainActivity (UI)"):::presentation
        B_VM("HomeScreenViewModel (ViewModel)"):::presentation
        B_HS("HomeScreen (Screen Composable)"):::presentation
        subgraph "Custom UI Components"
            B_Auto("AutoResizedText"):::presentation
            B_Button("CustomButton"):::presentation
        end
    end

    %% Domain Layer
    subgraph "Domain Layer"
        C_TimerModel("TimerSessionModel (Model)"):::domain
        C_Resource("Resource (Model)"):::domain
        C_TimerEnum("TimerTypeEnum (Model)"):::domain
        C_GetTimer("GetTimerSessionByDateUseCase (Use Case)"):::domain
        C_SaveTimer("SaveTimerSessionUseCase (Use Case)"):::domain
        C_RepoInterface("LocalStorageRepository (Interface)"):::domain
    end

    %% Data Layer
    subgraph "Data Layer"
        D_RepoImpl("LocalStorageRepositoryImpl (Repository Impl)"):::data
        D_AppDB("AppDatabase (ROOM Database)"):::data
        D_Dao("TimerSessionDao (DAO)"):::data
        D_Entity("TimerSessionEntity (Entity)"):::data
    end

    %% Connections
    A_App -->|"initializes"| E_DBModule
    A_App -->|"initializes"| E_RepoModule

    B_Main -->|"calls"| B_VM
    B_Main -->|"renders"| B_HS
    B_HS -->|"includes"| B_Auto
    B_HS -->|"includes"| B_Button

    B_VM -->|"invokes"| C_GetTimer
    B_VM -->|"invokes"| C_SaveTimer

    C_GetTimer -->|"calls"| C_RepoInterface
    C_SaveTimer -->|"calls"| C_RepoInterface

    C_RepoInterface -->|"implementedBy"| D_RepoImpl

    E_DBModule -->|"provides"| D_AppDB
    E_RepoModule -->|"provides"| D_RepoImpl

    D_RepoImpl -->|"accesses"| D_AppDB
    D_AppDB -->|"provides"| D_Dao
    D_Dao -->|"manages"| D_Entity

    %% Legend
    subgraph "Legend"
        L1["Solid Arrow: Direct Call/Dependency"]
        L2["Layer Colors:"]
        L3["Application: Beige"]
        L4["Presentation: Light Blue"]
        L5["Domain: Light Green"]
        L6["Data: Light Red"]
        L7["DI Modules: Lavender"]
    end

    %% Styles
    classDef application fill:#ffebcd,stroke:#333,stroke-width:2px;
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef domain fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef data fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef di fill:#e6e6fa,stroke:#333,stroke-width:2px;
    classDef legend fill:#fffacd,stroke:#333,stroke-width:1px;

    %% Click Events
    click A_App "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/FocusTimerApp.kt"
    click B_Main "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/presentation/MainActivity.kt"
    click B_VM "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/presentation/home/HomeScreenViewModel.kt"
    click B_HS "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/presentation/home/HomeScreen.kt"
    click B_Auto "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/presentation/components/AutoResizedText.kt"
    click B_Button "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/presentation/components/CustomButton.kt"
    click C_TimerModel "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/model/TimerSessionModel.kt"
    click C_Resource "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/model/Resource.kt"
    click C_TimerEnum "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/model/TimerTypeEnum.kt"
    click C_GetTimer "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/usecase/GetTimerSessionByDateUseCase.kt"
    click C_SaveTimer "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/usecase/SaveTimerSessionUseCase.kt"
    click C_RepoInterface "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/domain/repository/LocalStorageRepository.kt"
    click D_RepoImpl "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/data/repository/LocalStorageRepositoryImpl.kt"
    click D_AppDB "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/data/local/AppDatabase.kt"
    click D_Dao "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/data/local/dao/TimerSessionDao.kt"
    click D_Entity "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/data/local/entity/TimerSessionEntity.kt"
    click E_DBModule "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/di/DatabaseModule.kt"
    click E_RepoModule "https://github.com/cirilobido/focus-timer-yt/blob/master/app/src/main/java/com/cirilobido/focustimeryt/di/RepositoryModule.kt"
```
