# scribe-org/scribe-android architecture

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

- Interactive diagram: https://gitdiagram.com/scribe-org/scribe-android
- Repository: https://github.com/scribe-org/scribe-android

## Overview

##### Main components
- Android OS Platform & Input Method Framework – show that Scribe-Android registers as an IME service with Android.
- Application Module – represents the “app” directory including:
– Business Logic & Navigation: packages like “services” (e.g., EnglishKeyboardIME, FrenchKeyboardIME, etc.), “helpers” (for constants, configuration, database handling) and “navigation” (Screen.kt).
– Data & Assets: assets directory that contains language data (SQLite databases, translation files, i18n resources) and the bundled configuration/contract files.
- Testing & Build Tools: an indication of testing (under app/src/test) and the CI/CD configuration present in the .github/workflows, Gradle files, and pre-commit config.

##### Relationships and interactions
- The IME service (from the “services” package) then interacts with UI components (under “ui” and “activities”) to render the on-screen keyboard.
- The UI layer invokes helper classes and view models to manage settings, preferences, and data which is loaded from the asset-based SQLite databases.
- Localization flows: The app pulls language layouts and translation files from the “assets/i18n” folder and processes them (with helper scripts in the provided Python scripts directory) to convert between JSON and platform-specific formats as needed.
- The build and testing infrastructure (Gradle, CI workflows) support the development and integration process, which can be depicted as external tooling that feeds into the final app build.

##### Architectural Patterns & Design Principles
- The project appears to follow a modular component design. In many Android projects, especially those using Kotlin, an MVVM (Model-View-ViewModel) pattern is common. Components like “models,” “ui/screens,” and “viewmodels” suggest a separation between UI logic and business logic.
- The service layer that implements different keyboard IMEs (for each language) indicates the use of inheritance and possibly strategy patterns to allow for language-specific behavior.
- There is a clear separation of concerns: layout definitions in XML, business logic in helper classes, and external configuration/data in assets.

##### Relevant technologies, frameworks, and libraries
- Android SDK, Kotlin, and the use of the Android Studio IDE.
- Gradle Kotlin DSL for builds.
- SQLite for local language data storage.
- Pre-commit hooks and GitHub Actions for ensuring code quality and continuous integration.
- The project also references external contributions (like Simple-Keyboard and Simple-Commons) which may influence its design architecture.

- Each main component should be clearly labeled (e.g., “Android Input Method Service,” “UI & Presentation Layer,” “Business Logic & View Models,” “Data & Assets,” “Build & CI Infrastructure”).
- Incorporate annotations or callouts that outline the usage of architectural patterns like MVVM and service registration with Android’s input method framework.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Platform Layer
    subgraph "Platform"
        AOS("Android OS Platform"):::platform
    end

    %% IME Services Layer
    subgraph "IME Services"
        IME("Android IME Service"):::service
    end

    %% UI Layer
    subgraph "UI & Presentation Layer"
        MA("MainActivity"):::ui
        UT("UI Themes"):::ui
        XL("XML Layouts"):::ui
    end

    %% Business Logic & Navigation
    subgraph "Business Logic & Navigation"
        HEL("Helpers"):::logic
        NAV("Navigation"):::logic
    end

    %% Data & Assets
    subgraph "Data & Assets"
        SQL("SQLite & Translations"):::data
        I18N("Localization Files"):::data
    end

    %% Domain Layer
    subgraph "Domain Layer"
        MOD("Models"):::domain
        SV("Settings ViewModels"):::domain
    end

    %% Testing & Build Tools
    subgraph "Testing & Build Tools"
        TEST("Unit Tests"):::ci
        CI("CI Config"):::ci
    end

    %% External Dependencies & Services
    subgraph "External Dependencies"
        EXT("External Dependencies"):::external
    end

    %% Relationships
    AOS -->|"registers"| IME
    IME -->|"renders_keyboard"| MA
    MA -->|"invokes_helpers"| HEL
    HEL -->|"triggers_navigation"| NAV
    HEL -->|"loads_language_data"| SQL
    HEL -->|"loads_localization"| I18N
    MA -->|"binds_viewmodels"| SV
    MOD -->|"supplies_models_to"| SV
    EXT -->|"supplies_data_to"| SQL
    EXT -->|"supplies_localization_to"| I18N
    CI -->|"supports_build_test"| MA
    TEST -->|"verifies"| MA

    %% Click Events
    click IME "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/java/be/scri/services"
    click MA "https://github.com/scribe-org/scribe-android/blob/main/app/src/main/java/be/scri/activities/MainActivity.kt"
    click UT "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/java/be/scri/ui/theme"
    click XL "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/res/layout"
    click HEL "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/java/be/scri/helpers"
    click NAV "https://github.com/scribe-org/scribe-android/blob/main/app/src/main/java/be/scri/navigation/Screen.kt"
    click SQL "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/assets/data"
    click I18N "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/assets/i18n"
    click MOD "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/java/be/scri/models"
    click SV "https://github.com/scribe-org/scribe-android/tree/main/app/src/main/java/be/scri/ui/screens/settings"
    click TEST "https://github.com/scribe-org/scribe-android/tree/main/app/src/test"
    click CI "https://github.com/scribe-org/scribe-android/tree/main/ .github/workflows"
    click CI "https://github.com/scribe-org/scribe-android/blob/main/build.gradle.kts"

    %% Styles
    classDef platform fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef service fill:#aed6f1,stroke:#1f618d,stroke-width:2px;
    classDef ui fill:#abebc6,stroke:#196f3d,stroke-width:2px;
    classDef logic fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
    classDef data fill:#f5b7b1,stroke:#922b21,stroke-width:2px;
    classDef domain fill:#fcf3cf,stroke:#7d6608,stroke-width:2px;
    classDef ci fill:#d6eaf8,stroke:#2874a6,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#b03a2e,stroke-width:2px;
```
