# yvescheung/uinspector architecture

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

- Interactive diagram: https://gitdiagram.com/yvescheung/uinspector
- Repository: https://github.com/yvescheung/uinspector

## Overview

##### Main Components
- Core Inspector API (api module): This module exposes the key interfaces and classes (e.g., UInspector.kt, various plugins for hierarchy, properties, lifecycle, and touch events) that constitute the inspection logic.
- Default Implementations (impl module): Contains the default behaviors for panels, accessibility, view properties, hierarchy extra information, and targets (e.g., UInspectorDefaultChildPanelPlugin, UInspectorHierarchyPanel). This module implements the interfaces defined in the API.
- Demo/Application Module (app module): This sample app demonstrates the integration of the inspector. It includes the UI elements, Android manifest for launching activities (e.g., MainActivity, demo dialog and gallery windows) and interacts with the core UInspector.
- Optional Integrations (optional module): Divided into submodules like compose, fresco, glide, lottie, multitype and viewmodel, each providing additional parsing, inspection, or UI capabilities for popular third-party libraries or frameworks.

##### Relationships and Data Flow
- Once a view is tapped (using single-tap interception and double-tap for normal click propagation), the inspector queries the hierarchy, properties, and state of the view.
- The core API redirects this event to the appropriate panel or plugin, which may be implemented either by default (from the impl module) or extended through optional integrations.

##### Architectural Patterns and Principles
- Modular Design: The separation into modules (api, impl, app, optional) allows for independent development and testing. Each module has clear responsibilities and defined entry points (e.g., the UInspector creation call, Notification Service integration).
- Event Interception and Dispatching: Emphasize that the inspector intercepts UI touch events (with a fallback on double-taps to allow normal clicks), then processes and displays data visualizations of the view information.

##### Relevant Technologies and Frameworks
- Android SDK: Components such as Activities, Fragments, AndroidManifest entries, and resources (layouts, drawables, strings).
- Gradle Build System: Note the existence of build scripts at multiple levels (e.g., build.gradle in app, api, impl, and each optional module).
- Optional frameworks: Jetpack Compose, Fresco, Glide, Lottie, MultiType, and ViewModel – indicate their optional dependency paths that extend the core functionality.

##### Elements
- Each module (api, impl, app, optional) should be represented as a container.
- Within the API module, include components such as the main Inspector class (UInspector.kt), hierarchy parsers, properties parsers, lifecycle management, and plugin service interfaces.
- Within the Impl module, list key default implementations that tie into the API’s interfaces.
- The Demo Application should be shown as a consumer of the API (illustrating the flow from Android system events to inspector activation).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Event
    Start["User Touch Event (Android Notification)"]:::event

    %% API Module
    subgraph "API Module"
        A1["UInspector.kt - Core Inspector"]:::api
        A2["Notification Service"]:::api
        A3["Hierarchy & Properties Parsers"]:::api
        A4["Plugin Interfaces & Lifecycle Manager"]:::api
    end

    %% Impl Module
    subgraph "Impl Module"
        I1["UInspectorDefaultChildPanelPlugin"]:::impl
        I2["UInspectorHierarchyPanel"]:::impl
        I3["Other Default Implementations"]:::impl
    end

    %% Demo Application Module
    subgraph "Demo Application"
        D1["MainActivity"]:::app
        D2["MainApplication"]:::app
        D3["UI Panels & Dialogs (Demo)"]:::app
    end

    %% Optional Integrations Module
    subgraph "Optional Integrations"
        subgraph "Compose"
            O1["UInspectorComposeService.kt"]:::optional
        end
        subgraph "Fresco"
            O2["UInspectorFrescoService.kt"]:::optional
            O3["FrescoPropertiesParserPlugin"]:::optional
        end
        subgraph "Glide"
            O4["UInspectorGlideService.kt"]:::optional
            O5["GlidePropertiesParserPlugin"]:::optional
        end
        subgraph "Lottie"
            O6["UInspectorLottieService.kt"]:::optional
            O7["LottiePropertiesParserPlugin"]:::optional
        end
        subgraph "MultiType"
            O8["UInspectorMultiTypeService.kt"]:::optional
            O9["MultiTypeHierarchyPlugin"]:::optional
        end
        subgraph "ViewModel"
            O10["UInspectorViewModelPluginService"]:::optional
            O11["UInspectorViewModelPanel"]:::optional
            O12["UInspectorViewModelPanelPlugin"]:::optional
        end
    end

    %% Data Flow Connections
    Start -->|"triggers"| A2
    A2 -->|"activates"| A1
    A1 -->|"queries"| A3
    A1 -->|"delegates to"| A4
    A4 -->|"invokes"| I1
    A4 -->|"invokes"| I2
    A4 -->|"invokes"| I3
    A1 -->|"updates"| D3
    D1 -->|"demonstrates usage"| D3
    D2 -->|"configures"| D1

    %% Integration Points
    A4 -->|"optionalExtension"| O1
    A4 -->|"optionalExtension"| O2
    A3 -->|"optionalProperties"| O5
    A3 -->|"optionalExtension"| O6
    A4 -->|"optionalIntegration"| O8
    A4 -->|"optionalIntegration"| O10
    D3 -->|"UIEnhancement"| O3
    D3 -->|"UIEnhancement"| O7
    D3 -->|"UIEnhancement"| O9
    D3 -->|"UIEnhancement"| O11
    D3 -->|"UIEnhancement"| O12

    %% Class Styling
    classDef api fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef impl fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef app fill:#FFE082,stroke:#FF6F00,stroke-width:2px;
    classDef optional fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
    classDef event fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/yvescheung/uinspector/blob/2.x/api/src/main/java/com/pitaya/mobile/uinspector/UInspector.kt"
    click I1 "https://github.com/yvescheung/uinspector/tree/2.x/impl/src/main/java/com/pitaya/mobile/uinspector/impl"
    click D1 "https://github.com/yvescheung/uinspector/blob/2.x/app/src/main/java/com/pitaya/mobile/uinspector/MainActivity.kt"
    click D2 "https://github.com/yvescheung/uinspector/blob/2.x/app/src/main/java/com/pitaya/mobile/uinspector/MainApplication.kt"
    click O1 "https://github.com/yvescheung/uinspector/tree/2.x/optional/compose/src/main/java/com/pitaya/mobile/uinspector/optional/compose"
    click O2 "https://github.com/yvescheung/uinspector/tree/2.x/optional/fresco/src/main/java/com/pitaya/mobile/uinspector/optional/fresco"
    click O4 "https://github.com/yvescheung/uinspector/tree/2.x/optional/glide/src/main/java/com/pitaya/mobile/uinspector/optional/glide"
    click O6 "https://github.com/yvescheung/uinspector/tree/2.x/optional/lottie/src/main/java/com/pitaya/mobile/uinspector/optional/lottie"
    click O8 "https://github.com/yvescheung/uinspector/tree/2.x/optional/multitype/src/main/java/com/pitaya/mobile/uinspector/optional/multitype"
    click O10 "https://github.com/yvescheung/uinspector/tree/2.x/optional/viewmodel/src/main/java/com/pitaya/mobile/uinspector/optional/viewmodel"
```
