# apptolast/familyfilmapp architecture

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

- Interactive diagram: https://gitdiagram.com/apptolast/familyfilmapp
- Repository: https://github.com/apptolast/familyfilmapp

## Overview

##### Main Components
- App (Client-side Android Application):
– UI Layer: Built with Jetpack Compose, includes screens (home, login, groups, movie details, profile, search, recommend, etc.) and UI components (dialogs, cards, navigation bars).
– ViewModel Layer: Implements the MVVM pattern using StateFlow, Coroutines, and exposes state for the views.
– Domain/Use Case Layer: Contains business logic for filtering movie recommendations, handling login/registration flows, and group management.
– Repository Layer: Defines separate repositories (BackendRepository, FirebaseRepository, LocalRepository) that abstract data sources (remote API calls via Retrofit and local data management).
– Network Layer: Makes API calls using Retrofit; includes modules like ApiRoutes, BackendApi, and interceptors (e.g., AuthInterceptor).
– DI/Modularization: Dependency Injection is implemented using Hilt, as seen by the various modules (ApplicationModule, FirebaseModule, GoogleSignInModule, LocalStoreModule, NetworkModule, RepositoryModule) to decouple the components.

- External Services:
– Backend API: Externally hosted REST API built with Express/NodeJS that handles authentication and movie data operations.
– Firebase: Provides authentication (Firebase Auth using email/password and Google Sign-In) and Crashlytics for error reporting.

##### Relationships and Interactions
- The UI components trigger user actions that are handled by ViewModels.
- ViewModels call Use Cases which encapsulate business logic.
- Use Cases interact with different repositories:
– The BackendRepository accesses the RESTful API (using Retrofit) to handle server-side data.
– The FirebaseRepository interacts with Firebase services to handle user authentication and potentially other user-specific data.
– The LocalRepository may be used for managing cached or persistent data.
- Dependency Injection (via Hilt) wires all these components together, ensuring a loose coupling.
- External interactions include:
– The application sending requests to the backend API (secured using an authentication token acquired via Firebase).
– Firebase handling user identity and providing error reporting through Crashlytics.

##### Architectural Patterns and Design Principles
- MVVM: Clear separation between view, state management, and business logic.
- Reactive State Management: Use of Flow and Coroutines for updating the UI in response to data changes.
- Dependency Injection: Hilt is used to inject dependencies into components, facilitating testing and modularity.
- Clean Architecture principles by isolating the presentation, domain, and data layers.

##### Relevant Technologies
- Frontend (Android App): Jetpack Compose, Kotlin, Coroutines, StateFlow, Navigation Component.
- Networking: Retrofit, possibly with Gson for JSON conversion.
- DI: Hilt.
- Firebase APIs: Authentication and Crashlytics.
- Backend Components (External): NodeJS with Express (TypeScript), PostgreSQL, Docker, Render for deployment.

- Detailed labels and notes about the technologies (e.g., “Retrofit for API calls”, “Hilt DI for dependency management”, “Flow & Coroutines for reactive state management”).
- Essential interactions, ensuring that even less visible modules (like custom exception handling, navigation type modules) are indicated as part of the overall system if needed.
- Clear separation between Android-specific logic and external services to give an end-to-end view of how the system components come together.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Client Application"
        %% Presentation Layer
        subgraph "Presentation Layer"
            UI["UI Layer (Jetpack Compose)\nScreens & Components"]:::presentation
            VM["ViewModel Layer (StateFlow, Coroutines)"]:::presentation
            UI -->|"triggers"| VM
        end

        %% Domain Layer
        subgraph "Domain Layer"
            UC["Use Case Layer\n(Business Logic)"]:::domain
            VM -->|"calls"| UC
        end

        %% Data Layer
        subgraph "Data Layer"
            Repo["Repository Layer\n(BackendRepository, FirebaseRepository, LocalRepository)"]:::data
            Net["Network Layer\n(Retrofit, ApiRoutes, BackendApi)"]:::data
            UC -->|"invokes"| Repo
            Repo -->|"makes calls"| Net
        end

        %% Dependency Injection
        DI["DI Modules (Hilt)"]:::di
        DI --- UI
        DI --- VM
        DI --- UC
        DI --- Repo
        DI --- Net
    end

    subgraph "External Services"
        BA["Backend API\n(Express, PostgreSQL, Docker, Render)"]:::external
        FB["Firebase\n(Authentication & Crashlytics)"]:::external
        Net -->|"REST_calls"| BA
        Repo -->|"auth/data"| FB
    end

    %% Click Events
    click UI "https://github.com/apptolast/familyfilmapp/tree/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/ui"
    click VM "https://github.com/apptolast/familyfilmapp/blob/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/ui/screens/home/HomeViewModel.kt"
    click UC "https://github.com/apptolast/familyfilmapp/blob/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/BaseUseCase.kt"
    click Repo "https://github.com/apptolast/familyfilmapp/tree/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/repositories"
    click Net "https://github.com/apptolast/familyfilmapp/tree/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/network"
    click DI "https://github.com/apptolast/familyfilmapp/tree/develop-spring/app/src/main/java/com/apptolast/familyfilmapp/di"

    %% Styles
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef domain fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef data fill:#fffacd,stroke:#000,stroke-width:2px;
    classDef di fill:#ffa07a,stroke:#000,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#000,stroke-width:2px;
```
