# koyasi777/mozkey architecture

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

- Interactive diagram: https://gitdiagram.com/koyasi777/mozkey
- Repository: https://github.com/koyasi777/mozkey

## Overview

Mozkey is a Mozc-based Japanese IME for Windows and macOS. The user enters kana or romaji through an OS input method; Mozc handles conversion and suggestions, while documented live conversion and optional local Zenz correction augment the result for candidate display and selection. Configuration, dictionaries, and learning history support that workflow. The README documents the Zenz and live-conversion behavior; sampled source supports selected client, renderer, engine-output, and storage relationships, but does not show the full Zenz wiring.

Main entry points: [`src/engine/engine_converter.cc`](https://github.com/koyasi777/mozkey/blob/main/src/engine/engine_converter.cc) (Engine converter), [`src/renderer/renderer_server.cc`](https://github.com/koyasi777/mozkey/blob/main/src/renderer/renderer_server.cc) (Candidate UI), [`src/unix/ibus/mozc_engine.cc`](https://github.com/koyasi777/mozkey/blob/main/src/unix/ibus/mozc_engine.cc) (OS input method), [`src/client/client.cc`](https://github.com/koyasi777/mozkey/blob/main/src/client/client.cc) (IME client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and UI"]
  node_os_input["OS input method<br/>[mozc_engine.cc]"]
  node_client["IME client<br/>[client.cc]"]
  node_renderer["Candidate UI<br/>[renderer_server.cc]"]
end

subgraph group_conversion["Conversion pipeline"]
  node_composer["Romaji composer<br/>[composer.cc]"]
  node_session["Session handler<br/>[session_handler.cc]"]
  node_engine_converter["Engine converter"]
  node_converter["Kana conversion<br/>[converter.cc]"]
  node_prediction["Prediction<br/>[predictor.cc]"]
  node_rewriters["Candidate rewriting<br/>[rewriter.cc]"]
  node_output["Engine output<br/>[engine_output.cc]"]
end

subgraph group_knowledge["Language data and learning"]
  node_data_manager["Data manager<br/>[data_manager.cc]"]
  node_dictionary["System dictionary<br/>[dictionary_impl.cc]"]
  node_user_dictionary[("User dictionary")]
  node_history[("Learning history")]
end

subgraph group_zenz["Zenz correction"]
  node_zenz["Local Zenz scorer<br/>[main.cc]"]
end

subgraph group_platform["Platform services"]
  node_config["IME configuration<br/>[config_handler.cc]"]
  node_ipc["Process IPC<br/>[ipc.cc]"]
  node_lru[("Persistent LRU<br/>[lru_storage.cc]")]
end

node_user(("IME user"))

node_user -->|"types into"| node_os_input
node_os_input -->|"forwards input"| node_client
node_client -.->|"sends commands"| node_session
node_session -.->|"updates composition"| node_composer
node_session -.->|"requests conversion"| node_engine_converter
node_engine_converter -.->|"converts reading"| node_converter
node_engine_converter -.->|"requests suggestions"| node_prediction
node_engine_converter -.->|"rewrites candidates"| node_rewriters
node_engine_converter -->|"formats results"| node_output
node_output -.->|"supplies candidates"| node_renderer
node_renderer -->|"shows candidates"| node_user
node_user -->|"selects candidate"| node_renderer
node_engine_converter -.->|"applies correction"| node_zenz
node_zenz -.->|"returns correction"| node_engine_converter
node_data_manager -->|"loads dictionary data"| node_dictionary
node_engine_converter -.->|"uses user words"| node_user_dictionary
node_engine_converter -.->|"learns selections"| node_history
node_os_input -->|"uses renderer client"| node_renderer
node_client -->|"uses IPC interface"| node_ipc
node_config -->|"persists character forms"| node_lru
node_engine_converter -.->|"uses conversion settings"| node_config

click node_os_input "https://github.com/koyasi777/mozkey/blob/main/src/unix/ibus/mozc_engine.cc"
click node_client "https://github.com/koyasi777/mozkey/blob/main/src/client/client.cc"
click node_composer "https://github.com/koyasi777/mozkey/blob/main/src/composer/composer.cc"
click node_session "https://github.com/koyasi777/mozkey/blob/main/src/session/session_handler.cc"
click node_engine_converter "https://github.com/koyasi777/mozkey/blob/main/src/engine/engine_converter.cc"
click node_converter "https://github.com/koyasi777/mozkey/blob/main/src/converter/converter.cc"
click node_prediction "https://github.com/koyasi777/mozkey/blob/main/src/prediction/predictor.cc"
click node_rewriters "https://github.com/koyasi777/mozkey/blob/main/src/rewriter/rewriter.cc"
click node_output "https://github.com/koyasi777/mozkey/blob/main/src/engine/engine_output.cc"
click node_renderer "https://github.com/koyasi777/mozkey/blob/main/src/renderer/renderer_server.cc"
click node_config "https://github.com/koyasi777/mozkey/blob/main/src/config/config_handler.cc"
click node_data_manager "https://github.com/koyasi777/mozkey/blob/main/src/data_manager/data_manager.cc"
click node_dictionary "https://github.com/koyasi777/mozkey/blob/main/src/dictionary/dictionary_impl.cc"
click node_user_dictionary "https://github.com/koyasi777/mozkey/blob/main/src/dictionary/user_dictionary_storage.cc"
click node_history "https://github.com/koyasi777/mozkey/blob/main/src/prediction/user_history_storage.cc"
click node_zenz "https://github.com/koyasi777/mozkey/blob/main/src/zenz_scorer/main.cc"
click node_ipc "https://github.com/koyasi777/mozkey/blob/main/src/ipc/ipc.cc"
click node_lru "https://github.com/koyasi777/mozkey/blob/main/src/storage/lru_storage.cc"

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_os_input,node_client,node_renderer,node_user toneBlue
class node_composer,node_session,node_engine_converter,node_converter,node_prediction,node_rewriters,node_output toneAmber
class node_data_manager,node_dictionary,node_user_dictionary,node_history toneMint
class node_zenz toneRose
class node_config,node_ipc,node_lru toneIndigo
```

## Components

### Input and UI

- [OS input method](https://github.com/koyasi777/mozkey/blob/main/src/unix/ibus/mozc_engine.cc): `src/unix/ibus/mozc_engine.cc`
- [IME client](https://github.com/koyasi777/mozkey/blob/main/src/client/client.cc): `src/client/client.cc`
- [Candidate UI](https://github.com/koyasi777/mozkey/blob/main/src/renderer/renderer_server.cc): `src/renderer/renderer_server.cc`

### Conversion pipeline

- [Romaji composer](https://github.com/koyasi777/mozkey/blob/main/src/composer/composer.cc): `src/composer/composer.cc`
- [Session handler](https://github.com/koyasi777/mozkey/blob/main/src/session/session_handler.cc): `src/session/session_handler.cc`
- [Engine converter](https://github.com/koyasi777/mozkey/blob/main/src/engine/engine_converter.cc): `src/engine/engine_converter.cc`
- [Kana conversion](https://github.com/koyasi777/mozkey/blob/main/src/converter/converter.cc): `src/converter/converter.cc`
- [Prediction](https://github.com/koyasi777/mozkey/blob/main/src/prediction/predictor.cc): `src/prediction/predictor.cc`
- [Candidate rewriting](https://github.com/koyasi777/mozkey/blob/main/src/rewriter/rewriter.cc): `src/rewriter/rewriter.cc`
- [Engine output](https://github.com/koyasi777/mozkey/blob/main/src/engine/engine_output.cc): `src/engine/engine_output.cc`

### Language data and learning

- [Data manager](https://github.com/koyasi777/mozkey/blob/main/src/data_manager/data_manager.cc): `src/data_manager/data_manager.cc`
- [System dictionary](https://github.com/koyasi777/mozkey/blob/main/src/dictionary/dictionary_impl.cc): `src/dictionary/dictionary_impl.cc`
- [User dictionary](https://github.com/koyasi777/mozkey/blob/main/src/dictionary/user_dictionary_storage.cc): `src/dictionary/user_dictionary_storage.cc`
- [Learning history](https://github.com/koyasi777/mozkey/blob/main/src/prediction/user_history_storage.cc): `src/prediction/user_history_storage.cc`

### Zenz correction

- [Local Zenz scorer](https://github.com/koyasi777/mozkey/blob/main/src/zenz_scorer/main.cc): `src/zenz_scorer/main.cc`

### Platform services

- [IME configuration](https://github.com/koyasi777/mozkey/blob/main/src/config/config_handler.cc): `src/config/config_handler.cc`
- [Process IPC](https://github.com/koyasi777/mozkey/blob/main/src/ipc/ipc.cc): `src/ipc/ipc.cc`
- [Persistent LRU](https://github.com/koyasi777/mozkey/blob/main/src/storage/lru_storage.cc): `src/storage/lru_storage.cc`

### Other components

- **IME user**

## Connections

- IME user → OS input method: types into
- OS input method → IME client: forwards input (evidence: `src/unix/ibus/mozc_engine.cc`)
- IME client → Session handler: sends commands
- Session handler → Romaji composer: updates composition
- Session handler → Engine converter: requests conversion
- Engine converter → Kana conversion: converts reading
- Engine converter → Prediction: requests suggestions
- Engine converter → Candidate rewriting: rewrites candidates
- Engine converter → Engine output: formats results (evidence: `src/engine/engine_output.cc`)
- Engine output → Candidate UI: supplies candidates
- Candidate UI → IME user: shows candidates
- IME user → Candidate UI: selects candidate
- Engine converter → Local Zenz scorer: applies correction
- Local Zenz scorer → Engine converter: returns correction
- Data manager → System dictionary: loads dictionary data (evidence: `src/data_manager/data_manager.cc`)
- Engine converter → User dictionary: uses user words
- Engine converter → Learning history: learns selections
- OS input method → Candidate UI: uses renderer client (evidence: `src/unix/ibus/mozc_engine.cc`)
- IME client → Process IPC: uses IPC interface
- IME configuration → Persistent LRU: persists character forms
- Engine converter → IME configuration: uses conversion settings
