# netguru/videochatguru-android architecture

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

- Interactive diagram: https://gitdiagram.com/netguru/videochatguru-android
- Repository: https://github.com/netguru/videochatguru-android

## Overview

Based on our analysis of the file tree and README, VideoChatGuru is an open‐source Kotlin-based Android library that wraps the native WebRTC API. It includes a library module (found under the “videochatguru” directory) that implements core WebRTC functionality and a sample application (located in “sample”) that demonstrates a complete video chat solution (Chat&Roll) using Firebase for signaling.

##### Main Components
- VideoChatGuru Library Module – This is the core of the project and provides a friendlier abstraction over the native WebRTC API. Key classes here include the WebRtcClient found in the videochatguru package and other related observers and utilities.
- Sample Application – Under the “sample” directory you have the Android app that demonstrates the usage of VideoChatGuru. It contains typical Android layers (Activities, Fragments such as BaseActivity, BaseFragment, and specialized functionality for video handling) and custom DI setups.
- WebRTC Signaling and Connectivity Components – In the sample app, Firebase is used for signaling. This includes data handling classes (for ICE candidates, offers/answers, etc.) and the Firebase modules that manage ICE server configurations.
- External Services – These include Firebase (for real‑time database signaling), and the external STUN/TURN servers used for establishing peer-to-peer connections.

##### Relationships and Interactions
- The Sample Application’s UI (Activities/Fragments) interacts with the WebRtcClient from the VideoChatGuru library.
- The WebRtcClient initiates peer connections by communicating with native WebRTC service components (like those present in “webrtc/service”) and handling callbacks (observer patterns with PeerConnectionListener, Sdp observers, etc.).
- When establishing a connection, the WebRtcClient interacts with external ICE servers (STUN and TURN) and uses Firebase to exchange signaling messages such as ICE candidates and session descriptions.
- Dependency Injection components (e.g., ApplicationComponent, ApplicationModule in the sample’s “app” package) wire up the various parts and services within the sample.

##### Architectural Patterns and Design Principles
- Modular Architecture – There is a clear separation between the reusable VideoChatGuru library and the sample app.
- MVP / MV* Patterns – The sample uses BaseMvpActivity / BaseMvpFragment along with setup in Presenter and View interfaces to structure the UI business logic.
- Dependency Injection – Observed by the presence of di packages and custom scopes (ActivityScope, FragmentScope, ServiceScope).
- Use of Observer Callbacks – WebRTC communication is handled via various observer listeners and callbacks.

##### Relevant Technologies and Frameworks
- Kotlin is the primary language.
- WebRTC API is wrapped and abstracted by VideoChatGuru.
- Firebase is used for real-time signaling.
- Gradle’s multi-module build system is in use.
- Android UI components (Activities, Fragments, Services) form the presentation layer.

##### Attention to Detail
- Component’s interactions are clearly shown. For example, highlight that the WebRtcClient encapsulates both peer connection initiation and observer callbacks.
- Dependency injection in the sample by indicating DI modules that wire up the UI and the library classes.
- Adding note labels that reference key files or directories (e.g., “sample/src/main/java/co/netguru/android/chatandroll/…”) if needed, to assist new developers in locating implementations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Sample Application Layer
    subgraph "Sample Application Layer"
        UI["Chat&Roll UI (Activities/Fragments)"]:::ui
        DI["DI Components"]:::di
    end

    %% VideoChatGuru Library Layer
    subgraph "VideoChatGuru Library"
        LIB["VideoChatGuru Library Module"]:::lib
        WRTC["WebRtcClient & Observer Components"]:::libDetail
        LIB -->|"contains"| WRTC
    end

    %% Sample WebRTC Service Layer
    subgraph "Sample WebRTC Service"
        RTC["WebRtc Connectivity Service"]:::service
    end

    %% External Services
    subgraph "External Services"
        FBS["Firebase Signaling Service"]:::external
        ICE["STUN/TURN Servers"]:::external
    end

    %% Connections between layers
    DI -->|"wires"| UI
    DI -->|"wires"| WRTC
    UI -->|"calls"| WRTC
    WRTC -->|"invokes"| RTC
    WRTC -->|"signals"| FBS
    WRTC -->|"connects"| ICE

    %% Click Events for Component Mapping
    click LIB "https://github.com/netguru/videochatguru-android/tree/master/videochatguru/src/main/java/co/netguru/videochatguru"
    click WRTC "https://github.com/netguru/videochatguru-android/blob/master/videochatguru/src/main/java/co/netguru/videochatguru/WebRtcClient.kt"
    click UI "https://github.com/netguru/videochatguru-android/tree/master/sample/src/main/java/co/netguru/android/chatandroll"
    click DI "https://github.com/netguru/videochatguru-android/tree/master/sample/src/main/java/co/netguru/android/chatandroll/app"
    click DI "https://github.com/netguru/videochatguru-android/tree/master/sample/src/main/java/co/netguru/android/chatandroll/common/di"
    click RTC "https://github.com/netguru/videochatguru-android/tree/master/sample/src/main/java/co/netguru/android/chatandroll/webrtc/service"
    click FBS "https://github.com/netguru/videochatguru-android/tree/master/sample/src/main/java/co/netguru/android/chatandroll/data/firebase"

    %% Styles
    classDef ui fill:#FFCCCC,stroke:#333,stroke-width:2px;
    classDef di fill:#FFFFCC,stroke:#333,stroke-width:2px;
    classDef lib fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef libDetail fill:#CCFFDD,stroke:#333,stroke-width:2px;
    classDef service fill:#CCE5FF,stroke:#333,stroke-width:2px;
    classDef external fill:#FFEECC,stroke:#333,stroke-width:2px;
```
