LexiShift Extension System Map
Status: active architecture map
Role: Canonical current
Last updated: 2026-03-21
Source-of-truth: as-is extension runtime/file map; verify implementation details in apps/chrome-extension/manifest.json, apps/chrome-extension/options.html, and the linked source modules.
Purpose:
- Provide a single-page map of how the Chrome extension works.
- Help new contributors find the right file quickly.
- Keep boundaries clear between runtime, options UI, shared modules, and helper integration.
1) Entry Points
Core extension entry files:
apps/chrome-extension/manifest.jsonapps/chrome-extension/content_script.jsapps/chrome-extension/background.jsapps/chrome-extension/options.htmlapps/chrome-extension/options.js
How they connect:
manifest.jsonloads ordered content modules, thencontent_script.js.background.jshandles helper/native messaging bridge requests.options.htmlloads ordered options modules, thenoptions.js.
2) Runtime Topology (Content Script)
Primary runtime folders:
apps/chrome-extension/content/processingapps/chrome-extension/content/runtimeapps/chrome-extension/content/uiapps/chrome-extension/shared
High-level flow:
- Load and normalize settings from
chrome.storage.local. - Resolve active ruleset (
ruleset+ optional helper rules + optional SRS gate). - Build matcher/trie and scan DOM text nodes.
- Replace matched text with
.lexishift-replacementspans. - Track exposure and enable feedback popup interactions.
- Re-apply or rescan on settings/storage/mutation events.
Core runtime modules:
content/runtime/apply_settings_pipeline.jscontent/runtime/rules/active_rules_runtime.jscontent/runtime/dom_scan_runtime.jscontent/runtime/feedback/feedback_runtime_controller.jscontent/runtime/settings_change_router.js
3) Popup Module Runtime
Popup ownership:
apps/chrome-extension/content/ui/feedback_popup_controller.jsapps/chrome-extension/content/ui/popup_modules/module_registry.js
Current built-in module:
apps/chrome-extension/content/ui/popup_modules/japanese_script_module.js
Contract:
- Modules render in a stack above the fixed feedback bar.
- Feedback bar remains present and bottom-attached.
- Popup lifecycle (open/close/position/fade) is controlled by core popup controller.
Reference:
docs/architecture/popup_modules_pattern.md
4) Options App Topology
Primary folders:
apps/chrome-extension/options/coreapps/chrome-extension/options/controllers
Composition root:
apps/chrome-extension/options.js
Controller graph builder:
apps/chrome-extension/options/core/bootstrap/controller_graph.js
Controller factory guard:
apps/chrome-extension/options/core/bootstrap/controller_factory.js
Design rule:
options.jsdoes composition and startup.- Domain behavior lives in controllers and core installers.
Detailed reference:
docs/architecture/options_controllers_architecture.md
5) Storage Map
Persistent stores:
chrome.storage.local- extension settings/rules/runtime mirrors
- SRS logs/stores/feedback metadata
- IndexedDB (
profile_media_store)- profile background image blobs
Defaults source:
apps/chrome-extension/shared/settings/settings_defaults.js
Profile-scoped settings container:
srsProfiles.<profile_id>.*
6) Helper Integration Map
Client/transport modules:
apps/chrome-extension/shared/helper/helper_transport_extension.jsapps/chrome-extension/shared/helper/helper_client.jsapps/chrome-extension/shared/helper/helper_cache.jsapps/chrome-extension/shared/helper/helper_feedback_sync.js
Who calls helper flows:
- SRS options controllers (
initialize,refresh, diagnostics, sampled preview) - Feedback sync queue runtime path
7) Where To Edit (By Feature)
If you are changing:
- Replacement matching logic:
content/processing/tokenizer.jscontent/processing/matcher.jscontent/processing/replacements.js
- DOM scan/replacement scheduling:
content/runtime/dom_scan_runtime.jscontent/runtime/dom_scan/*
- Popup UX/modules:
content/ui/feedback_popup_controller.jscontent/ui/popup_modules/*
- Options setting behavior:
options/controllers/*options/core/settings/*
- SRS setting persistence/profile behavior:
options/core/settings/srs_profile_methods.jsoptions/controllers/srs/*
8) Fast Debug Paths
A word is not replaced:
- Check extension enabled + pair settings in options.
- Check active rules resolution in content debug logs.
- Check node-filter skips in DOM scan runtime logs.
- Check page/lemma replacement budgets.
Popup module not visible:
- Confirm replacement span has expected dataset payload (
data-script-forms,data-display-script,data-origin). - Confirm origin gating allows popup on that span.
- Confirm module registry build path runs and module returns content.
Profile switch appears inconsistent:
- Check selected profile key (
srsSelectedProfileId/ runtime mirrors). - Check
srsProfiles.<id>language prefs and pair settings. - Check profile background runtime bridge updates.
9) Architecture Invariants
- Manifest and options script ordering are hard dependencies.
- Content UI modules cannot break feedback core behavior.
- Profile scoping must be preserved in SRS settings, helper cache, and media assets.
- Controller boundaries in options must stay modular (no logic bloat in
options.js).