# elirangor/byewall architecture

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

- Interactive diagram: https://gitdiagram.com/elirangor/byewall
- Repository: https://github.com/elirangor/byewall

## Overview

Page Rewind is a Chrome extension for opening archived versions of the current page through Archive.today or the Wayback Machine. The popup coordinates service and tab preferences, history, shortcuts, and archive requests; the background worker dispatches requests to shared archive logic, which validates the page, checks for snapshots, opens one, and records it. The graph includes the documented shortcut and theme capabilities. Some popup internals and manifest wiring were not sampled, so unverified connections are omitted.

Main entry points: [`src/popup/popup.js`](https://github.com/elirangor/byewall/blob/main/src/popup/popup.js) (Popup coordinator), [`src/popup/modules/ui-handlers.js`](https://github.com/elirangor/byewall/blob/main/src/popup/modules/ui-handlers.js) (Popup controls), [`src/core/archive-core.js`](https://github.com/elirangor/byewall/blob/main/src/core/archive-core.js) (Archive lookup and opening), [`src/storage/history-manager.js`](https://github.com/elirangor/byewall/blob/main/src/storage/history-manager.js) (Archive history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_popup["Popup experience"]
  node_popup_app["Popup coordinator<br/>[popup.js]"]
  node_popup_handlers["Popup controls<br/>[ui-handlers.js]"]
  node_popup_ui["Popup rendering<br/>[popup-ui.js]"]
  node_shortcut_display["Shortcut display<br/>[shortcuts.js]"]
  node_pending_messages["Pending messages"]
  node_precheck_warmup["Precheck warmup<br/>[precheck.js]"]
  node_history_ui["History controls<br/>[history.js]"]
end

subgraph group_archive["Archive workflow"]
  node_background["Background worker<br/>[service-worker.js]"]
  node_archive_logic["Archive lookup and opening<br/>[archive-core.js]"]
end

subgraph group_state["Preferences and history"]
  node_history_store[("Archive history<br/>[history-manager.js]")]
  node_settings["Service and display preferences<br/>[ui-handlers.js]"]
end

subgraph group_shared["Shared logic"]
  node_error_messages["Error message mapping<br/>[error-messages.js]"]
  node_constants["Configuration constants<br/>[constants.js]"]
  node_utilities["Storage and URL utilities<br/>[utils.js]"]
end

node_user(("User"))
node_chrome["Chrome APIs"]
node_archive_today["Archive.today"]
node_wayback["Wayback Machine"]
node_browser_storage[("Extension storage")]

node_user -->|"opens popup"| node_popup_app
node_popup_app -->|"loads history"| node_history_ui
node_popup_app -->|"checks messages"| node_pending_messages
node_popup_app -->|"initializes hints"| node_shortcut_display
node_popup_app -->|"initializes controls"| node_popup_handlers
node_popup_handlers -->|"requests archive"| node_background
node_background -->|"dispatches request"| node_archive_logic
node_background -->|"stores shortcut error"| node_browser_storage
node_popup_app -->|"warms checks"| node_precheck_warmup
node_popup_handlers -->|"starts warmup"| node_precheck_warmup
node_archive_logic -->|"checks snapshot"| node_archive_today
node_archive_logic -->|"checks snapshot"| node_wayback
node_archive_logic -->|"saves archive"| node_history_store
node_archive_logic -->|"opens archived page"| node_chrome
node_history_store -->|"reads and writes"| node_browser_storage
node_history_ui -->|"loads and edits"| node_history_store
node_history_ui -->|"renders history"| node_popup_ui
node_popup_handlers -->|"shows feedback"| node_popup_ui
node_pending_messages -->|"shows message"| node_popup_ui
node_pending_messages -->|"formats error"| node_error_messages
node_popup_handlers -->|"formats error"| node_error_messages
node_popup_handlers -->|"stores preferences"| node_browser_storage
node_archive_logic -->|"validates URLs"| node_utilities
node_history_store -->|"normalizes URLs"| node_utilities
node_popup_ui -->|"checks text direction"| node_utilities
node_error_messages -->|"maps error codes"| node_constants

click node_popup_app "https://github.com/elirangor/byewall/blob/main/src/popup/popup.js"
click node_popup_handlers "https://github.com/elirangor/byewall/blob/main/src/popup/modules/ui-handlers.js"
click node_popup_ui "https://github.com/elirangor/byewall/blob/main/src/ui/popup-ui.js"
click node_shortcut_display "https://github.com/elirangor/byewall/blob/main/src/popup/modules/shortcuts.js"
click node_pending_messages "https://github.com/elirangor/byewall/blob/main/src/popup/modules/pending-messages.js"
click node_precheck_warmup "https://github.com/elirangor/byewall/blob/main/src/popup/modules/precheck.js"
click node_history_ui "https://github.com/elirangor/byewall/blob/main/src/popup/modules/history.js"
click node_background "https://github.com/elirangor/byewall/blob/main/src/background/service-worker.js"
click node_archive_logic "https://github.com/elirangor/byewall/blob/main/src/core/archive-core.js"
click node_history_store "https://github.com/elirangor/byewall/blob/main/src/storage/history-manager.js"
click node_settings "https://github.com/elirangor/byewall/blob/main/src/popup/modules/ui-handlers.js"
click node_error_messages "https://github.com/elirangor/byewall/blob/main/src/core/error-messages.js"
click node_constants "https://github.com/elirangor/byewall/blob/main/src/core/constants.js"
click node_utilities "https://github.com/elirangor/byewall/blob/main/src/utils/utils.js"

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_popup_app,node_popup_handlers,node_popup_ui,node_shortcut_display,node_pending_messages,node_precheck_warmup,node_history_ui,node_user toneBlue
class node_background,node_archive_logic,node_browser_storage toneAmber
class node_history_store,node_settings,node_chrome toneMint
class node_error_messages,node_constants,node_utilities toneRose
class node_archive_today,node_wayback toneIndigo
```

## Components

### Popup experience

- [Popup coordinator](https://github.com/elirangor/byewall/blob/main/src/popup/popup.js): `src/popup/popup.js`
- [Popup controls](https://github.com/elirangor/byewall/blob/main/src/popup/modules/ui-handlers.js): `src/popup/modules/ui-handlers.js`
- [Popup rendering](https://github.com/elirangor/byewall/blob/main/src/ui/popup-ui.js): `src/ui/popup-ui.js`
- [Shortcut display](https://github.com/elirangor/byewall/blob/main/src/popup/modules/shortcuts.js): `src/popup/modules/shortcuts.js`
- [Pending messages](https://github.com/elirangor/byewall/blob/main/src/popup/modules/pending-messages.js): `src/popup/modules/pending-messages.js`
- [Precheck warmup](https://github.com/elirangor/byewall/blob/main/src/popup/modules/precheck.js): `src/popup/modules/precheck.js`
- [History controls](https://github.com/elirangor/byewall/blob/main/src/popup/modules/history.js): `src/popup/modules/history.js`

### Archive workflow

- [Background worker](https://github.com/elirangor/byewall/blob/main/src/background/service-worker.js): `src/background/service-worker.js`
- [Archive lookup and opening](https://github.com/elirangor/byewall/blob/main/src/core/archive-core.js): `src/core/archive-core.js`

### Preferences and history

- [Archive history](https://github.com/elirangor/byewall/blob/main/src/storage/history-manager.js): `src/storage/history-manager.js`
- [Service and display preferences](https://github.com/elirangor/byewall/blob/main/src/popup/modules/ui-handlers.js): `src/popup/modules/ui-handlers.js`

### Shared logic

- [Error message mapping](https://github.com/elirangor/byewall/blob/main/src/core/error-messages.js): `src/core/error-messages.js`
- [Configuration constants](https://github.com/elirangor/byewall/blob/main/src/core/constants.js): `src/core/constants.js`
- [Storage and URL utilities](https://github.com/elirangor/byewall/blob/main/src/utils/utils.js): `src/utils/utils.js`

### Other components

- **User**
- **Chrome APIs**
- **Archive.today**
- **Wayback Machine**
- **Extension storage**

## Connections

- User → Popup coordinator: opens popup (evidence: `README.md`)
- Popup coordinator → History controls: loads history (evidence: `src/popup/popup.js`)
- Popup coordinator → Pending messages: checks messages (evidence: `src/popup/popup.js`)
- Popup coordinator → Shortcut display: initializes hints (evidence: `src/popup/popup.js`)
- Popup coordinator → Popup controls: initializes controls (evidence: `src/popup/popup.js`)
- Popup controls → Background worker: requests archive (evidence: `src/popup/modules/ui-handlers.js`)
- Background worker → Archive lookup and opening: dispatches request (evidence: `src/background/service-worker.js`)
- Background worker → Extension storage: stores shortcut error (evidence: `src/background/service-worker.js`)
- Popup coordinator → Precheck warmup: warms checks (evidence: `src/popup/popup.js`)
- Popup controls → Precheck warmup: starts warmup (evidence: `src/popup/modules/ui-handlers.js`)
- Archive lookup and opening → Archive.today: checks snapshot (evidence: `src/core/archive-core.js`)
- Archive lookup and opening → Wayback Machine: checks snapshot (evidence: `src/core/archive-core.js`)
- Archive lookup and opening → Archive history: saves archive (evidence: `src/core/archive-core.js`)
- Archive lookup and opening → Chrome APIs: opens archived page (evidence: `src/core/archive-core.js`)
- Archive history → Extension storage: reads and writes (evidence: `src/storage/history-manager.js`)
- History controls → Archive history: loads and edits (evidence: `src/popup/modules/history.js`)
- History controls → Popup rendering: renders history (evidence: `src/popup/modules/history.js`)
- Popup controls → Popup rendering: shows feedback (evidence: `src/popup/modules/ui-handlers.js`)
- Pending messages → Popup rendering: shows message (evidence: `src/popup/modules/pending-messages.js`)
- Pending messages → Error message mapping: formats error (evidence: `src/popup/modules/pending-messages.js`)
- Popup controls → Error message mapping: formats error (evidence: `src/popup/modules/ui-handlers.js`)
- Popup controls → Extension storage: stores preferences (evidence: `src/popup/modules/ui-handlers.js`)
- Archive lookup and opening → Storage and URL utilities: validates URLs (evidence: `src/core/archive-core.js`)
- Archive history → Storage and URL utilities: normalizes URLs (evidence: `src/storage/history-manager.js`)
- Popup rendering → Storage and URL utilities: checks text direction (evidence: `src/ui/popup-ui.js`)
- Error message mapping → Configuration constants: maps error codes (evidence: `src/core/error-messages.js`)
