Skip to content

Architecture

NtGitG edited this page Jun 12, 2026 · 1 revision

Architecture

High-level map of the mod — enough to find your way in the code, not a full class diagram.

Startup

MineGlot (Forge) → MineGlotLifecycle
                 → ServiceManager (config, DB, cache, translation, events, Lingua)
                 → ClientShutdownManager (clean exit)

Translation paths

Commands

/translate, /translation → handler → TranslationOrchestrator
                                    → ValidationService
                                    → TranslationCacheApiFlow (cache → API → render)
/translation without text → ChatSelectionDecorator
                          → existing GuiNewChat lines become clickable
                          → click runs /translation <line>

Incoming chat

ClientChatReceivedEvent → ChatMessageInterceptor
                       → ChatMessageParser (player + message)
                       → ChatTranslationFilter (target list, chat shape)
                       → TranslationOrchestrator (same cache/API flow)

While selection mode is active, ChatSelectionEventHandler also marks newly received chat lines as clickable.

Cache and API flow

TranslationOrchestrator
    → fast unified cache hit? (text + target lang, skip language detection)
    → else TranslationContextResolver (Lingua if needed)
    → TranslationCacheApiFlow
          → contextual cache (text + source + target + model)
          → API via AbstractAIEngine (OpenAI / Claude)
          → store memory + RocksDB
Layer Role
TranslationMemoryCache Hot entries in RAM
TranslationStorage / RocksDB Persistent cache on disk
Recent miss TTL Avoids hammering DB on repeated misses

Main packages

Area Key classes
Translation TranslationOrchestrator, TranslationCacheApiFlow, TranslationRenderer
Chat ChatMessageParser, ChatTranslationFilter, ChatMessageInterceptor
Cache / DB TranslationCache, DatabaseService, TranslationStorage
AI AbstractAIEngine, parsers for OpenAI / Claude
Config ConfigurationManager, ModConfig
UI ScreenManager, screens under ui/gui/screens/
Commands CommandManager, handlers under core/command/

Tests

Logic that does not need Minecraft is covered under src/test/java (parser, cache, storage keys, retry policy, API request builders).

Run:

.\gradlew.bat test --no-daemon

Clone this wiki locally