# vladimir-ponomarenko/android architecture

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

- Interactive diagram: https://gitdiagram.com/vladimir-ponomarenko/android
- Repository: https://github.com/vladimir-ponomarenko/android

## Overview

##### Project Type and Purpose
- This is a full-stack Android application that gathers and analyzes mobile network data (such as signal strength, cell IDs, and traffic usage) and sends the results to a remote server for further study.

##### Analyzing the File Structure
- There is a well-defined separation between Android-specific Java/Kotlin code (located in app/src/main/java/com/example/login) and native C/C++ code (found in app/src/main/cpp and app/src/main/jni). This indicates the use of JNI for performance-critical or legacy operations such as diagnostics processing.
- The “assets” folder includes several configuration files (diag.cfg, full_diag.cfg, etc.) and directories for dissector tools, suggesting that the native module uses these files to process detailed network data.
- The directory “app/src/main/res” holds XML layouts and resources, confirming that the UI is structured through Android’s UI framework.
- Gradle and build scripts (build.gradle.kts, CMakeLists.txt, etc.) indicate that both Java/Kotlin and C++ code are integrated in the build process.

##### Key System Components
a. Frontend / User Interface:
- Components: Activities and various UI screens such as MainActivity, DataScreen, MapScreen, LoginScreen, TrafficScreen, UpdateScreen, etc.
- Role: Handle user interaction, displaying real-time network data (e.g., graphs and maps) and managing permission flows.

b. Core Application Logic (Business Logic Layer):
- Components: DataManager (for gathering location and network data), NetworkManager (for server communication, authentication, and data uploads), TrafficManager (for analyzing data usage), and Utils for shared functionality.
- Role: Interface between the UI and the underlying data collection/processing modules.

c. Native / JNI Layer:
- Components: C++ modules (such as diagRevealer.cpp, diagcfgwr.cpp, hdlc.cpp, log_packet.cpp, etc.) that perform low-level processing of network diagnostic logs and dissecting protocols.
- Role: Provide high-performance processing and potentially integration with libraries (e.g., nlohmann::json or Wireshark’s dissectors) to parse and process network diagnostic data.

d. External Services and Data Flow:
- Components: Server endpoint (remote service) where processed data is sent.
- Role: Reception and possibly further analysis of the network data collected from the device.

e. Configuration and Resources:
- Role: Provide static data and configuration parameters used by both the frontend and native layers.

##### Relationships and Data Flow
- Start at the UI layer where user interactions (e.g., starting data collection, navigating between screens) are performed.
- UI components invoke methods in the core application logic (DataManager, TrafficManager, etc.) to obtain and process network data.
- DataManager may pass data to and from the native layer via JNI calls; native components take care of complex data processing such as protocol dissection.
- Processed data moves back to the Java/Kotlin side to be visualized (maps and graphs) and may be sent to external servers via the NetworkManager.

##### Highlighting Important Architectural Patterns
- Modular Separation: The clear split between UI, business logic, and native processing should be emphasized using distinct layers or modules.
- JNI Integration: Represent the boundary between Java/Kotlin components and the native C++ modules.
- Client-Server Communication: Indicate how network data is forwarded to a server through the NetworkManager.
- Use of external configuration files and assets: Show their relationship to the native processing modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Android UI)"
        MA("MainActivity"):::frontend
        DS("DataScreen"):::frontend
        MS("MapScreen"):::frontend
        LS("LoginScreen"):::frontend
        TS("TrafficScreen"):::frontend
        US("UpdateScreen"):::frontend
    end

    subgraph "Core Application Logic"
        DM("DataManager"):::logic
        NM("NetworkManager"):::logic
        TM("TrafficManager"):::logic
        UM("UpdateManager"):::logic
        RM("RootManager"):::logic
        UT("Utils"):::logic
    end

    subgraph "Native / JNI Layer"
        subgraph "C++ Modules"
            DR("diagRevealer"):::native
        end
        subgraph "JNI Interaction"
            JNI("JNI diag_revealer"):::native
            CL("CMakeLists"):::native
        end
    end

    subgraph "Configuration and Resources"
        AC("Assets & Configuration Files"):::config
        UR("UI Resources"):::config
    end

    ES("External Server"):::external

    %% UI to Core Application Logic relationships
    MA -->|"calls"| DM
    DS -->|"triggers"| DM
    MS -->|"requests"| DM
    LS -->|"authenticates"| DM
    TS -->|"analyzes"| TM
    US -->|"updates"| UM

    %% Core to Native (via JNI) relationships
    DM -->|"JNI_call"| JNI
    JNI -->|"process"| DR

    %% Core to External Server
    NM -->|"DataUpload"| ES

    %% Configuration feeding Native Layer
    AC -->|"provides config"| DR

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef logic fill:#ABEBC6,stroke:#333,stroke-width:2px;
    classDef native fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef config fill:#F5CBA7,stroke:#333,stroke-width:2px;
    classDef external fill:#E6B0AA,stroke:#333,stroke-width:2px;

    %% Click Events for Frontend / User Interface Components
    click MA "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/MainActivity.kt"
    click DS "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/DataScreen.kt"
    click MS "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/MapScreen.kt"
    click LS "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/LoginScreen.kt"
    click TS "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/TrafficScreen.kt"
    click US "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/UpdateScreen.kt"

    %% Click Events for Core Application Logic Components
    click DM "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/DataManager.kt"
    click NM "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/NetworkManager.kt"
    click TM "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/TrafficManager.kt"
    click UM "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/UpdateManager.kt"
    click RM "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/RootManager.kt"
    click UT "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/java/com/example/login/Utils.kt"

    %% Click Events for Native / JNI Layer Components
    click DR "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/cpp/diagRevealer.cpp"
    click JNI "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/jni/diag_revealer.c"
    click CL "https://github.com/vladimir-ponomarenko/android/blob/main/app/src/main/jni/CMakeLists.txt"

    %% Click Events for Configuration and Resources
    click AC "https://github.com/vladimir-ponomarenko/android/tree/main/app/src/main/assets"
    click UR "https://github.com/vladimir-ponomarenko/android/tree/main/app/src/main/res"
```
