# chewing/ibus-chewing architecture

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

- Interactive diagram: https://gitdiagram.com/chewing/ibus-chewing
- Repository: https://github.com/chewing/ibus-chewing

## Overview

##### Main Components

a) Core Components:
- IBus Framework Interface
- Chewing Engine Core
- Setup/Configuration UI
- Input Processing Pipeline
- Translation/Localization System

b) Key Relationships:
- IBus Framework ↔ Chewing Engine
- Engine ↔ Configuration System
- User Interface ↔ Engine Settings

**┌─────────────────────────────────────┐**
- IBus Framework           │
- ┘
- ↕
**┌─────────────────────────────────────┐**
- IBus-Chewing Engine         │
- ┬───────────────┤
- PreEdit Handler  │ Lookup Table  │
- Input Process    │ Handler       │
- ┴───────────────┘
- ↕
**┌─────────────────────────────────────┐**
- Configuration Layer         │
- ┬───────────────┤
- Settings UI        │  GSettings    │
- (GTK Interface)    │  Storage      │
- ┴───────────────┘

##### Component Details

a) Engine Core (src/ibus-chewing-engine.c):
- Connections to IBus framework
- PreEdit and LookupTable components

b) Setup Interface (src/setup/*):
- As a separate module
- Connection to GSettings storage
- Configuration UI elements

c) Utility Layer (src/IBusChewingUtil.*):
- Connections to both engine and setup components

##### Important Implementation Details to Highlight

- Interaction between IBusChewingPreEdit and IBusChewingLookupTable
- GSettings configuration storage system
- Translation/localization system integration
- Debug interfaces for development purposes

##### External Dependencies

Connections to:
- IBus system
- Chewing library
- GTK framework (for setup UI)
- GSettings system

##### Data Flow Indicators

- Input text flow
- Configuration data flow
- User interaction flow
- Event handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    IBF["IBus Framework"]:::framework
    
    subgraph Engine["Engine Layer"]
        EC["Chewing Engine Core"]:::core
        PEH["PreEdit Handler"]:::handler
        LTH["Lookup Table Handler"]:::handler
        UL["Utility Layer"]:::util
    end
    
    subgraph Config["Configuration Layer"]
        SUI["Setup/Configuration UI"]:::ui
        SA["Setup Application"]:::ui
        GS["GSettings Storage"]:::storage
        CD["Configuration Data"]:::config
        SDI["Setup Desktop Integration"]:::ui
    end
    
    subgraph External["External Dependencies"]
        CL["Chewing Library"]:::external
        GTK["GTK Framework"]:::external
        GSS["GSettings System"]:::external
    end
    
    subgraph L10n["Localization Layer"]
        TS["Translation System"]:::l10n
    end
    
    %% Relationships
    IBF <--> EC
    EC --> PEH
    EC --> LTH
    EC <--> UL
    
    PEH <--> LTH
    
    SUI <--> GS
    SA --> SUI
    GS --> CD
    SA --> SDI
    
    EC <--> CL
    SUI <--> GTK
    GS <--> GSS
    
    EC --> TS
    SUI --> TS
    
    %% Click Events
    click EC "https://github.com/chewing/ibus-chewing/blob/master/src/ibus-chewing-engine.c"
    click PEH "https://github.com/chewing/ibus-chewing/blob/master/src/IBusChewingPreEdit.c"
    click LTH "https://github.com/chewing/ibus-chewing/blob/master/src/IBusChewingLookupTable.c"
    click SUI "https://github.com/chewing/ibus-chewing/blob/master/src/setup/ibus-setup-chewing-window.c"
    click GS "https://github.com/chewing/ibus-chewing/blob/master/src/setup/org.freedesktop.IBus.Chewing.gschema.xml"
    click TS "https://github.com/chewing/ibus-chewing/tree/master/po/"
    click UL "https://github.com/chewing/ibus-chewing/blob/master/src/IBusChewingUtil.c"
    click SA "https://github.com/chewing/ibus-chewing/blob/master/src/setup/ibus-setup-chewing-application.c"
    click CD "https://github.com/chewing/ibus-chewing/blob/master/data/chewing.xml.in"
    click SDI "https://github.com/chewing/ibus-chewing/blob/master/data/ibus-setup-chewing.desktop.in"
    
    %% Styles
    classDef framework fill:#gray,stroke:#333,stroke-width:2px;
    classDef core fill:#blue,stroke:#333,stroke-width:2px;
    classDef handler fill:#lightblue,stroke:#333,stroke-width:2px;
    classDef util fill:#cyan,stroke:#333,stroke-width:2px;
    classDef ui fill:#green,stroke:#333,stroke-width:2px;
    classDef storage fill:#orange,stroke:#333,stroke-width:2px;
    classDef config fill:#yellow,stroke:#333,stroke-width:2px;
    classDef external fill:#lightgray,stroke:#333,stroke-width:2px;
    classDef l10n fill:#purple,stroke:#333,stroke-width:2px;
    
    %% Legend
    subgraph Legend
        L1["Framework Component"]:::framework
        L2["Core Component"]:::core
        L3["Handler Component"]:::handler
        L4["Utility Component"]:::util
        L5["UI Component"]:::ui
        L6["Storage Component"]:::storage
        L7["Config Component"]:::config
        L8["External Component"]:::external
        L9["Localization Component"]:::l10n
    end
```
