# matsuokajuri/ziliu-ime architecture

> Architecture diagram of the GitHub repository matsuokajuri/ziliu-ime, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matsuokajuri/ziliu-ime
- Repository: https://github.com/matsuokajuri/ziliu-ime

## Overview

Ziliu is a native Windows Chinese input method. The main workflow runs from text entry in a Windows app through the TSF service and local named-pipe broker to a Rime-backed session; the candidate window presents composition and selection. Settings and theme import form a separate customization branch. The graph follows README statements and shown source references; unsampled implementation details are not expanded.

Main entry points: [`src/settings/MainWindow.xaml.cpp`](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/MainWindow.xaml.cpp) (Settings app), [`src/ipc/src/pipe_server.cpp`](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_server.cpp) (Named-pipe server), [`src/tsf/src/text_service.cpp`](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/tsf/src/text_service.cpp) (TSF text service), [`src/ipc/src/pipe_client.cpp`](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_client.cpp) (Pipe client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_windows["Windows input"]
  node_tsf["TSF text service<br/>[text_service.cpp]"]
  node_pipeclient["Pipe client<br/>[pipe_client.cpp]"]
end

subgraph group_broker["Engine broker"]
  node_pipe["Named-pipe server<br/>[pipe_server.cpp]"]
  node_broker_main["Broker process<br/>[broker_main.cpp]"]
  node_session["Session host<br/>[session_host.cpp]"]
  node_engine["Rime engine<br/>[rime_engine.cpp]"]
  node_stub["Development engine<br/>[stub_engine.cpp]"]
  node_protocol["IPC protocol<br/>[ipc_protocol.cpp]"]
end

subgraph group_presentation["Candidates and themes"]
  node_candidate["Candidate window"]
end

subgraph group_settings["Settings and themes"]
  node_settings_ui["Settings app"]
  node_settings["Input settings<br/>[settings.cpp]"]
  node_catalog["Theme catalog<br/>[theme_catalog.cpp]"]
  node_manifest["Theme manifest<br/>[theme_manifest.cpp]"]
  node_ssf_import["SSF importer"]
  node_ssf_container["SSF container reader"]
end

node_user(("Windows user"))
node_host["Windows app"]

node_user -->|"types in"| node_host
node_host -->|"receives input"| node_tsf
node_tsf -->|"sends requests"| node_pipeclient
node_pipeclient -->|"exchanges messages"| node_pipe
node_broker_main -->|"starts server"| node_pipe
node_pipe -->|"dispatches requests"| node_session
node_session -->|"creates sessions"| node_engine
node_session -->|"creates fallback"| node_stub
node_pipeclient -->|"encodes requests"| node_protocol
node_pipe -->|"handles messages"| node_protocol
node_tsf -->|"presents candidates"| node_candidate
node_settings_ui -->|"reads and saves"| node_settings
node_settings_ui -->|"manages themes"| node_catalog
node_catalog -->|"loads manifests"| node_manifest
node_settings_ui -->|"imports skins"| node_ssf_import
node_ssf_import -->|"produces theme data"| node_manifest
node_ssf_import -.->|"reads packages"| node_ssf_container
node_candidate -->|"loads theme resources"| node_catalog
node_settings_ui -->|"previews appearance"| node_candidate

click node_tsf "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/tsf/src/text_service.cpp"
click node_pipeclient "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_client.cpp"
click node_pipe "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_server.cpp"
click node_broker_main "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/broker/src/broker_main.cpp"
click node_session "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/session_host.cpp"
click node_engine "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/broker/src/rime_engine.cpp"
click node_stub "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/stub_engine.cpp"
click node_protocol "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/ipc_protocol.cpp"
click node_candidate "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ui/src/candidate_window.cpp"
click node_settings_ui "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/MainWindow.xaml.cpp"
click node_settings "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/settings.cpp"
click node_catalog "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/theme_catalog.cpp"
click node_manifest "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/theme_manifest.cpp"
click node_ssf_import "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/sogou_theme_import.cpp"
click node_ssf_container "https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/sogou_ssf_container.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tsf,node_pipeclient,node_user toneBlue
class node_pipe,node_broker_main,node_session,node_engine,node_stub,node_protocol toneAmber
class node_candidate toneMint
class node_settings_ui,node_settings,node_catalog,node_manifest,node_ssf_import,node_ssf_container toneRose
class node_host toneIndigo
```

## Components

### Windows input

- [TSF text service](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/tsf/src/text_service.cpp): `src/tsf/src/text_service.cpp`
- [Pipe client](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_client.cpp): `src/ipc/src/pipe_client.cpp`

### Engine broker

- [Named-pipe server](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ipc/src/pipe_server.cpp): `src/ipc/src/pipe_server.cpp`
- [Broker process](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/broker/src/broker_main.cpp): `src/broker/src/broker_main.cpp`
- [Session host](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/session_host.cpp): `src/core/src/session_host.cpp`
- [Rime engine](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/broker/src/rime_engine.cpp): `src/broker/src/rime_engine.cpp`
- [Development engine](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/stub_engine.cpp): `src/core/src/stub_engine.cpp`
- [IPC protocol](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/ipc_protocol.cpp): `src/core/src/ipc_protocol.cpp`

### Candidates and themes

- [Candidate window](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/ui/src/candidate_window.cpp): `src/ui/src/candidate_window.cpp`

### Settings and themes

- [Settings app](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/MainWindow.xaml.cpp): `src/settings/MainWindow.xaml.cpp`
- [Input settings](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/settings.cpp): `src/core/src/settings.cpp`
- [Theme catalog](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/theme_catalog.cpp): `src/core/src/theme_catalog.cpp`
- [Theme manifest](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/core/src/theme_manifest.cpp): `src/core/src/theme_manifest.cpp`
- [SSF importer](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/sogou_theme_import.cpp): `src/settings/sogou_theme_import.cpp`
- [SSF container reader](https://github.com/matsuokajuri/ziliu-ime/blob/main/src/settings/sogou_ssf_container.cpp): `src/settings/sogou_ssf_container.cpp`

### Other components

- **Windows user**
- **Windows app**

## Connections

- Windows user → Windows app: types in (evidence: `README.md`)
- Windows app → TSF text service: receives input (evidence: `README.md`)
- TSF text service → Pipe client: sends requests (evidence: `src/tsf/src/text_service.cpp`)
- Pipe client → Named-pipe server: exchanges messages (evidence: `README.md`)
- Broker process → Named-pipe server: starts server (evidence: `src/broker/src/broker_main.cpp`)
- Named-pipe server → Session host: dispatches requests
- Session host → Rime engine: creates sessions
- Session host → Development engine: creates fallback (evidence: `src/core/src/session_host.cpp`)
- Pipe client → IPC protocol: encodes requests
- Named-pipe server → IPC protocol: handles messages
- TSF text service → Candidate window: presents candidates (evidence: `src/tsf/src/text_service.cpp`)
- Settings app → Input settings: reads and saves (evidence: `src/settings/MainWindow.xaml.cpp`)
- Settings app → Theme catalog: manages themes
- Theme catalog → Theme manifest: loads manifests
- Settings app → SSF importer: imports skins (evidence: `src/settings/MainWindow.xaml.cpp`)
- SSF importer → Theme manifest: produces theme data
- SSF importer → SSF container reader: reads packages
- Candidate window → Theme catalog: loads theme resources (evidence: `src/ui/src/candidate_window.cpp`)
- Settings app → Candidate window: previews appearance
