# 483218131/pyqcgbc architecture

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

- Interactive diagram: https://gitdiagram.com/483218131/pyqcgbc
- Repository: https://github.com/483218131/pyqcgbc

## Overview

##### Main Components
- User Interface (UI) Layer:
- Activities and fragments that manage the main user-driven interactions.
- Key files: MainActivity.java, LogViewActivity.java, SavedTextsActivity.java, along with layout XML files (activity_main.xml, activity_saved_texts.xml, etc.).
- Service / Accessibility Layer:
- A dedicated Android Accessibility Service that monitors WeChat’s editing screen.
- Key files: WeChatTextSaverService.java and its related configuration XML (accessibility_service_config.xml) that sets the accessibility rules.
- Data Storage Component:
- Where saved texts are persisted using the file system.
- Key file: SavedText.java is likely the model representing individual records.
- Logging and Management Component:
- Handles logging functionalities and management operations for monitoring service activity.
- Key file: LogManager.java.

##### Understand the Component Relationships & Interactions
- The Accessibility Service sits at the core of the application. It continuously listens for state changes (like leaving the editing screen, switching apps, or closing WeChat) through the accessibility events.
- When triggered, the service captures the text content from WeChat’s editing interface and relays it to the data storage component for caching/saving.
- The UI Layer then allows users to view, manage, search, and filter these stored texts as well as view live logs rendered via LogViewActivity.
- The LogManager works in tandem with both the service and UI to reflect the current running status, while also enabling operations like copying and clearing logs.

##### Notice Architectural Patterns & Design Principles
- Clear Separation of Concerns: Differentiating the UI concerns (user interaction), background service logic (text capturing via accessibility), storage management, and logging elements.
- Reactive / Event-Driven Design: Especially within the Accessibility Service, which automatically listens and responds to system events (like screen state changes).
- Modular Organization: The file tree indicates services, activities, tests and resources are well-separated, facilitating a component-based architecture.

##### Incorporate Relevant Technologies & Frameworks
- Android Accessibility Service
- Java (and Kotlin for test modules like SnsDraftModuleTest.kt)
- Android resource management (layouts, drawable, and XML configuration files)
- Activity lifecycle management inherent to Android

## Diagram (Mermaid)

```mermaid
graph TD
    A["Android Text Saver App"]:::external
    E["OS Accessibility Events"]:::external

    subgraph "UI Layer"
        MA["UI - MainActivity"]:::ui
        MAL["MainActivity Layout"]:::ui
        STA["UI - SavedTextsActivity"]:::ui
        STAL["SavedTexts Layout"]:::ui
        LVA["UI - LogViewActivity"]:::ui
        LVL["LogView Layout"]:::ui
    end

    subgraph "Service Layer"
        WTS["Service - WeChatTextSaverService"]:::service
        ASC["Accessibility Service Config"]:::service
    end

    subgraph "Data & Logging"
        ST["Data - SavedText"]:::storage
        LM["Log Manager"]:::log
    end

    %% Connections between components
    A --> MA
    A --> STA
    A --> LVA
    A --> WTS
    A --> ST
    A --> LM

    E -->|"sendsEvent"| WTS

    WTS -->|"saveText"| ST
    WTS -->|"logEvent"| LM

    LM -->|"displayLog"| LVA
    ST -->|"presentSavedText"| STA

    MA -->|"navigateToSavedTexts"| STA
    MA -->|"navigateToLogView"| LVA

    %% Connections for config relation
    ASC -->|"configures"| WTS

    %% Click Events for UI Layer – MainActivity
    click MA "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/MainActivity.java"
    click MAL "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/res/layout/activity_main.xml"

    %% Click Events for UI Layer – SavedTextsActivity
    click STA "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/SavedTextsActivity.java"
    click STAL "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/res/layout/activity_saved_texts.xml"

    %% Click Events for UI Layer – LogViewActivity
    click LVA "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/LogViewActivity.java"
    click LVL "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/res/layout/activity_log_view.xml"

    %% Click Events for Service / Accessibility Layer
    click WTS "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/WeChatTextSaverService.java"
    click ASC "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/res/xml/accessibility_service_config.xml"

    %% Click Events for Data Storage
    click ST "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/SavedText.java"

    %% Click Events for Logging and Management
    click LM "https://github.com/483218131/pyqcgbc/blob/main/app/src/main/java/com/example/wechattextsaver/LogManager.java"

    %% Styling
    classDef ui fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef service fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef storage fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef log fill:#F9C0C0,stroke:#333,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
