# kokorikofc/tfgonitime architecture

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

- Interactive diagram: https://gitdiagram.com/kokorikofc/tfgonitime
- Repository: https://github.com/kokorikofc/tfgonitime

## Overview

##### Project Type and Purpose
- Android mobile application written in Kotlin
- Implements MVVM (Model–View–ViewModel) + Repository patterns
- Uses Firebase (google‑services.json) for authentication, chat, diary, etc.
- Provides UI screens for login, sign‐up, diary, chat, tasks, missions, streaks, store, settings

##### Main Architectural Components
- Presentation Layer (UI)
– Activities & Compose/Views (MainActivity, screen Composables under ui/screens and ui/components)
– Navigation wrapper (NavigationWrapper.kt)
- ViewModel Layer
– ViewModels for each feature (AuthViewModel, ChatViewModel, DiaryViewModel, …)
– Exposes LiveData/StateFlows to the UI
- Domain/Data Layer
– Repositories (ChatRepository, DiaryRepository, TaskRepository, etc.)
– LanguageManager for runtime locale
- Data Models
– Plain‐Kotlin data classes (User, Task, Mission, Mood, Streak, StreakDay, TaskGroup)
- External Services
– Firebase Auth / Firestore / Realtime Database (implied by google‑services.json)
– Local caching (if any) or Room (if integrated)
- Configuration & Resources
– Gradle build scripts, ProGuard, themes, drawables, strings

##### Relationships and Data Flow
- UI <‐> ViewModel:
– UI events (button taps, form input) invoke ViewModel calls
– ViewModel exposes UI state updates (via LiveData/StateFlow) back to UI
- ViewModel <‐> Repository:
– ViewModel calls repository methods to fetch/save data
– Repository interacts with Firebase SDK or local DB
- Repository <‐> External Service:
– Reads/writes from Firebase APIs (Auth, Firestore, Storage)
– Could also read/write local cache

##### Architectural Patterns
- MVVM: clear separation of concerns
- Repository Pattern: single point of data access and syncing
- Unidirectional data flow: UI → VM → Repo → External
- Modularization: UI components, ViewModels, Repositories, Models

##### Essential Details to Capture
- All major ViewModels and which Repositories they depend on
- Core data models flowing through the layers
- External Firebase services (Auth, Database, Storage) used by specific repositories
- The navigation component (NavigationWrapper) linking UI screens

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer (UI)"
        direction TB
        MainActivity["MainActivity"]:::ui
        UIComponents["UI Components"]:::ui
        UIScreens["UI Screens"]:::ui
        NavigationWrapper["NavigationWrapper"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        direction TB
        AuthVM["AuthViewModel"]:::vm
        ChatVM["ChatViewModel"]:::vm
        DiaryVM["DiaryViewModel"]:::vm
        GroupVM["GroupViewModel"]:::vm
        LanguageVM["LanguageViewModel"]:::vm
        MissionVM["MissionViewModel"]:::vm
        StreakVM["StreakViewModel"]:::vm
        TaskVM["TaskViewModel"]:::vm
    end

    %% Repository/Data Layer
    subgraph "Repository Layer"
        direction TB
        ChatRepo["ChatRepository"]:::repo
        DiaryRepo["DiaryRepository"]:::repo
        GroupRepo["GroupRepository"]:::repo
        LanguageMgr["LanguageManager"]:::repo
        MissionRepo["MissionRepository"]:::repo
        StreakRepo["StreakRepository"]:::repo
        TaskRepo["TaskRepository"]:::repo
        UserRepo["UserRepository"]:::repo
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Firebase(("Firebase Services")):::external
    end

    %% Resources & Config
    subgraph "Configuration & Resources"
        direction TB
        AppGradle["app/build.gradle.kts"]:::config
        RootGradle["build.gradle.kts"]:::config
        ProGuard["app/proguard-rules.pro"]:::config
        Themes["themes.xml"]:::config
        Colors["colors.xml"]:::config
        Strings["strings.xml etc."]:::config
        Drawables["res/drawable/"]:::config
    end

    %% Data Flow
    MainActivity -->|"UI events"| AuthVM
    MainActivity -->|"UI events"| ChatVM
    MainActivity -->|"UI events"| DiaryVM
    MainActivity -->|"UI events"| GroupVM
    MainActivity -->|"UI events"| LanguageVM
    MainActivity -->|"UI events"| MissionVM
    MainActivity -->|"UI events"| StreakVM
    MainActivity -->|"UI events"| TaskVM

    UIComponents --> AuthVM
    UIScreens --> AuthVM

    AuthVM -->|"signIn() / signUp()"| UserRepo
    ChatVM -->|"getChat() / sendMessage()"| ChatRepo
    DiaryVM -->|"observeDiary() / saveEntry()"| DiaryRepo
    GroupVM -->|"manageGroups()"| GroupRepo
    LanguageVM -->|"getLocale() / setLocale()"| LanguageMgr
    MissionVM -->|"observeMissions()"| MissionRepo
    StreakVM -->|"observeStreaks()"| StreakRepo
    TaskVM -->|"observeTasks() / updateTask()"| TaskRepo

    UserRepo -->|"Auth API"| Firebase
    ChatRepo -->|"Firestore"| Firebase
    DiaryRepo -->|"Firestore"| Firebase
    GroupRepo -->|"Firestore"| Firebase
    LanguageMgr -->|"Local Prefs"| Firebase
    MissionRepo -->|"Firestore"| Firebase
    StreakRepo -->|"Firestore"| Firebase
    TaskRepo -->|"Firestore"| Firebase

    NavigationWrapper --> MainActivity

    %% Click Events
    click MainActivity "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/MainActivity.kt"
    click UIComponents "https://github.com/kokorikofc/tfgonitime/tree/main/app/src/main/java/com/example/tfgonitime/ui/components/"
    click UIScreens "https://github.com/kokorikofc/tfgonitime/tree/main/app/src/main/java/com/example/tfgonitime/ui/screens/"
    click NavigationWrapper "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/ui/navigation/NavigationWrapper.kt"
    click AuthVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/AuthViewModel.kt"
    click ChatVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/ChatViewModel.kt"
    click DiaryVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/DiaryViewModel.kt"
    click GroupVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/GroupViewModel.kt"
    click LanguageVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/LanguageViewModel.kt"
    click MissionVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/MissionViewModel.kt"
    click StreakVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/StreakViewModel.kt"
    click TaskVM "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/viewmodel/TaskViewModel.kt"
    click ChatRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/ChatRepository.kt"
    click DiaryRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/DiaryRepository.kt"
    click GroupRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/GroupRepository.kt"
    click LanguageMgr "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/LanguageManager.kt"
    click MissionRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/MissionRepository.kt"
    click StreakRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/StreakRepository.kt"
    click TaskRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/TaskRepository.kt"
    click UserRepo "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/java/com/example/tfgonitime/data/repository/UserRepository.kt"
    click AppGradle "https://github.com/kokorikofc/tfgonitime/blob/main/app/build.gradle.kts"
    click RootGradle "https://github.com/kokorikofc/tfgonitime/blob/main/build.gradle.kts"
    click ProGuard "https://github.com/kokorikofc/tfgonitime/blob/main/app/proguard-rules.pro"
    click Themes "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/res/values/themes.xml"
    click Colors "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/res/values/colors.xml"
    click Strings "https://github.com/kokorikofc/tfgonitime/blob/main/app/src/main/res/values/strings.xml"
    click Drawables "https://github.com/kokorikofc/tfgonitime/tree/main/app/src/main/res/drawable/"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#4A90E2,color:#000
    classDef vm fill:#DFF2BF,stroke:#8FBC00,color:#000
    classDef repo fill:#FFE0B2,stroke:#F57C00,color:#000
    classDef external fill:#E1BEE7,stroke:#8E24AA,color:#000
    classDef config fill:#F0F0F0,stroke:#999,color:#000
```
