# victorhvs/trading-fight-club-mobile architecture

> Architecture diagram of the GitHub repository victorhvs/trading-fight-club-mobile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/victorhvs/trading-fight-club-mobile
- Repository: https://github.com/victorhvs/trading-fight-club-mobile

## Overview

##### Project type and purpose
- This is a full-stack Android mobile application (TradingFight.club) built in Kotlin using Modern Android development (Jetpack Compose, Coroutines, Paging).
- Its purpose is to deliver a financial social network: display stock data, user profiles, rankings, portfolios, and allow buy/sell actions, all backed by Firebase.

##### File structure
- Top-level “app/” module holds the Android application code.
- src/main/java/com/victorhvs/tfc:
– core: shared utilities (DispatcherProvider for Coroutines, Resource/State wrappers).
– data: data-layer (datasources, paging, DI, extensions, fake for tests, repository implementations).
– domain: clean-architecture boundary (models, enums, repository interfaces, use-cases).
– presentation: UI-layer (Compose screens, components, ViewModels, navigation graphs, theming, extensions).
- src/test & src/androidTest: unit and instrumentation tests using fake datasources and CoroutinesRule.
- Build files: Gradle Kotlin DSL, Proguard rules.
- CI: .github/workflows/tfc.yml, common GitHub-Action steps.
- Config: detekt, lint rules.

##### README for additional insights
- MVP features map to screens: Splash, Home, Stocks, Ranking, Profile, Stock Detail, Search.
- CI/CD via GitHub Actions is in place.

a. Main components
- Android Client App
– Presentation Layer (Compose Screens & ViewModels)
– Domain Layer (Use-Cases & Interfaces)
– Data Layer (Repositories & DataSources)
– Dependency Injection module (DI.kt)
- External Services
– Firebase Firestore (stocks, rankings, profiles)
– Firebase Authentication
- (Optional) Local device storage or caching if any (not present, but mention Room if added)
- CI/CD Pipeline (GitHub Actions)

b. Relationships & interactions
- User taps UI → Compose Screen invokes ViewModel
- ViewModel calls appropriate Use-Case
- Use-Case calls Repository interface
- Repository implementation uses DataSource to fetch from Firebase (or FakeDataSource for tests)
- DataSource returns domain models via Coroutines Flow/LiveData
- DI module wires ViewModels → Use-Cases → Repositories → DataSources
- CI/CD workflow triggers build/test on commit → deploy to Play Store placeholder

c. Architectural patterns & principles
- Clean Architecture / MVVM
- Single-Activity, multiple Compose-based screens (Navigation Graph)
- Separation of Concerns: Presentation / Domain / Data
- Coroutines DispatcherProvider for testable threading
- Repository Pattern, Paging 3 for infinite scroll
- Dependency Injection (manual DI via DI.kt)

d. Key technologies & frameworks
- Kotlin, Jetpack Compose, AndroidX Navigation, Paging 3
- Firebase Firestore & Auth
- Coroutines & Flow
- JUnit + AndroidX Test + CoroutinesRule for testing
- GitHub Actions for CI/CD
- Detekt & lint for static analysis

##### Detailed capture of essential elements
- Don’t simply list classes; group them by layer and responsibility.
- MVVM flow and Clean Architecture boundaries.
- Test harness path (FakeDataSource) branching off the Data layer.

Summary:

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "Presentation Layer"
        direction TB
        MA["MainActivity"]:::presentation
        UIS["Compose Screens & ViewModels"]:::presentation
        NC["Navigation Graphs"]:::presentation
        UC["UI Components"]:::presentation
        TH["Theming"]:::presentation
    end

    subgraph "Domain Layer"
        direction TB
        UCAS["Use-Cases"]:::domain
        RINT["Repository Interfaces"]:::domain
        MOD["Models & Enums"]:::domain
    end

    subgraph "Data Layer"
        direction TB
        REPO["Repository Implementations"]:::data
        DS["Firestore DataSource"]:::data
        PS["Paging Source"]:::data
        FAKE["Fake DataSource"]:::data
        EXT["Extensions"]:::data
    end

    subgraph "External Services"
        direction TB
        FAUTH[(Firebase Auth)]:::external
        FSTORE[(Firebase Firestore)]:::external
    end

    DI{"DI Module"}:::di
    CI[/CI/CD Pipeline/]:::pipeline
    GHA["GitHub Actions"]:::pipeline
    BUILD["Build"]:::pipeline
    TEST["Test"]:::pipeline
    DEPLOY["Deploy"]:::pipeline

    %% Flows
    MA -->|"invoke ViewModel"| UIS
    UIS -->|"calls Use-Case"| UCAS
    UCAS -->|"uses Interface"| RINT
    RINT -->|"impl by"| REPO
    REPO -->|"fetches via"| DS
    PS -->|"pages data from"| FSTORE
    DS -->|"queries"| FSTORE
    DS -->|"auth via"| FAUTH
    FAKE -.-> REPO

    %% DI Connections
    DI --> MA
    DI --> UCAS
    DI --> REPO
    DI --> DS

    %% CI/CD Flow
    CI --> GHA
    GHA --> BUILD
    BUILD --> TEST
    TEST --> DEPLOY

    %% Click Events
    click MA "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/presentation/MainActivity.kt"
    click UIS "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/presentation/screens"
    click UC "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/presentation/components"
    click NC "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/presentation/navigation"
    click TH "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/presentation/theme"
    click UCAS "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/domain/use_case"
    click RINT "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/domain/repository"
    click MOD "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/domain/models"
    click REPO "https://github.com/victorhvs/trading-fight-club-mobile/tree/main/app/src/main/java/com/victorhvs/tfc/data/repository"
    click DS "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/data/datasource/FirebaseDataSource.kt"
    click PS "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/data/datasource/FirebaseStocksPagingSource.kt"
    click FAKE "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/data/fake/FakeDataSource.kt"
    click EXT "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/data/extensions/QueryExtensions.kt"
    click DI "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/app/src/main/java/com/victorhvs/tfc/data/di/DI.kt"
    click GHA "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/.github/workflows/tfc.yml"
    click CI "https://github.com/victorhvs/trading-fight-club-mobile/blob/main/.github/actions/common-steps/action.yml"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000
    classDef domain fill:#90EE90,stroke:#000
    classDef data fill:#FFA500,stroke:#000
    classDef external fill:#D3D3D3,stroke:#000
    classDef di fill:#FFB6C1,stroke:#000,stroke-dasharray: 5 5
    classDef pipeline fill:#E6E6FA,stroke:#000,shape:parallelogram
```
