# mobile-insight/mobileinsight-mobile architecture

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

- Interactive diagram: https://gitdiagram.com/mobile-insight/mobileinsight-mobile
- Repository: https://github.com/mobile-insight/mobileinsight-mobile

## Overview

##### Major Components
- MobileInsight Mobile App – The “app” directory is the heart of the project. It houses the user interface components (screens, layouts in .kv files, and Python logic), core utilities (e.g., coordinator.py, crash_app.py), and supporting components (data assets, settings, plugins).
- UI Layer – Within “app,” there is a strong reliance on Kivy/KivyMD for building the graphical user interface (as seen in files like mobileinsight.kv, multiple screens in the “screens” folder, and customized KivyMD widgets in the “kivymd” folder).
- Service/Background Layer – The “service” directory contains modules (e.g., control.py, gps.py, main.py) that likely run as background services to collect data, manage state, and handle system-level interactions.
- Plugin Framework – The “plugins” folder (with subdirectories for KPIAnalyzer, NasAnalysis, NetLogger, RrcAnalysis, WifiMonitor, etc.) shows that the application is extensible through various analytical and debugging plugins. Each plugin has its own main file (e.g., main.mi2app), configuration (such as settings.json), and documentation.
- Diag Revealer – The “diag_revealer” folder contains native (C) code under two subdirectories (mtk and qcom) for handling raw message extraction via JNI. This indicates integration of native libraries into the overall pipeline.
- Configuration and Build Tools – Top-level files like Makefile, deploy.py, and the “config” directory (with config_template.yml, example.jks, etc.) show that the project has a custom build/deployment pipeline leveraging python-for-android, Android SDK/NDK, and specific build scripts.

##### Relationships and Interactions
- The UI layer interacts with the service layer to trigger data collection (e.g., starting a GPS service or log collection).
- The service layer collects data (possibly using diag_revealer’s native code via JNI) and communicates with the plugin framework. Plugins then analyze this data (e.g., network logging, RRC, KPI analysis) and display results via the UI.
- The build system (Makefile, deploy.py) ties together code compilation (both Python via python-for-android and the native diag revealer components) and packaging (APK generation) for Android.
- Configuration files (in the “config” folder) provide runtime and compile-time settings, such as API levels, keystore details, and other build parameters.

##### Architectural Patterns and Design Principles
- Layered/MVC-like Structure – The separation seen among UI, service, and plugins suggests a modular design. The UI components (views) are clearly decoupled from backend services (controllers) and the plugin-based analytical modules.
- Plugin Architecture – The design supports extensibility by loading separate modules from the “plugins” directory, allowing easy addition or modification of analysis tools.
- Integration of Native and Managed Code – The diag_revealer module exemplifies using native C code through JNI, integrated into the Python-based (and Kivy-driven) Android app.

##### Relevant Technologies and Frameworks
- Python-for-Android – Serves as the backend build and packaging tool for the mobile application.
- Kivy and KivyMD – Define the UI components and interactions.
- Android SDK/NDK and ant – The build process for creating the APK.
- JNI Modules (in diag_revealer) – For low-level data extraction via native code.

##### Overall Detailing
- Be very detailed in capturing the essential architectural elements. List out as many components as possible rather than lumping them together. For example, separate out “app/screens” from “app/service” and “app/plugins.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Application Container
    M["MobileInsight Mobile App"]:::app

    %% UI Layer Subgraph
    subgraph "UI Layer"
        UI1["KV Layout: \"mobileinsight.kv\""]:::ui
        UI2["Screens: \"app/screens\""]:::ui
        UI3["Custom Widgets: \"app/kivymd\""]:::ui
    end

    %% Service Layer Subgraph
    subgraph "Service Layer"
        S1["Data Collection & GPS: \"app/service\""]:::service
    end

    %% Plugin Framework Subgraph
    subgraph "Plugin Framework"
        P1["KPIAnalyzer: \"app/plugins/KPIAnalyzer\""]:::plugin
        P2["NasAnalysis: \"app/plugins/NasAnalysis\""]:::plugin
        P3["NetLogger: \"app/plugins/NetLogger\""]:::plugin
        P4["RrcAnalysis: \"app/plugins/RrcAnalysis\""]:::plugin
        P5["WifiMonitor: \"app/plugins/WifiMonitor\""]:::plugin
    end

    %% Native Integration Subgraph
    subgraph "Native Integration"
        D1["Diag Revealer MTK: \"diag_revealer/mtk\""]:::native
        D2["Diag Revealer QCOM: \"diag_revealer/qcom\""]:::native
    end

    %% Build & Configuration Subgraph
    subgraph "Build & Configuration"
        B1["Makefile"]:::build
        B2["deploy.py"]:::build
        B3["Config Files: \"config/\""]:::build
    end

    %% Data Assets Node
    DA["Data Assets: \"app/data\""]:::data

    %% Relationships between Components
    M -->|"contains"| UI_Layer
    M -->|"contains"| S1
    M -->|"contains"| Plugin_Framework
    M -->|"contains"| DA

    UI_Layer -->|"triggers"| S1
    S1 -->|"communicates"| Plugin_Framework
    Plugin_Framework -->|"updates"| UI_Layer
    S1 -->|"invokes"| D1
    S1 -->|"invokes"| D2
    B1 & B2 & B3 -->|"build&config"| M

    %% Styling Classes
    classDef app fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef ui fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef plugin fill:#FFA500,stroke:#FF8C00,stroke-width:2px;
    classDef native fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
    classDef build fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef data fill:#D3D3D3,stroke:#696969,stroke-width:2px;

    %% Click Events
    click M "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/"
    click UI1 "https://github.com/mobile-insight/mobileinsight-mobile/blob/master/app/mobileinsight.kv"
    click UI2 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/screens/"
    click UI3 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/kivymd/"
    click S1 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/service/"
    click P1 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/plugins/KPIAnalyzer"
    click P2 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/plugins/NasAnalysis"
    click P3 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/plugins/NetLogger"
    click P4 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/plugins/RrcAnalysis"
    click P5 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/plugins/WifiMonitor"
    click DA "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/app/data/"
    click D1 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/diag_revealer/mtk"
    click D2 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/diag_revealer/qcom"
    click B1 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/Makefile"
    click B2 "https://github.com/mobile-insight/mobileinsight-mobile/blob/master/deploy.py"
    click B3 "https://github.com/mobile-insight/mobileinsight-mobile/tree/master/config/"
```
