# scribe-org/scribe-ios architecture

> Architecture diagram of the GitHub repository scribe-org/scribe-ios, 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-ios
- Repository: https://github.com/scribe-org/scribe-ios

## Overview

Based on our analysis of the file tree and README, Scribe-iOS is a Swift/iOS application that provides language learning keyboards. Its purpose is to supply a keyboard extension that offers language tools such as translation (β), verb conjugation, noun pluralization, and word annotation. The project is structured as follows:

##### Main application and keyboard extension
- The “Keyboards” directory is divided into a “KeyboardsBase” (for common keyboard interfaces, styling, utility extensions, and shared functionality) and “LanguageKeyboards” (which holds language-specific implementations for English, French, German, etc.). This clear separation lets the project use common mechanics while supporting different language variations.

##### Internationalization and localization
- The “Scribe/i18n” directory deals with all the internationalization aspects. It holds localized strings (in JSON and .xcstrings formats), conversion scripts (Python scripts for iOS/Android conversion), and even its own GitHub workflow for i18n processing. This shows a structured approach to supporting multiple languages and ongoing localization efforts.

##### Development infrastructure
- The “.github” folder contains configurations for pull requests, issue templates, code of conduct, and multiple GitHub workflows (CI, SwiftLint, test checks) ensuring code quality.
- Tools such as swiftformat, swiftlint, and a pre-commit configuration are present to enforce code style and consistency.

##### External integrations and data components
- The project is closely tied to Wikidata (used for sourcing feature data and translations) and integrates machine translations (via Transformers) as well as language-specific databases (e.g. via LanguageDBManager found in the KeyboardsBase section).
- References to Scribe-Data, Scribe-Android, and planned Scribe-Desktop signal an architecture that fits into a broader ecosystem of related projects (external services and multi-platform extensions).

A. Identify and lay out the main components:
- Keyboard Extension Core: Divide the “Keyboards” part into two submodules—common/shared functionality (KeyboardsBase) and language-specific implementations (LanguageKeyboards).
- Main Application UI: Illustrate the “Scribe” module where view controllers, storyboards, and UI elements (AboutTab, InstallationTab, SettingsTab) are managed.
- Internationalization Module: Represent the “Scribe/i18n” section (localizable strings, conversion scripts, resource processing).
- External/Data Services: Show the connection to external data sources (Wikidata) and the use of machine translation libraries (Transformers) along with database management (LanguageDBManager).

B. Define the relationships and data flow:
- From the keyboard UI, show flows toward language-specific modules when a user performs operations like translation, conjugation, or pluralization.
- Data flows from the language processing modules to the database component (via LanguageDBManager) and from there to the presentation logic.
- Additionally, annotate data inputs/outputs representing the sourcing of feature data from external resources (Wikidata, Transformers library).

C. Represent key architectural patterns:
- The separation of concerns (shared keyboard logic vs. language-specific variations).
- Use of Model–View–Controller (MVC) or another suitable design pattern as suggested by the presence of controllers and view models in Scribe.
- The integration of CI/CD and pre-commit hooks should be shown to underline the automated quality assurance pipeline.

D. Include relevant technologies, frameworks, and libraries:
- Swift and the Xcode environment as fundamental tools.
- Use of SwiftLint, SwiftFormat, and pre-commit as part of development automation.
- Mention integration with GRDB (for database management) and any other external libraries (SwiftyJSON, CustomKeyboard, etc.) that influence the architecture.
- Don’t forget the external dependencies like the Transformers library for translation and the Wikidata API.

- Use clear labels for each component (e.g., “Keyboard Core (KeyboardsBase)”, “Language-Specific Keyboards (Keyboards/LanguageKeyboards)”, “Scribe Main UI”, “Internationalization Module”, “Assets & Resources”, “CI/CD & DevOps”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User Input (iOS Keyboard)"]:::external

    subgraph "Keyboard Extension"
        KB["Keyboard Extension Core (KeyboardsBase)"]:::keyboard
        LDM["LanguageDBManager"]:::keyboard
        LSM["Language-Specific Keyboards (Keyboards/LanguageKeyboards)"]:::keyboard
    end

    subgraph "Main Application UI"
        UI["Scribe Main UI"]:::frontend
        i18n["Internationalization Module (Scribe/i18n)"]:::i18n
        ASSET["Assets & Resources (In-App)"]:::assets
        APPSTORE["AppStore Assets & Promotions"]:::assets
    end

    DI["CI/CD & DevOps (.github)"]:::infra
    ED["External/Data Services (Wikidata,Transformers)"]:::external

    A -->|"triggers"| KB
    KB -->|"calls"| LSM
    KB -->|"manages"| LDM
    LDM -->|"integrates"| ED
    KB -->|"updates"| UI
    i18n -->|"localizes"| UI
    ASSET -->|"supplies"| UI
    UI -->|"promotes"| APPSTORE
    DI -->|"deploys"| UI
    DI -->|"deploys"| KB

    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef keyboard fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef i18n fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef assets fill:#FFECB3,stroke:#F57C00,stroke-width:2px;
    classDef infra fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#C62828,stroke-width:2px;

    click UI "https://github.com/scribe-org/scribe-ios/blob/main/Scribe/AppDelegate.swift"
    click KB "https://github.com/scribe-org/scribe-ios/blob/main/Keyboards/KeyboardsBase/KeyboardViewController.swift"
    click LDM "https://github.com/scribe-org/scribe-ios/blob/main/Keyboards/KeyboardsBase/LanguageDBManager.swift"
    click LSM "https://github.com/scribe-org/scribe-ios/tree/main/Keyboards/LanguageKeyboards"
    click i18n "https://github.com/scribe-org/scribe-ios/tree/main/Scribe/i18n"
    click ASSET "https://github.com/scribe-org/scribe-ios/blob/main/Scribe/Assets.xcassets"
    click APPSTORE "https://github.com/scribe-org/scribe-ios/tree/main/AppStore"
    click DI "https://github.com/scribe-org/scribe-ios/blob/main/.github"
```
