# gurecn/yuyanime architecture

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

- Interactive diagram: https://gitdiagram.com/gurecn/yuyanime
- Repository: https://github.com/gurecn/yuyanime

## Overview

##### Project type and purpose
- This is an Android input-method (IME) app named “语燕输入法” (YuyanIme).
- It’s built as an Android Studio Gradle project with two main modules:
- app/ – the Android application module implementing the InputMethodService, keyboard UIs, settings, permissions, themes, and resource management
- yuyansdk/ – a submodule (likely containing the core engine wrapper around the Rime input engine, dictionary loading, policy, and common SDK code)
- The README confirms it’s a fork/customization of the Rime engine, offering multiple input modes (pinyin, double-pinyin, handwriting via Hanwang online, etc.), personalized settings, offline/online editions, and minimal permissions.

##### File structure
- Top-level:
- .github – issue/PR templates
- app/ – Android application module
- yuyansdk/ – core engine SDK module
- build.gradle, settings.gradle, gradle.properties – multi-module Gradle setup
- app/src/main/java/com/yuyan/BaseApplication.kt: initializes global state
- app/src/main/res/xml/method.xml: AndroidManifest registration of the InputMethodService
- app/src/main/res/*: layouts, drawables, themes, keyboard definitions
- app/build.gradle: app-level dependencies (AndroidX, Kotlin, third-party libraries)
- root build.gradle: common dependencies, Rime native libs inclusion
- gradle.properties: Android SDK versions (minSdk 23), Kotlin/JVM settings
- yuyansdk/: likely contains Kotlin/Java wrapper interfaces, JNI bindings to librime, dictionary loaders, common utilities

##### README for additional insights
- Architecture hints: “基于Rime引擎” – uses librime via JNI, packaged within the SDK module.
- Two editions: offline (no network, minimal Android permissions) vs. online (adds Hanwang handwriting network calls).
- Emphasis on modular input schemes: T9, QWERTY, double-pinyin, Wubi strokes, handwriting, emoji, custom symbol sets.
- Custom UI features: floating keyboard, single-handed mode, dark theme auto-switch, custom numeric row, clipboard manager.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Framework Layer"
        BA["BaseApplication"]:::android
        IMS["InputMethodService"]:::android
    end

    subgraph "UI Layer"
        KV["KeyboardView Components"]:::ui
        SS["Settings Screens"]:::ui
    end

    subgraph "Business Logic Layer"
        EM["YuyanEngineManager"]:::biz
        IP["InputPolicy"]:::biz
        CS["ClipboardService"]:::biz
    end

    subgraph "Native Engine Layer"
        lib["liblibrime.so"]:::native
    end

    subgraph "Data & Persistence"
        SP["SharedPreferences"]:::data
        DF["Dictionary Files"]:::data
    end

    subgraph "External Services"
        HW["Hanwang Online API"]:::external
    end

    subgraph "Android System Services"
        CM["ClipboardManager"]:::system
        VM["Vibrator"]:::system
        AM["AudioManager"]:::system
        SM["SensorManager"]:::system
    end

    subgraph "Project Files"
        MODApp["app/"]:::file
        AGradle["app/build.gradle"]:::file
        Proguard["app/proguard.cfg"]:::file
        SDKmod["yuyansdk/"]:::file
        RootSetup["Root Gradle Setup"]:::file
        GitHub[".github/ISSUE_TEMPLATE/"]:::file
        Doc["README.md & LICENSE"]:::file
    end

    %% Flows
    User["User"]:::external --> KV
    KV --> IMS
    IMS -->|"onCreate/onStartInput"| EM
    EM --> lib
    lib --> EM
    EM --> IMS
    IMS -->|"commit text"| HostApp["Host Application"]:::android

    SS --> SP
    SP --> EM
    IP --> EM
    CM --> CS
    CS --> IMS

    KV -->|"handwriting strokes"| HW
    HW -.->|"recognition result"| EM

    %% Click Events
    click BA "https://github.com/gurecn/yuyanime/blob/master/app/src/main/java/com/yuyan/BaseApplication.kt"
    click IMS "https://github.com/gurecn/yuyanime/blob/master/app/src/main/res/xml/method.xml"
    click MODApp "https://github.com/gurecn/yuyanime/tree/master/app/"
    click AGradle "https://github.com/gurecn/yuyanime/blob/master/app/build.gradle"
    click Proguard "https://github.com/gurecn/yuyanime/blob/master/app/proguard.cfg"
    click SDKmod "https://github.com/gurecn/yuyanime/tree/master/yuyansdk/"
    click RootSetup "https://github.com/gurecn/yuyanime/blob/master/settings.gradle"
    click RootSetup "https://github.com/gurecn/yuyanime/blob/master/build.gradle"
    click RootSetup "https://github.com/gurecn/yuyanime/blob/master/gradle.properties"
    click GitHub "https://github.com/gurecn/yuyanime/tree/master/.github/ISSUE_TEMPLATE/"
    click Doc "https://github.com/gurecn/yuyanime/blob/master/README.md"

    %% Styles
    classDef android fill:#D0E8FF,stroke:#004080,color:#004080;
    classDef ui fill:#E8F8E8,stroke:#1F7700,color:#1F7700;
    classDef biz fill:#FFF0D6,stroke:#CC8400,color:#CC8400;
    classDef native fill:#FFE6E6,stroke:#CC0000,color:#CC0000;
    classDef external fill:#F3E6FF,stroke:#8000CC,color:#8000CC;
    classDef data fill:#FFFDE6,stroke:#E6D800,color:#E6D800;
    classDef system fill:#F0F0F0,stroke:#666666,color:#666666;
    classDef file fill:#F8F8F8,stroke:#AAAAAA,color:#333333;
```
