# openvanilla/mcbopomofoweb architecture

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

- Interactive diagram: https://gitdiagram.com/openvanilla/mcbopomofoweb
- Repository: https://github.com/openvanilla/mcbopomofoweb

## Overview

##### Major Components
- Core Input Method Engine:
– This lies mainly in the src directory, with submodules like McBopomofo, Mandarin, BopomofoBraille, ChineseNumbers, Gramambular2, and LargeSync.
– Each module may encapsulate specific functionality such as input decoding, candidate selection, language model processing, and text conversion (e.g., Chinese numbers and Braille conversions).

- Build and Deployment Pipelines:
– The npm scripts (npm run build, npm run build:chromeos, npm run build:pime) indicate that the source code is bundled via webpack (multiple webpack.config files) into different output directories.
– The installer directory (with WiX files for PIME) and batch files show that there’s a dedicated packaging process for the Windows/PIME integration.

- Frontend/Presentation Layers:
– In the output folder, separate directories for example (web demo), chromeos (Chrome OS version), and pime (Windows PIME version) show distinct deployments.
– These components show how the core engine is integrated into different environments (web, Chrome extension-style packaging, and integration into PIME).

- External Integration Components:
– The “others/word_addin” directory provides a Microsoft Word Add-in, which demonstrates an integration point for using the text conversion services within Office.
– Additional tools (in the tools directory) showcase supplementary functionalities for things like encoding and mapping.

- Supporting Artifacts:
– GitHub workflows, ESLint configuration, and other configuration files indicate continuous integration/quality control which, while not part of runtime architecture, are essential for the build and deployment process.

##### Relationships and Interactions
- The core engine (src modules) is first developed in TypeScript then compiled/bundled using webpack.
- The build process generates platform-specific artifacts, which are deployed as follows:
– The “output/example” folder represents a standalone web demo.
– The “output/chromeos” folder is structured for Chrome OS input method packaging.
– The “output/pime” folder contains files used to integrate with the PIME framework on Windows.
- The installer (with WiX scripts) packages the PIME version for easier distribution and installation on Windows.
- The “others/word_addin” serves as an integration layer for Microsoft Word, clearly isolated from the core engine but leveraging shared conversion capabilities.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Notice how the project clearly divides the core logic, build scripts, installer configurations, and external integrations.
- Multi-target Packaging: The use of separate build scripts and output directories underscores a strategy for multi-platform deployments.
- Modular Design: The src tree is organized by functional modules (e.g., McBopomofo, Mandarin) which supports extensibility and maintainability.
- CI/CD Integration: The GitHub workflows and config files (like .eslintrc.js, jest.config.js) emphasize modern DevOps practices.

##### Technologies and Frameworks
- Primary Languages: JavaScript and TypeScript.
- Build Tools: npm, webpack (with several configuration files for different targets).
- Testing: Jest for tests in TypeScript files.
- Installer: WiX for Windows installer packaging.
- External Libraries: Third-party packages (e.g., chinese_convert, chrome-storage-largeSync) for conversion and storage.

##### Elements
- Clear Labels: Each component (e.g., “Input Method Engine – McBopomofo Module”, “Chrome OS Deployment”, “PIME Packaging Process”) should be clearly labeled.
- Build & CI/CD Components: Optionally add a section (maybe at the side) that shows GitHub workflows and build scripts as part of the continuous integration pipeline that feeds into the packaging or deployment process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Input Method Engine
    subgraph "Core Input Method Engine"
        MC["McBopomofo Module"]:::core
        MD["Mandarin Module"]:::core
        BB["BopomofoBraille Module"]:::core
        CN["ChineseNumbers Module"]:::core
        GA["Gramambular2 Module"]:::core
        LS["LargeSync Module"]:::core
    end

    %% Build and Deployment Pipelines
    subgraph "Build and Deployment Pipelines"
        webpack1["Webpack: webpack.config.js"]:::pipeline
        webpack2["Webpack: webpack.config.chromeext.js"]:::pipeline
        webpack3["Webpack: webpack.config.pime.js"]:::pipeline
        batch1["Batch Script: build_pime.bat"]:::pipeline
        batch2["Batch Script: build_pime_installer.bat"]:::pipeline
        installer["PIME Installer"]:::pipeline
    end

    %% Frontend / Presentation
    subgraph "Frontend / Presentation"
        webDemo["Web Demo"]:::frontend
        chromeos["Chrome OS Input Method"]:::frontend
        pime["Windows PIME Version"]:::frontend
    end

    %% External Integration
    wordaddin["Word Add-in"]:::integration

    %% Relationships
    %% Core Engine to Build Pipelines
    LS -->|"compiled_via"| webpack1
    LS -->|"compiled_via"| webpack2
    LS -->|"compiled_via"| webpack3

    %% Batch Scripts trigger deployments
    batch1 -->|"builds"| pime
    batch2 -->|"triggers"| installer

    %% Build Pipelines to Frontend / Presentation
    webpack1 -->|"bundles_for"| webDemo
    webpack2 -->|"bundles_for"| chromeos
    webpack3 -->|"bundles_for"| pime

    %% PIME Packaging process
    pime -->|"packaged_by"| installer

    %% Core Engine to External Integration
    LS -->|"serves_conversion"| wordaddin

    %% Styles
    classDef core fill:#ffebcd,stroke:#b8860b,stroke-width:2px;
    classDef pipeline fill:#e0ffff,stroke:#008b8b,stroke-width:2px;
    classDef frontend fill:#e6e6fa,stroke:#9370db,stroke-width:2px;
    classDef integration fill:#ffe4e1,stroke:#ff6347,stroke-width:2px;

    %% Click Events for Core Input Method Engine Modules
    click MC "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/McBopomofo"
    click MD "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/Mandarin"
    click BB "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/BopomofoBraille"
    click CN "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/ChineseNumbers"
    click GA "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/Gramambular2"
    click LS "https://github.com/openvanilla/mcbopomofoweb/tree/main/src/LargeSync"

    %% Click Events for Build and Deployment Pipelines
    click webpack1 "https://github.com/openvanilla/mcbopomofoweb/blob/main/webpack.config.js"
    click webpack2 "https://github.com/openvanilla/mcbopomofoweb/blob/main/webpack.config.chromeext.js"
    click webpack3 "https://github.com/openvanilla/mcbopomofoweb/blob/main/webpack.config.pime.js"
    click batch1 "https://github.com/openvanilla/mcbopomofoweb/blob/main/build_pime.bat"
    click batch2 "https://github.com/openvanilla/mcbopomofoweb/blob/main/build_pime_installer.bat"
    click installer "https://github.com/openvanilla/mcbopomofoweb/tree/main/installer/wix"

    %% Click Events for Frontend/Presentation
    click webDemo "https://github.com/openvanilla/mcbopomofoweb/tree/main/output/example"
    click chromeos "https://github.com/openvanilla/mcbopomofoweb/tree/main/output/chromeos"
    click pime "https://github.com/openvanilla/mcbopomofoweb/tree/main/output/pime"

    %% Click Event for External Integration Component
    click wordaddin "https://github.com/openvanilla/mcbopomofoweb/tree/main/others/word_addin"
```
