# moseoridev/warpshare architecture

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

- Interactive diagram: https://gitdiagram.com/moseoridev/warpshare
- Repository: https://github.com/moseoridev/warpshare

## Overview

##### Main Components
- UI Layer:
– Activities (e.g., MainActivity, AboutActivity, SettingsActivity, SetupActivity, ShareActivity)
– Fragments (e.g., SettingsFragment, ShareBottomSheetFragment)
– UI Themes and resources (found in the “res” subdirectories for layouts, drawables, values, etc.)

- Application & Business Logic Layer:
– Application class (WarpShareApplication) initializes global settings
– Service components (ReceiverService, InitializeReceiver, SelfBroadcastReceiver, TriggerReceiver)
– Managers/Controllers handling file transfer and network interactions. These include:
▪ AirDrop-related classes (AirDropManager, AirDropClient, AirDropServer, AirDropBleController, AirDropNsdController, AirDropWlanController, etc.)
▪ Nearby Sharing (NearShareManager, NearSharePeer)
▪ WiFi Direct (AndroidWifiP2pController, AndroidNsdController, AndroidbluetoothLeController, P2PwifiManager, WifiP2pPeer)
▪ Base communication (classes in the “base” package for handling peers, sessions, sending routines)
▪ Certificate management (CertificateManager and CustomTrust in the “certificate” folder)

- Network and State Monitoring Components:
– Monitors like BluetoothStateMonitor and WifiStateMonitor
– Various controllers that handle connection discovery using AWDL-like protocols (as noted in the README)

- Configuration & Assets:
– Gradle build files, AndroidManifest.xml and resources like keystore, CA certificates, and asset keys provide the deployment configuration and security certificates used during the file transfer.

##### Relationships and Interactions
- User Actions in the UI Layer (e.g., selecting files, initiating a transfer) propagate events to the Application Layer.
- The Application Layer orchestrates file transfers by invoking methods from the AirDropManager and related sub-modules in the “airdrop”, “base”, “certificate”, “nearbysharing”, and “wifip2p” packages.
- Background services (ReceiverService etc.) handle asynchronous, event-driven messaging and system broadcasts (via InitializeReceiver, SelfBroadcastReceiver, TriggerReceiver).
- Network state monitors (BluetoothStateMonitor, WifiStateMonitor) capture connectivity changes and direct traffic to the appropriate network controller modules (e.g., AirDropBleController, AndroidWifiP2pController).
- Secure communications are managed via certificate and trust configurations ensuring that file transfers meet security criteria.

##### Architectural Patterns
- Layered structure typical in Android apps (UI → Business Logic → Network/Hardware interface).
- Separation of concerns: UI and presentation layers are clearly decoupled from the service and business logic (managers, controllers and monitors).
- Event-driven processing is evident in the use of broadcast receivers and services.
- Modular design with distinct subpackages for AirDrop functionality, base communication, certificate security, and connectivity protocols.

##### Relevant Technologies and Frameworks
- Android SDK components (Activities, Services, BroadcastReceivers).
- Gradle for build configuration.
- Java and Kotlin, as both languages are represented in the project.
- Standard Android resource management (layouts, values, drawables, XML configuration files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        MA["MainActivity"] 
        AA["AboutActivity"] 
        SA["SettingsActivity"] 
        SUA["SetupActivity"] 
        SHA["ShareActivity"] 
        SF["SettingsFragment"] 
        SBSF["ShareBottomSheetFragment"] 
        UIT["UI Themes & Resources"]
    end

    subgraph "Application & Business Logic Layer"
        WSA["WarpShareApplication"]
        RS["ReceiverService"]
        IR["InitializeReceiver"]
        SBR["SelfBroadcastReceiver"]
        TR["TriggerReceiver"]
    end

    subgraph "AirDrop Module"
        ADM["AirDropManager"]
        ABLE["AirDropBleController"]
        AC["AirDropClient"]
        AS["AirDropServer"]
        ANSD["AirDropNsdController"]
        AWLAN["AirDropWlanController"]
    end

    subgraph "Nearby Sharing Module"
        NSM["NearShareManager"]
        NSP["NearSharePeer"]
    end

    subgraph "WiFi Direct & Network Controllers"
        AWPC["AndroidWifiP2pController"]
        ANDC["AndroidNsdController"]
        ABLETC["AndroidbluetoothLeController"]
        P2PWM["P2PwifiManager"]
        WPP["WifiP2pPeer"]
    end

    subgraph "Base Communication Components"
        BC["Base Communication (Discover, Peer, Sender, etc.)"]
    end

    subgraph "Certificate Management"
        CM["CertificateManager"]
        CT["CustomTrust"]
    end

    subgraph "Network & State Monitoring"
        BSM["BluetoothStateMonitor"]
        WSM["WifiStateMonitor"]
    end

    subgraph "Configuration & Assets"
        GC["Gradle & Build Config"]
        AM["AndroidManifest & Assets"]
        SC["Security Certificates & Keystore"]
    end

    %% Relationships
    MA -->|"UserAction"| WSA
    AA -->|"UserAction"| WSA
    SA -->|"UserAction"| WSA
    SUA -->|"UserAction"| WSA
    SHA -->|"UserAction"| WSA

    WSA -->|"Initializes"| RS
    WSA -->|"Initializes"| IR
    WSA -->|"Initializes"| SBR
    WSA -->|"Initializes"| TR
    WSA -->|"Invokes"| ADM
    WSA -->|"Invokes"| NSM
    WSA -->|"Invokes"| AWPC
    WSA -->|"Invokes"| CM

    RS -->|"HandlesBackground"| ADM

    ADM -->|"ManagesBLE"| ABLE
    ADM -->|"ManagesClient"| AC
    ADM -->|"ManagesServer"| AS
    ADM -->|"ManagesNSD"| ANSD
    ADM -->|"ManagesWLAN"| AWLAN

    NSM -->|"ManagesPeer"| NSP

    AWPC -->|"UsesNSD"| ANDC
    AWPC -->|"UsesBLE"| ABLETC
    AWPC -->|"CoordinatesP2P"| P2PWM
    AWPC -->|"CoordinatesPeer"| WPP

    RS -->|"Uses"| BC

    BSM -->|"MonitorsBLE"| ABLE
    WSM -->|"MonitorsWiFi"| AWPC

    CM -->|"Secures"| ADM
    CM -->|"Secures"| NSM

    ADM -->|"UpdatesUI"| MA
    NSM -->|"UpdatesUI"| MA

    GC --> AM
    AM -->|"Deployment"| SC

    UIT --> MA
    UIT --> SA
    UIT --> SHA

    %% Click Events for UI Layer
    click MA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/MainActivity.java"
    click AA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/AboutActivity.kt"
    click SA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/SettingsActivity.java"
    click SUA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/SetupActivity.java"
    click SHA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/ShareActivity.java"
    click SF "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/SettingsFragment.java"
    click SBSF "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/ShareBottomSheetFragment.java"
    click UIT "https://github.com/moseoridev/warpshare/tree/master/app/src/main/java/org/mokee/warpshare/ui/theme"

    %% Click Events for Application & Business Logic Layer
    click WSA "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/WarpShareApplication.java"
    click RS "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/ReceiverService.java"
    click IR "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/InitializeReceiver.java"
    click SBR "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/SelfBroadcastReceiver.java"
    click TR "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/TriggerReceiver.java"

    %% Click Events for AirDrop Module
    click ADM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropManager.java"
    click ABLE "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropBleController.java"
    click AC "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropClient.java"
    click AS "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropServer.java"
    click ANSD "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropNsdController.java"
    click AWLAN "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/airdrop/AirDropWlanController.java"

    %% Click Events for Nearby Sharing Module
    click NSM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/nearbysharing/NearShareManager.java"
    click NSP "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/nearbysharing/NearSharePeer.java"

    %% Click Events for WiFi Direct & Network Controllers
    click AWPC "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/wifip2p/AndroidWifiP2pController.java"
    click ANDC "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/wifip2p/AndroidNsdController.java"
    click ABLETC "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpsare/wifip2p/AndroidbluetoothLeController.java"
    click P2PWM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/wifip2p/P2PwifiManager.java"
    click WPP "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/wifip2p/WifiP2pPeer.java"

    %% Click Events for Certificate Management
    click CM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/certificate/CertificateManager.java"
    click CT "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/certificate/CustomTrust.java"

    %% Click Events for Network & State Monitoring
    click BSM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/BluetoothStateMonitor.java"
    click WSM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/java/org/mokee/warpshare/WifiStateMonitor.java"

    %% Click Events for Configuration & Assets
    click AM "https://github.com/moseoridev/warpshare/blob/master/app/src/main/AndroidManifest.xml"

    %% Styles
    classDef ui fill:#f9f,stroke:#333,stroke-width:2px;
    classDef logic fill:#bbf,stroke:#333,stroke-width:2px;
    classDef module fill:#cfc,stroke:#333,stroke-width:2px;
    classDef network fill:#fc9,stroke:#333,stroke-width:2px;
    classDef asset fill:#cff,stroke:#333,stroke-width:2px;

    class MA,AA,SA,SUA,SHA,SF,SBSF,UIT ui;
    class WSA,RS,IR,SBR,TR logic;
    class ADM,ABLE,AC,AS,ANSD,AWLAN module;
    class NSM,NSP module;
    class AWPC,ANDC,ABLETC,P2PWM,WPP network;
    class BSM,WSM network;
    class CM,CT logic;
    class GC,AM,SC asset;
    class BC logic;
```
