# google/mozc architecture

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

- Interactive diagram: https://gitdiagram.com/google/mozc
- Repository: https://github.com/google/mozc

## Overview

##### Main Components Overview
The system should be divided into these major components:

a. Core Engine Components:
- Dictionary System (/src/dictionary)
- Converter (/src/converter)
- Prediction System (/src/prediction)
- Rewriter System (/src/rewriter)
- Session Manager (/src/session)

b. Platform-Specific UI Components:
- Windows (TSF/IMM) (/src/win32)
- macOS (/src/mac)
- Linux/IBus (/src/unix/ibus)
- Android (/src/android)

c. Supporting Systems:
- IPC Layer (/src/ipc)
- Renderer (/src/renderer)
- Storage (/src/storage)
- Base Utilities (/src/base)

##### Component Relationships

**[User Interface Layer]**
- Windows/Mac/Linux/Android UI
- ↕
**[IPC Communication Layer]**
- ↕
**[Session Management]**
- ↕
**[Core Engine]**
- ↙     ↓     ↘
**Dictionary  Converter  Prediction**
- ↘     ↓     ↙
- Rewriter System
- ↕
**[Storage Layer]**

##### Specific Implementation Details

Key architectural elements:
- Server-client architecture (mozc_server, mozc_renderer)
- Dictionary management system
- Configuration system (/src/config)
- Platform-specific input handling
- Rendering system for candidate windows

##### Data Flow Indicators

Show:
- Input flow from UI to core engine
- Dictionary lookup paths
- Conversion result paths
- Configuration data flow
- IPC communication paths

##### Notes for Implementation Details

Callouts for:
- Multi-platform support mechanisms
- Dictionary data structures
- IPC mechanisms
- Threading model
- Resource management

Remember to emphasize the modular nature of the system and how different components can be swapped out for different platforms while maintaining the core conversion engine's integrity.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef ui fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef ipc fill:#FFE5CC,stroke:#333,stroke-width:2px
    classDef storage fill:#FFB366,stroke:#333,stroke-width:2px
    classDef platform fill:#E6E6FA,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph UI
        WIN["Windows UI (TSF/IMM)"]:::platform
        MAC["macOS UI"]:::platform
        LIN["Linux/IBus UI"]:::platform
        AND["Android UI"]:::platform
        UITOOLS["UI Tools"]:::ui
    end

    %% IPC and Communication
    IPC["IPC Layer"]:::ipc
    RENDER["Renderer System"]:::ui
    PROTO["Protocol Definitions"]:::ipc

    %% Core Engine Components
    subgraph CoreEngine
        SESSION["Session Manager"]:::core
        CONV["Converter"]:::core
        DICT["Dictionary System"]:::core
        PRED["Prediction System"]:::core
        REW["Rewriter System"]:::core
        ENGINE["Engine Core"]:::core
    end

    %% Supporting Systems
    CONFIG["Configuration System"]:::core
    STORAGE["Storage System"]:::storage
    BASE["Base Utilities"]:::core
    DATA["Data Manager"]:::storage

    %% Relationships
    WIN & MAC & LIN & AND --> IPC
    UITOOLS --> IPC
    IPC --> SESSION
    IPC --> PROTO
    SESSION --> ENGINE
    ENGINE --> CONV & DICT & PRED
    CONV & DICT & PRED --> REW
    REW --> STORAGE
    BASE --> CoreEngine
    DATA --> STORAGE
    CONFIG --> CoreEngine
    RENDER --> UI

    %% Click Events
    click WIN "https://github.com/google/mozc/tree/master/src/win32/"
    click MAC "https://github.com/google/mozc/tree/master/src/mac/"
    click LIN "https://github.com/google/mozc/tree/master/src/unix/ibus/"
    click AND "https://github.com/google/mozc/tree/master/src/android/"
    click IPC "https://github.com/google/mozc/tree/master/src/ipc/"
    click RENDER "https://github.com/google/mozc/tree/master/src/renderer/"
    click SESSION "https://github.com/google/mozc/tree/master/src/session/"
    click CONV "https://github.com/google/mozc/tree/master/src/converter/"
    click DICT "https://github.com/google/mozc/tree/master/src/dictionary/"
    click PRED "https://github.com/google/mozc/tree/master/src/prediction/"
    click REW "https://github.com/google/mozc/tree/master/src/rewriter/"
    click ENGINE "https://github.com/google/mozc/tree/master/src/engine/"
    click PROTO "https://github.com/google/mozc/tree/master/src/protocol/"
    click CONFIG "https://github.com/google/mozc/tree/master/src/config/"
    click STORAGE "https://github.com/google/mozc/tree/master/src/storage/"
    click BASE "https://github.com/google/mozc/tree/master/src/base/"
    click UITOOLS "https://github.com/google/mozc/tree/master/src/gui/"
    click DATA "https://github.com/google/mozc/tree/master/src/data_manager/"

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Core Components"]:::core
        L3["IPC Components"]:::ipc
        L4["Storage Components"]:::storage
        L5["Platform-Specific"]:::platform
    end
```
