# hongt-chen/pinyin_to_ja architecture

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

- Interactive diagram: https://gitdiagram.com/hongt-chen/pinyin_to_ja
- Repository: https://github.com/hongt-chen/pinyin_to_ja

## Overview

This repository contains separate English- and Chinese-to-katakana converters. The Chinese CLI converts input through pinyin and a JSON mapping while preserving non-Chinese characters; the English module uses G2P phonemes and katakana conversion rules. Source excerpts show the conversion logic but omit parts of the English runtime path, and the web page is unsampled, so those connections are not inferred.

Main entry points: [`to_kana/pinyin/main.py`](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/main.py) (Chinese converter), [`to_kana/english/main.py`](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/english/main.py) (English CLI), [`to_kana/pinyin/data.json`](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/data.json) (Pinyin kana map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_english["English conversion"]
  node_english_cli["English CLI<br/>[main.py]"]
  node_english_converter["English converter<br/>[main.py]"]
  node_g2p["G2P engine"]
end

subgraph group_chinese["Chinese conversion"]
  node_chinese_cli["Chinese CLI<br/>[main.py]"]
  node_chinese_converter["Chinese converter<br/>[main.py]"]
  node_pypinyin["Pinyin library"]
  node_kana_map["Pinyin kana map<br/>[data.json]"]
end

node_user(("User"))

node_english_cli -->|"prewarms"| node_g2p
node_english_converter -->|"generates phonemes"| node_g2p
node_user -->|"enters text"| node_chinese_cli
node_chinese_cli -->|"converts input"| node_chinese_converter
node_chinese_converter -->|"gets pinyin"| node_pypinyin
node_chinese_converter -->|"looks up kana"| node_kana_map

click node_english_cli "https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/english/main.py"
click node_english_converter "https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/english/main.py"
click node_chinese_cli "https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/main.py"
click node_chinese_converter "https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/main.py"
click node_kana_map "https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/data.json"

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_english_cli,node_english_converter,node_g2p,node_user toneBlue
class node_chinese_cli,node_chinese_converter,node_pypinyin,node_kana_map toneAmber
```

## Components

### English conversion

- [English CLI](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/english/main.py): `to_kana/english/main.py`
- [English converter](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/english/main.py): `to_kana/english/main.py`
- **G2P engine**

### Chinese conversion

- [Chinese CLI](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/main.py): `to_kana/pinyin/main.py`
- [Chinese converter](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/main.py): `to_kana/pinyin/main.py`
- **Pinyin library**
- [Pinyin kana map](https://github.com/hongt-chen/pinyin_to_ja/blob/main/to_kana/pinyin/data.json): `to_kana/pinyin/data.json`

### Other components

- **User**

## Connections

- English CLI → G2P engine: prewarms (evidence: `to_kana/english/main.py`)
- English converter → G2P engine: generates phonemes (evidence: `to_kana/english/main.py`)
- User → Chinese CLI: enters text (evidence: `to_kana/pinyin/main.py`)
- Chinese CLI → Chinese converter: converts input (evidence: `to_kana/pinyin/main.py`)
- Chinese converter → Pinyin library: gets pinyin (evidence: `to_kana/pinyin/main.py`)
- Chinese converter → Pinyin kana map: looks up kana (evidence: `to_kana/pinyin/main.py`)
