# binbingwu/multi-agent-game-localizer architecture

> Architecture diagram of the GitHub repository binbingwu/multi-agent-game-localizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/binbingwu/multi-agent-game-localizer
- Repository: https://github.com/binbingwu/multi-agent-game-localizer

## Overview

Hanhua is a project-based game-localization CLI: it extracts engine-specific text, builds linguistic context, translates batches locally, applies rule-based QA and retries, then builds and optionally installs a validated patch. The README documents human review/import-export and smoke-test capabilities. Sampled source confirms orchestration, extraction, context, translation, QA, and the System 4 plugin; build-agent internals are represented only at the documented subsystem level.

Main entry points: [`hanhua/orchestrator.py`](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/orchestrator.py) (Pipeline scheduler), [`hanhua/agents/translation.py`](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/translation.py) (Batch translation), [`hanhua/db.py`](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/db.py) (Project database), [`hanhua/agents/context.py`](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/context.py) (Context analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Project workflow"]
  node_cli["CLI commands<br/>[__main__.py]"]
  node_orchestrator["Pipeline scheduler<br/>[orchestrator.py]"]
  node_strategy["Translation strategy<br/>[orchestrator.py]"]
  node_review["Human review<br/>[__main__.py]"]
  node_build["Build and install<br/>[build.py]"]
end

subgraph group_linguistics["Translation pipeline"]
  node_context["Context analysis<br/>[context.py]"]
  node_glossary["Glossary and scenes<br/>[context.py]"]
  node_translation["Batch translation<br/>[translation.py]"]
  node_qa["Translation QA<br/>[qa.py]"]
  node_language["Language profiles<br/>[langs.py]"]
  node_llm["Local LLM client<br/>[llm.py]"]
end

subgraph group_engine["Engine integration"]
  node_extract["Text extraction<br/>[extraction.py]"]
  node_system4["System 4 plugin<br/>[plugin.py]"]
  node_engine_api["Engine registry<br/>[__init__.py]"]
end

subgraph group_state["Project state"]
  node_state_db[("Project database<br/>[db.py]")]
  node_workspace["Project workspace<br/>[common.py]"]
end

node_user(("Localizer"))
node_inference["Local model server"]
node_game["Game resources"]
node_patch["Localization patch"]

node_user -->|"runs commands"| node_cli
node_cli -->|"starts workflow"| node_orchestrator
node_cli -->|"imports or exports"| node_review
node_review -->|"updates translations"| node_state_db
node_orchestrator -->|"loads project"| node_workspace
node_orchestrator -->|"selects plugin"| node_engine_api
node_engine_api -->|"resolves engine"| node_system4
node_orchestrator -->|"runs extraction"| node_extract
node_extract -->|"backs up and extracts"| node_system4
node_system4 -->|"reads resources"| node_game
node_extract -->|"stores text units"| node_state_db
node_orchestrator -->|"creates or loads"| node_strategy
node_orchestrator -->|"runs context stage"| node_context
node_context -->|"reads units and scenes"| node_state_db
node_context -->|"builds summaries"| node_glossary
node_context -->|"requests analysis"| node_llm
node_context -->|"saves context"| node_state_db
node_orchestrator -->|"runs translation stage"| node_translation
node_translation -->|"loads and saves batches"| node_state_db
node_translation -->|"uses context"| node_glossary
node_translation -->|"uses instructions"| node_strategy
node_translation -->|"requests translations"| node_llm
node_llm -->|"sends prompts"| node_inference
node_inference -->|"returns completions"| node_llm
node_translation -->|"checks batches"| node_qa
node_qa -->|"records results"| node_state_db
node_qa -->|"returns failed lines"| node_translation
node_orchestrator -->|"checks pending lines"| node_qa
node_orchestrator -->|"runs build stage"| node_build
node_build -->|"loads translations"| node_state_db
node_build -->|"builds and validates"| node_system4
node_system4 -->|"writes patched files"| node_patch
node_build -->|"installs or restores"| node_game
node_translation -->|"uses target rules"| node_language
node_qa -->|"uses QA profiles"| node_language

click node_cli "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/__main__.py"
click node_orchestrator "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/orchestrator.py"
click node_strategy "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/orchestrator.py"
click node_review "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/__main__.py"
click node_build "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/build.py"
click node_extract "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/extraction.py"
click node_system4 "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/engines/system4/plugin.py"
click node_engine_api "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/engines/__init__.py"
click node_context "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/context.py"
click node_glossary "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/context.py"
click node_translation "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/translation.py"
click node_qa "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/qa.py"
click node_language "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/langs.py"
click node_llm "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/llm.py"
click node_state_db "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/db.py"
click node_workspace "https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/common.py"

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_cli,node_orchestrator,node_strategy,node_review,node_build toneBlue
class node_context,node_glossary,node_translation,node_qa,node_language,node_llm toneAmber
class node_extract,node_system4,node_engine_api,node_inference toneMint
class node_state_db,node_workspace toneRose
class node_user,node_game,node_patch toneIndigo
```

## Components

### Project workflow

- [CLI commands](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/__main__.py): `hanhua/__main__.py`
- [Pipeline scheduler](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/orchestrator.py): `hanhua/orchestrator.py`
- [Translation strategy](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/orchestrator.py): `hanhua/orchestrator.py`
- [Human review](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/__main__.py): `hanhua/__main__.py`
- [Build and install](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/build.py): `hanhua/agents/build.py`

### Translation pipeline

- [Context analysis](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/context.py): `hanhua/agents/context.py`
- [Glossary and scenes](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/context.py): `hanhua/agents/context.py`
- [Batch translation](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/translation.py): `hanhua/agents/translation.py`
- [Translation QA](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/qa.py): `hanhua/agents/qa.py`
- [Language profiles](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/langs.py): `hanhua/langs.py`
- [Local LLM client](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/llm.py): `hanhua/llm.py`

### Engine integration

- [Text extraction](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/agents/extraction.py): `hanhua/agents/extraction.py`
- [System 4 plugin](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/engines/system4/plugin.py): `hanhua/engines/system4/plugin.py`
- [Engine registry](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/engines/__init__.py): `hanhua/engines/__init__.py`

### Project state

- [Project database](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/db.py): `hanhua/db.py`
- [Project workspace](https://github.com/binbingwu/multi-agent-game-localizer/blob/main/hanhua/common.py): `hanhua/common.py`

### Other components

- **Localizer**
- **Local model server**
- **Game resources**
- **Localization patch**

## Connections

- Localizer → CLI commands: runs commands
- CLI commands → Pipeline scheduler: starts workflow
- CLI commands → Human review: imports or exports
- Human review → Project database: updates translations
- Pipeline scheduler → Project workspace: loads project
- Pipeline scheduler → Engine registry: selects plugin
- Engine registry → System 4 plugin: resolves engine
- Pipeline scheduler → Text extraction: runs extraction
- Text extraction → System 4 plugin: backs up and extracts
- System 4 plugin → Game resources: reads resources
- Text extraction → Project database: stores text units
- Pipeline scheduler → Translation strategy: creates or loads
- Pipeline scheduler → Context analysis: runs context stage
- Context analysis → Project database: reads units and scenes
- Context analysis → Glossary and scenes: builds summaries
- Context analysis → Local LLM client: requests analysis
- Context analysis → Project database: saves context
- Pipeline scheduler → Batch translation: runs translation stage
- Batch translation → Project database: loads and saves batches
- Batch translation → Glossary and scenes: uses context
- Batch translation → Translation strategy: uses instructions
- Batch translation → Local LLM client: requests translations
- Local LLM client → Local model server: sends prompts
- Local model server → Local LLM client: returns completions
- Batch translation → Translation QA: checks batches
- Translation QA → Project database: records results
- Translation QA → Batch translation: returns failed lines
- Pipeline scheduler → Translation QA: checks pending lines
- Pipeline scheduler → Build and install: runs build stage
- Build and install → Project database: loads translations
- Build and install → System 4 plugin: builds and validates
- System 4 plugin → Localization patch: writes patched files
- Build and install → Game resources: installs or restores
- Batch translation → Language profiles: uses target rules
- Translation QA → Language profiles: uses QA profiles
