# fkunn1326/azookey-windows architecture

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

- Interactive diagram: https://gitdiagram.com/fkunn1326/azookey-windows
- Repository: https://github.com/fkunn1326/azookey-windows

## Overview

##### Main Components
- Client Component (Rust):
- Located under the “crates/client” directory.
- Contains the TSF (Text Service Framework) integration modules (e.g., tsf folder) and engine code responsible for input handling, text conversion, and IPC with other parts.
- Server Component (Rust):
- Found in “crates/server” which holds code for potentially managing background services or conversion logic.
- Launcher:
- Present in “crates/launcher”; this component is used to initiate and manage the lifecycle of the conversion engine.
- Shared Library:
- Under “crates/shared”, providing common types and Protocol Buffers definitions (service.proto and window.proto) for inter-module messaging and integration.
- UI Component:
- Within “crates/ui”, which likely handles UI elements such as candidate lists or indicators used during conversion.
- Frontend:
- The “frontend” directory shows that a Tauri-based frontend is used. This part involves a web-based UI (with TypeScript/React TSX components) and native Rust bindings (via the “src-tauri” module) for integration.
- Additional Components:
- “crates/macros” for common macros shared across the Rust crates.
- “server-swift” directory indicates that a Swift-based server (or bridging code) exists, probably to support some native Windows functionality or as an additional backend path via FFI.

##### Interactions & Relationships
- The Client communicates with the Windows TSF subsystem, receiving key events and sending converted text.
- The Client also talks to the Launcher to start and manage the conversion engine.
- Shared libraries provide common protocols and helper logic ensuring consistency across the client, server, and UI components.
- The Server (in Rust) may host backend services such as conversion processing or state management, interacting with the Client via IPC.
- The UI component handles user interactions (e.g., candidate selection) and indicates the conversion status, receiving inputs from the Client/Server.
- The Frontend (Tauri) bridges the web-based UI with native functionality; it interacts with the underlying Rust backend and possibly exposes configuration or debugging tools.
- Finally, the Swift-based server side (“server-swift”) likely interfaces with the conversion engine or other system-level services through a C/FFI layer.

##### Architectural Patterns & Technologies
- Multi-language / Multi-process Architecture: Multiple crates and languages (Rust, Swift, TypeScript) are integrated, typically via clearly defined interfaces (e.g., Protocol Buffers and IPC).
- Modular Design: The project uses a monorepo layout where each subcomponent (client, server, UI, launcher) is encapsulated as its own crate/module.
- Windows TSF Integration: Emphasize the TSF (Text Service Framework) integration in the client engine for handling IME functionalities.
- Tauri for Desktop UI: The frontend uses Tauri to bridge web technologies with native code.
- Build & Deployment: The existence of build scripts, cargo-make files, and installer scripts (Inno Setup) informs how components are packaged or deployed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Component
    EX["Windows TSF Subsystem"]:::external

    %% Rust Components Subgraph
    subgraph "Rust Components"
        L["Launcher [Rust]"]:::rust
        C["Client Engine (TSF Integration) [Rust]"]:::rust
        S["Server (Conversion Service) [Rust]"]:::rust
        SH["Shared Libraries (Protobuf & Common Types) [Rust]"]:::rust
        U["UI Module (Candidate List & Indicators) [Rust]"]:::rust
        M["Common Macros (Rust)"]:::rust
    end

    %% Frontend Components Subgraph
    subgraph "Frontend Components"
        F["Frontend Web UI (Tauri, TS/React)"]:::tauri
        NB["Native Bindings (Rust, src-tauri)"]:::tauri
    end

    %% Swift Component
    SW["Swift Server & FFI (Swift)"]:::swift

    %% Relationships
    EX -->|"TSF_events"| C
    L -->|"launch_client"| C
    C <-->|"IPC_communication"| S
    C -->|"update_UI"| U
    S -->|"conversion_results"| U
    SH -->|"shared_dependency"| C
    SH -->|"shared_dependency"| S
    SH -->|"shared_dependency"| U
    U -->|"UI_interaction"| F
    F -->|"native_bridge"| NB
    SW -->|"FFI_interaction"| S

    %% Click Events
    click C "https://github.com/fkunn1326/azookey-windows/tree/master/crates/client/src/tsf"
    click S "https://github.com/fkunn1326/azookey-windows/tree/master/crates/server"
    click L "https://github.com/fkunn1326/azookey-windows/tree/master/crates/launcher"
    click SH "https://github.com/fkunn1326/azookey-windows/tree/master/crates/shared"
    click U "https://github.com/fkunn1326/azookey-windows/tree/master/crates/ui"
    click M "https://github.com/fkunn1326/azookey-windows/tree/master/crates/macros"
    click F "https://github.com/fkunn1326/azookey-windows/tree/master/frontend"
    click NB "https://github.com/fkunn1326/azookey-windows/tree/master/frontend/src-tauri"
    click SW "https://github.com/fkunn1326/azookey-windows/tree/master/server-swift"

    %% Styles
    classDef rust fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef tauri fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef swift fill:#ffa500,stroke:#333,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
