# hassieeeee/webrtc-drop-2os architecture

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

- Interactive diagram: https://gitdiagram.com/hassieeeee/webrtc-drop-2os
- Repository: https://github.com/hassieeeee/webrtc-drop-2os

## Overview

##### Component Identification
a. Flutter Application (Core App):
- UI Layer – Represented by the contents of the lib/screens and lib/widgets directories. These handle user interactions including screens for scanning, sharing files, and informing the user if Bluetooth is off.
- Business Logic / Service Layer – Represented by the lib/utils directory. Key functionalities here likely include device info retrieval, signaling (WebRTC), peripheral management, and other utilities.
b. Platform-Specific Layers:
- Native code and configurations for Android (android directory), iOS (ios directory), macOS (macos directory), Windows (windows directory), and Linux (linux directory). These ensure that the Flutter code can interface with platform-specific services (e.g., accessing the native Bluetooth stack or network functionalities).
- Web-specific configuration files in the web directory.
c. External Interactions:
- Signaling server/Network services (implied by the signaling.dart file) for managing WebRTC connections.
- Underlying networking and potentially BLE stacks provided by each OS’s native capabilities.

##### Relationships and Interactions
- From the Business Logic layer, illustrate connections toward native platform channels. This represents how Flutter communicates with platform-specific APIs (implemented in the native directories) for low-level operations such as file access, Bluetooth operations, or even rendering on each platform.
- A connection between the Business Logic (specifically the signaling component) and external/signaling services for establishing peer-to-peer connections.

##### Architectural Patterns and Principles
- The overall architecture follows a layered approach (UI, business logic, native services) along with the use of platform channels to mediate between Flutter and native code.
- Separation of concerns by showing a clear boundary between platform-independent Dart code and platform-dependent native code.
- If there is any usage of Flutter plugins for WebRTC or Bluetooth, mention that these abstract away the platform-specific implementations while providing a common API in the Flutter layer.

##### Relevant Technologies and Frameworks
- Flutter (Dart) as the core framework for the UI and application logic.
- Platform channels for communicating with Android (Kotlin), iOS (Swift/Objective-C), macOS, Windows, and Linux subsystems.
- WebRTC libraries and possibly BLE frameworks (as suggested by file naming) for facilitating peer-to-peer file transfer.
- Build and dependency management files (such as pubspec.yaml, build.gradle, Podfile, and CMakeLists.txt) indicate the integration and configuration of these platform-specific and cross-platform components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Flutter Core App"
        subgraph "UI Layer"
            Screens["Screens (UI)"]:::ui
            Widgets["Widgets (UI)"]:::ui
        end
        subgraph "Business Logic Layer"
            BusinessLogic["Business Logic & Utilities"]:::logic
        end
    end

    subgraph "Native Layers"
        subgraph "Android Native"
            AndroidBLE["Android BLE"]:::native
            AndroidWebRTC["Android WebRTC"]:::native
        end
        iOSNative["iOS Native Layer"]:::native
        macOSNative["macOS Native Layer"]:::native
        LinuxNative["Linux Native Layer"]:::native
        WindowsNative["Windows Native Layer"]:::native
        WebConfig["Web Configuration"]:::native
    end

    ExternalSignaling["Signaling Server"]:::external

    Screens -->|"triggers"| BusinessLogic
    Widgets -->|"triggers"| BusinessLogic

    BusinessLogic -->|"callsBLE"| AndroidBLE
    BusinessLogic -->|"callsWebRTC"| AndroidWebRTC
    BusinessLogic -->|"callsNative"| iOSNative
    BusinessLogic -->|"callsNative"| macOSNative
    BusinessLogic -->|"callsNative"| LinuxNative
    BusinessLogic -->|"callsNative"| WindowsNative
    BusinessLogic -->|"callsNative"| WebConfig
    BusinessLogic -->|"signal"| ExternalSignaling

    click Screens "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/lib/screens"
    click Widgets "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/lib/widgets"
    click BusinessLogic "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/lib/utils"
    click AndroidBLE "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/android/app/src/main/kotlin/com/example/cross_os_ble_demo"
    click AndroidWebRTC "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/android/app/src/main/kotlin/com/example/webrtc_drop_2os"
    click iOSNative "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/ios"
    click macOSNative "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/macos"
    click LinuxNative "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/linux"
    click WindowsNative "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/windows"
    click WebConfig "https://github.com/hassieeeee/webrtc-drop-2os/tree/main/web"

    classDef ui fill:#bbf,stroke:#333,stroke-width:2px;
    classDef logic fill:#bfb,stroke:#333,stroke-width:2px;
    classDef native fill:#fbb,stroke:#333,stroke-width:2px;
    classDef external fill:#ff9,stroke:#333,stroke-width:2px;
```
