# hiendang123a/android_lab_04_03 architecture

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

- Interactive diagram: https://gitdiagram.com/hiendang123a/android_lab_04_03
- Repository: https://github.com/hiendang123a/android_lab_04_03

## Overview

##### Project Type and Core Purpose
- Recognize that both modules are Android applications.
- That “BluetoothSocket” deals with Bluetooth communication (its code hints at managing control over Bluetooth components).
- “ImageUpload” focuses on managing image uploads with integrations to external services like Google Drive.
- Overall, the lab project demonstrates Android development fundamentals, UI design, and integration with external services/APIs.

##### Break Down the File Structure for Architectural Insights
- Top-level directories ("BluetoothSocket" and "ImageUpload") represent two distinct Android applications.
- Each app module contains the standard Android subdirectories:
- “app/src/main”: Holds core code (Activities, helper classes like BlueControl, GoogleDriveHelper, etc.) and AndroidManifest.xml.
- “app/src/res”: Contains layouts (activity_main.xml, activity_blue_control.xml, etc.), as well as drawable resources and XML configuration files (data_extraction_rules.xml, backup_rules.xml).
- “app/src/androidTest” and “app/src/test”: Indicate the presence of both instrumented and local unit tests.
- Gradle build files (build.gradle.kts) and other configuration files (gradle wrapper, gradle.properties) show that dependency management and build automation follow standard Android and Kotlin DSL conventions.

##### Main Components
- User Interface (UI) Layer:
- Activities such as MainActivity (in both projects), BlueControl (for BluetoothSocket), and ProfileActivity (for ImageUpload) that serve as the entry point for user interactions.
- Layout resources (XML files under res/layout) which define the UI structure.
- Business Logic / Service Layer:
- Domain classes and helper classes (e.g., BlueControl in the BluetoothSocket app, GoogleDriveHelper and GoogleDriveServiceHelper in the ImageUpload app) that encapsulate the core functionality, business rules, or external API integrations.
- External Integrations:
- In ImageUpload, the communication with Google Drive is a notable integration. Even if not explicitly visible as third-party libraries in the file tree, the presence of classes indicates interaction with external APIs.
- Testing Components (Optional but useful):
- Instrumented tests and local tests indicate how the project validates functionality.

##### Relationships and Interactions
- For each app, show how the components interact:
- The UI layer (Activities) calls into business logic layers (such as BlueControl or ImageUpload and associated helpers) to execute functions (e.g., establishing Bluetooth connections or uploading an image).
- The business logic layer manages data processing, API calls, or device service interactions.
- If applicable, illustrate data flow from user input through the activity and business logic to any external services, and back as feedback that updates the UI.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Each Android module separates the UI, business, and data/integration layers clearly.
- Modularity:
- The project is organized into distinct modules (BluetoothSocket and ImageUpload) which can be understood as separate self-contained systems.
- Standard Android Application Structure:
- That the architecture follows Android’s recommended application structure. Even if it’s not explicitly using patterns like MVP or MVVM, the separation in directories (activities, layouts, test cases) mirrors common Android design practices.

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% BluetoothSocket Module
    subgraph "BluetoothSocket Module"
        %% UI Layer
        subgraph "UI Layer"
            BT_MainActivity("MainActivity (UI)"):::ui
            BT_MainLayout("Main Activity Layout"):::layout
        end
        %% Business Logic Layer
        subgraph "Business Logic Layer"
            BT_BlueControl("BlueControl (Business Logic)"):::bl
            BT_BlueControlLayout("BlueControl Layout"):::layout
        end
        %% Testing
        subgraph "Testing"
            BT_InstrumentedTest("Instrumented Test"):::test
            BT_UnitTest("Unit Test"):::test
        end
    end

    %% ImageUpload Module
    subgraph "ImageUpload Module"
        %% UI Layer
        subgraph "UI Layer"
            IU_MainActivity("MainActivity (UI)"):::ui
            IU_MainLayout("Main Activity Layout"):::layout
            IU_ProfileActivity("ProfileActivity (UI)"):::ui
            IU_ProfileLayout("Profile Activity Layout"):::layout
        end
        %% Business Logic Layer
        subgraph "Business Logic Layer"
            IU_ImageUpload("ImageUpload (Core Module)"):::bl
            IU_Const("Const (Constants)"):::bl
            IU_GoogleDriveHelper("GoogleDriveHelper"):::bl
            IU_GoogleDriveServiceHelper("GoogleDriveServiceHelper"):::bl
        end
        %% External Integration
        subgraph "External Integration"
            GD_Service("Google Drive Service"):::external
        end
        %% Testing
        subgraph "Testing"
            IU_InstrumentedTest("Instrumented Test"):::test
            IU_UnitTest("Unit Test"):::test
        end
    end

    %% Connections for BluetoothSocket Module
    BT_MainActivity -->|"calls"| BT_BlueControl
    BT_MainActivity -->|"uses"| BT_MainLayout
    BT_BlueControl -->|"associatedLayout"| BT_BlueControlLayout

    %% Connections for ImageUpload Module
    IU_MainActivity -->|"uses"| IU_MainLayout
    IU_ProfileActivity -->|"uses"| IU_ProfileLayout
    IU_MainActivity -->|"triggersUpload"| IU_ImageUpload
    IU_ImageUpload -->|"usesConstants"| IU_Const
    IU_ImageUpload -->|"calls"| IU_GoogleDriveHelper
    IU_GoogleDriveHelper -->|"invokesService"| IU_GoogleDriveServiceHelper
    IU_GoogleDriveHelper -->|"integratesWith"| GD_Service
    IU_GoogleDriveServiceHelper -->|"communicatesWith"| GD_Service
    IU_ProfileActivity -->|"updatesProfile"| IU_GoogleDriveHelper

    %% Click Events for BluetoothSocket Module
    click BT_MainActivity "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/main/java/com/example/bluetoothsocket/MainActivity.java"
    click BT_BlueControl "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/main/java/com/example/bluetoothsocket/BlueControl.java"
    click BT_MainLayout "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/main/res/layout/activity_main.xml"
    click BT_BlueControlLayout "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/main/res/layout/activity_blue_control.xml"
    click BT_InstrumentedTest "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/androidTest/java/com/example/bluetoothsocket/ExampleInstrumentedTest.java"
    click BT_UnitTest "https://github.com/hiendang123a/android_lab_04_03/blob/main/BluetoothSocket/app/src/test/java/com/example/bluetoothsocket/ExampleUnitTest.java"

    %% Click Events for ImageUpload Module
    click IU_MainActivity "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/MainActivity.java"
    click IU_ProfileActivity "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/ProfileActivity.java"
    click IU_MainLayout "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/res/layout/activity_main.xml"
    click IU_ProfileLayout "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/res/layout/activity_profile.xml"
    click IU_ImageUpload "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/ImageUpload.java"
    click IU_GoogleDriveHelper "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/GoogleDriveHelper.java"
    click IU_GoogleDriveServiceHelper "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/GoogleDriveServiceHelper.java"
    click IU_Const "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/main/java/com/example/myapplication/Const.java"
    click IU_InstrumentedTest "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.java"
    click IU_UnitTest "https://github.com/hiendang123a/android_lab_04_03/blob/main/ImageUpload/app/src/test/java/com/example/myapplication/ExampleUnitTest.java"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef layout fill:#e0f7fa,stroke:#000;
    classDef bl fill:#FFA07A,stroke:#000;
    classDef test fill:#D3D3D3,stroke:#000;
    classDef external fill:#90EE90,stroke:#000;
```
