# project-travel-mate/travel-mate architecture

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

- Interactive diagram: https://gitdiagram.com/project-travel-mate/travel-mate
- Repository: https://github.com/project-travel-mate/travel-mate

## Overview

##### Main system components
a. Presentation Layer (Android UI)
b. Domain Layer (Presenters / ViewModels)
c. Data Layer (Room Database, DAOs, Repositories)
d. Network Layer (Retrofit / API clients)
e. External Services (Weather API, Twitter API, Google Places / Maps, Email Verification Service)
f. Widgets & Background Services

##### Classes by layer and package
– Activities & Fragments (e.g., MainActivity, HomeFragment, CityFragment, TravelFragment, etc.)
– Adapters & Views (e.g., CardViewOptionsAdapter, NestedListView, FlipViewPager)
– MVP Presenters & Views (e.g., LoginPresenter / LoginView, FunFactsPresenter / FunFactsView, FinalCityInfoPresenter / FinalCityInfoView)
– ViewModels (ChecklistViewModel, ViewModelFactory)
– Room Database (AppDataBase, Converters)
– DAOs (CityDao, WidgetCheckListDao, ChecklistItemDAO)
– DataSource / Injection (ChecklistDataSource, Injection)
– Local assets (JSON under assets/, raw/)
– API definitions (ApiResources.kt)
– HTTP client (Retrofit instance injected via Injection)
– Weather API
– Twitter API
– Google Places / Maps Web Services
– Email / Auth Service (for VerifyEmailActivity)
– CheckListWidgetProvider / Service
– ClockWidget / ConfigureActivity

##### Architectural patterns
- MVP pattern in login, fun facts, city info modules (Presenter ↔ View interfaces)
- MVVM pattern in checklist module (ViewModel ↔ LiveData ↔ DAO)
- Repository / DataSource abstraction for Room + Network

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Android App"
        subgraph "Presentation Layer"
            direction TB
            MainActivity["MainActivity"]:::presentation
            HomeFragment["HomeFragment"]:::presentation
            TravelFragment["TravelFragment"]:::presentation
            CardViewOptionsAdapter["CardViewOptionsAdapter"]:::presentation
            NestedListView["NestedListView"]:::presentation
            FlipViewPager["FlipViewPager"]:::presentation
            FontTextView["FontTextView"]:::presentation
        end
        subgraph "Domain Layer"
            direction TB
            LoginPresenter["LoginPresenter"]:::domain
            LoginView["LoginView"]:::domain
            FunFactsPresenter["FunFactsPresenter"]:::domain
            FunFactsView["FunFactsView"]:::domain
            FinalCityInfoPresenter["FinalCityInfoPresenter"]:::domain
            FinalCityInfoView["FinalCityInfoView"]:::domain
            ChecklistViewModel["ChecklistViewModel"]:::domain
            ViewModelFactory["ViewModelFactory"]:::domain
        end
        subgraph "Data Layer"
            direction TB
            AppDataBase["AppDataBase"]:::db
            Converters["Converters"]:::data
            CityDao["CityDao"]:::data
            WidgetCheckListDao["WidgetCheckListDao"]:::data
            ChecklistItemDAO["ChecklistItemDAO"]:::data
            ChecklistDataSource["ChecklistDataSource"]:::data
            Injection["Injection"]:::data
            LocalAssets["Local Assets (JSON)"]:::data
        end
        subgraph "Network Layer"
            direction TB
            RetrofitClient["Retrofit Client"]:::network
            ApiResources["ApiResources"]:::network
        end
        subgraph "Widgets & Background"
            direction TB
            CheckListWidgetProvider["CheckListWidgetProvider"]:::widgets
            CheckListWidgetService["CheckListWidgetService"]:::widgets
            CheckListProvider["CheckListProvider"]:::widgets
            ClockWidget["ClockWidget"]:::widgets
            ClockWidgetConfigureActivity["ClockWidgetConfigureActivity"]:::widgets
        end
    end

    %% Presentation to Domain
    MainActivity -->|uses| LoginPresenter
    HomeFragment -->|uses| FunFactsPresenter
    TravelFragment -->|uses| FinalCityInfoPresenter
    FontTextView -->|render| LoginView

    %% Domain to Data and Network
    LoginPresenter -->|reads/writes| ChecklistDataSource
    LoginPresenter -->|calls| RetrofitClient
    FunFactsPresenter -->|reads/writes| ChecklistDataSource
    FunFactsPresenter -->|calls| RetrofitClient
    FinalCityInfoPresenter -->|reads/writes| ChecklistDataSource
    FinalCityInfoPresenter -->|calls| RetrofitClient
    ChecklistViewModel -->|reads/writes| ChecklistDataSource
    ChecklistViewModel -->|reads/writes| CityDao

    %% Data layer internal
    ChecklistDataSource -->|uses| WidgetCheckListDao
    ChecklistDataSource -->|uses| CityDao
    WidgetCheckListDao -->|persist| AppDataBase
    CityDao -->|persist| AppDataBase
    ChecklistItemDAO -->|persist| AppDataBase
    Injection -->|provides| RetrofitClient
    Injection -->|provides| ChecklistDataSource

    %% Widgets to Data
    CheckListWidgetProvider -->|reads| WidgetCheckListDao
    CheckListWidgetService -->|reads| WidgetCheckListDao
    CheckListProvider -->|reads| WidgetCheckListDao
    ClockWidget -->|reads| AppDataBase

    %% Network calls
    RetrofitClient -->|defines| ApiResources
    ApiResources -.->|weather| ExternalWeatherAPI
    ApiResources -.->|tweets| ExternalTwitterAPI
    ApiResources -.->|places/maps| ExternalMapsAPI
    ApiResources -.->|email| ExternalEmailService

    %% External Services
    ExternalWeatherAPI["Weather API"]:::external
    ExternalTwitterAPI["Twitter API"]:::external
    ExternalMapsAPI["Google Places/Maps"]:::external
    ExternalEmailService["Email Verification Service"]:::external

    %% Dependency injection to presenters
    Injection -->|inject| LoginPresenter
    Injection -->|inject| FunFactsPresenter
    Injection -->|inject| FinalCityInfoPresenter
    Injection -->|inject| ChecklistViewModel

    %% Click Events
    click MainActivity "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/MainActivity.java"
    click HomeFragment "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/HomeFragment.java"
    click TravelFragment "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/travel/TravelFragment.java"
    click CardViewOptionsAdapter "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/adapters/CardViewOptionsAdapter.java"
    click NestedListView "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/adapters/NestedListView.java"
    click FlipViewPager "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/flipviewpager/view/FlipViewPager.java"
    click FontTextView "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/views/FontTextView.java"
    click LoginPresenter "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/login/LoginPresenter.java"
    click LoginView "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/login/LoginView.java"
    click FunFactsPresenter "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/destinations/funfacts/FunFactsPresenter.java"
    click FunFactsView "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/destinations/funfacts/FunFactsView.java"
    click FinalCityInfoPresenter "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/destinations/description/FinalCityInfoPresenter.java"
    click FinalCityInfoView "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/destinations/description/FinalCityInfoView.java"
    click ChecklistViewModel "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/roompersistence/ChecklistViewModel.java"
    click ViewModelFactory "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/roompersistence/ViewModelFactory.java"
    click AppDataBase "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/database/AppDataBase.java"
    click Converters "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/database/Converters.java"
    click CityDao "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/dao/CityDao.java"
    click WidgetCheckListDao "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/dao/WidgetCheckListDao.java"
    click ChecklistItemDAO "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/roompersistence/ChecklistItemDAO.java"
    click ChecklistDataSource "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/roompersistence/ChecklistDataSource.java"
    click Injection "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/io/github/project_travel_mate/roompersistence/Injection.java"
    click ApiResources "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/objects/ApiResources.kt"
    click CheckListWidgetProvider "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/widget/CheckListWidgetProvider.java"
    click CheckListWidgetService "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/widget/CheckListWidgetService.java"
    click CheckListProvider "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/widget/CheckListProvider.java"
    click ClockWidget "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/widget/ClockWidget.java"
    click ClockWidgetConfigureActivity "https://github.com/project-travel-mate/travel-mate/blob/master/Android/app/src/main/java/widget/ClockWidgetConfigureActivity.java"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000
    classDef domain fill:#90EE90,stroke:#000
    classDef data fill:#FFA500,stroke:#000
    classDef network fill:#D8BFD8,stroke:#000
    classDef widgets fill:#20B2AA,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000
    classDef db fill:#FFA500,stroke:#000,shape:cylinder
```
