Architecture
Single-file SPA (HTML/CSS/JS) with an IIFE runtime, direct DOM updates, and localStorage persistence. Main layers: UI surfaces, input handlers, suggestion/learning engine, settings subsystem, import/export pipeline.
Goal: deterministic behavior with local-first data and no backend dependency.
State and persistence
Core stores: settings, userDict, history, bigrams (pair+meta), glossaries, presets, sailor palettes, draft text, backup timestamps. All stores use normalization helpers for backward compatibility and safe defaults.
Pattern: load -> normalize -> mutate in memory -> saveJSON -> targeted rerender.
Input engine
Supports keyboard shortcuts, pointer selection, optional dwell activation, and optional gamepad control. Radial navigation uses ring/segment targeting and utility focus states.
Gamepad mapping is fully configurable (buttons, deadzone, repeat, axis mode).
Suggestion engine
Multi-source ranking: user dictionary frequency + active glossary entries + bigram next-word candidates in PREFIX_NEXT mode. Supports case/diacritics normalization toggles and class-based letter filtering.
Modes: PREFIX (current token) and PREFIX_NEXT (current token + previous-word prediction).
Learning and bigrams
Words are learned from delimiters/copy/save/manual flows. Bigrams are case-sensitive and track metadata provenance (text, suggestion, manual, mixed). Suggestion-click learning can be toggled.
Bigram panel updates live when learning occurs.
Radial + variants subsystem
Modes: LETTERS, NUMBERS, SYMBOLS, EMOJIS. Letter variants include accents and optional extra forms. Symbols use smart spacing rules. Crown/center actions vary by context and settings.
Directional and encapsulated navigation improve accessibility workflows.
Gamepad implementation notes
Navigation supports dpad and axis traversal (circular/coordinates). Runtime includes press-edge detection and repeat timing. Utility focus can switch between radial and suggestion/variant targets.
Settings, presets, and themes
Supports built-in and custom presets, import/export, sailor mood palettes, layout controls, typography scaling, and behavior toggles for all major systems.
Normalization keeps imported/outdated payloads compatible.
For complete recreation
Use README-TECHNICAL.md for full implementation-level documentation, including component boundaries, data contracts, runtime flows, and behavior expectations for AI-assisted rebuilds.