# chrisbanes/tivi architecture

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

- Interactive diagram: https://gitdiagram.com/chrisbanes/tivi
- Repository: https://github.com/chrisbanes/tivi

## Overview

##### High-Level Architecture Components

- Client Layer |     |  Domain Layer |     |   Data Layer  |
- (UI Modules)  | --> |  (Use Cases)  | --> | (Repositories)|

##### Platform-Specific Components

Create three parallel tracks for different platforms:
**Android App    iOS App    Desktop App**
- ↓             ↓           ↓
**Shared Kotlin Multiplatform Code Base**

##### Core Components Breakdown

a) UI Layer (common/ui/*)

- UI Modules    |

- Account         |
- Search          |
- Show Details    |
- Episodes        |
- Settings        |

b) Data Layer

- Data Sources   |

- Trakt.tv API    |
- TMDb API        |
- Local Database  |

##### Key Architectural Features

- UI Components | --> | Presenters   | --> |  Domain Layer |
- (Compose UI)  |     | (Circuit)    |     |  (Interactors)|

- ↑                                           ↓

- Platform UI   | --> | Shared State | <-- |  Repositories  |
- Components    |     | Management   |     |  & Data Sources|

##### Data Flow Patterns

Flow:
**User Action → Presenter → Interactor → Repository → Data Source**
- ↑          ↓           ↓            ↓            ↓
**UI State ← State Update ← Result ← Transformed Data ← Raw Data**

##### Cross-Cutting Concerns

Shared services:

- Common Services              |

- Analytics                              |
- Logging                                |
- Authentication                         |
- Image Loading                          |
- Notifications                          |

##### Important Implementation Details

- Kotlin Multiplatform shared code
- Compose Multiplatform UI
- SQLDelight database
- Platform-specific implementations
- Dependency injection structure

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph ClientLayer["Client Layer"]
        direction TB
        Android["Android App"]
        iOS["iOS App"]
        Desktop["Desktop App"]
        
        subgraph UIModules["UI Modules"]
            direction TB
            Account["Account UI"]:::ui
            Search["Search UI"]:::ui
            ShowDetails["Show Details UI"]:::ui
            Episodes["Episodes UI"]:::ui
            Settings["Settings UI"]:::ui
        end
    end

    subgraph DomainLayer["Domain Layer"]
        direction TB
        Interactors["Interactors"]:::domain
        Observers["Observers"]:::domain
        Presenters["Presenters (Circuit)"]:::domain
    end

    subgraph DataLayer["Data Layer"]
        direction TB
        Database["Local Database"]:::data
        TraktAPI["Trakt.tv API"]:::external
        TMDbAPI["TMDb API"]:::external
        Models["Data Models"]:::data
    end

    subgraph SharedServices["Common Services"]
        direction TB
        Analytics["Analytics"]:::service
        Logging["Logging"]:::service
        Auth["Authentication"]:::service
        ImageLoading["Image Loading"]:::service
        Notifications["Notifications"]:::service
    end

    subgraph SharedComponents["Shared Components"]
        direction TB
        UIComponents["UI Components"]:::ui
        Resources["Resources"]:::ui
    end

    %% Relationships
    Android & iOS & Desktop --> UIModules
    UIModules --> Presenters
    Presenters --> Interactors
    Interactors --> DataLayer
    Observers --> DataLayer
    UIModules --> SharedComponents
    DataLayer --> SharedServices

    %% Styles
    classDef ui fill:#2196F3,color:white
    classDef domain fill:#4CAF50,color:white
    classDef data fill:#FFC107,color:black
    classDef external fill:#FF5252,color:white
    classDef service fill:#9E9E9E,color:white

    %% Click Events
    click Account "https://github.com/chrisbanes/tivi/tree/main/ui/account/src/commonMain/kotlin/app/tivi/account"
    click Search "https://github.com/chrisbanes/tivi/tree/main/ui/search/src/commonMain/kotlin/app/tivi/home/search"
    click ShowDetails "https://github.com/chrisbanes/tivi/tree/main/ui/show/details/src/commonMain/kotlin/app/tivi/showdetails/details"
    click Episodes "https://github.com/chrisbanes/tivi/tree/main/ui/episode/details/src/commonMain/kotlin/app/tivi/episodedetails"
    click Settings "https://github.com/chrisbanes/tivi/tree/main/ui/settings/src/commonMain/kotlin/app/tivi/settings"
    click Interactors "https://github.com/chrisbanes/tivi/tree/main/domain/src/commonMain/kotlin/app/tivi/domain/interactors"
    click Observers "https://github.com/chrisbanes/tivi/tree/main/domain/src/commonMain/kotlin/app/tivi/domain/observers"
    click Database "https://github.com/chrisbanes/tivi/tree/main/data/db-sqldelight/src/commonMain/kotlin/app/tivi/data"
    click TraktAPI "https://github.com/chrisbanes/tivi/tree/main/api/trakt/src/commonMain/kotlin/app/tivi/trakt"
    click TMDbAPI "https://github.com/chrisbanes/tivi/tree/main/api/tmdb/src/commonMain/kotlin/app/tivi/tmdb"
    click Models "https://github.com/chrisbanes/tivi/tree/main/data/models/src/commonMain/kotlin/app/tivi/data/models"
    click Analytics "https://github.com/chrisbanes/tivi/tree/main/core/analytics/src/commonMain/kotlin/app/tivi/core/analytics"
    click Logging "https://github.com/chrisbanes/tivi/tree/main/core/logging/src/commonMain/kotlin/app/tivi/util"
    click Auth "https://github.com/chrisbanes/tivi/tree/main/data/traktauth/src/commonMain/kotlin/app/tivi/data/traktauth"
    click ImageLoading "https://github.com/chrisbanes/tivi/tree/main/common/imageloading/src/commonMain/kotlin/app/tivi/common/imageloading"
    click Notifications "https://github.com/chrisbanes/tivi/tree/main/core/notifications/core/src/commonMain/kotlin/app/tivi/core/notifications"
    click UIComponents "https://github.com/chrisbanes/tivi/tree/main/common/ui/compose/src/commonMain/kotlin/app/tivi/common/compose"
    click Resources "https://github.com/chrisbanes/tivi/tree/main/common/ui/resources/src/commonMain/kotlin/app/tivi/common/ui/resources"
```
