# okonogi8284/calendar-preset architecture

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

- Interactive diagram: https://gitdiagram.com/okonogi8284/calendar-preset
- Repository: https://github.com/okonogi8284/calendar-preset

## Overview

Calendar Preset is a Chrome extension for saving and applying named Google Calendar display presets. The main workflow starts in the side panel: it reads the current calendar state through tab messaging, stores presets locally, and sends selections back to the content script to update Calendar. Separate branches handle preset editing, ordering, quick actions, view types, and automatic side-panel behavior. The graph uses README and SOURCE INDEX evidence; unexcerpted modules are included where documented, but their internal behavior and some wiring remain unverified.

Main entry points: [`src/sidepanel/main.js`](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/main.js) (Panel coordinator), [`src/sidepanel/services/preset.js`](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/preset.js) (Preset management), [`src/sidepanel/components/preset-list.js`](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/preset-list.js) (Preset list), [`src/sidepanel/services/storage.js`](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/storage.js) (Preset storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_panel["Side panel"]
  node_panel_main["Panel coordinator<br/>[main.js]"]
  node_preset_service["Preset management<br/>[preset.js]"]
  node_storage_service["Preset storage<br/>[storage.js]"]
  node_tab_service["Tab messaging<br/>[tabs.js]"]
  node_preset_list["Preset list<br/>[preset-list.js]"]
  node_drag_drop["Preset ordering<br/>[drag-drop.js]"]
  node_menu["Preset menu<br/>[menu.js]"]
  node_views["Panel views<br/>[views.js]"]
  node_messages["Panel messages<br/>[messages.js]"]
  node_sanitize["Input sanitizing<br/>[sanitize.js]"]
end

subgraph group_content["Calendar control"]
  node_content_entry["Content entry<br/>[main.js]"]
  node_message_handler["Message dispatch<br/>[message-handler.js]"]
  node_calendar_state["State discovery<br/>[state.js]"]
  node_calendar_actions["Calendar actions<br/>[actions.js]"]
  node_calendar_dom["Calendar DOM<br/>[dom.js]"]
  node_calendar_utils["Calendar identity<br/>[utils.js]"]
  node_view_type["View type control<br/>[view-type.js]"]
end

subgraph group_background["Background lifecycle"]
  node_bg_entry["Background events<br/>[main.js]"]
  node_sidepanel_control["Panel behavior<br/>[sidepanel.js]"]
  node_bg_state["Panel state<br/>[state.js]"]
  node_tab_events["Tab tracking<br/>[tabs.js]"]
end

subgraph group_shared["Shared services"]
  node_constants["Shared constants<br/>[constants.js]"]
  node_i18n["Localization<br/>[i18n.js]"]
end

node_user(("User"))
node_calendar["Google Calendar"]
node_chrome["Chrome APIs"]

node_user -->|"operates"| node_panel_main
node_panel_main -->|"invokes"| node_preset_service
node_panel_main -->|"renders"| node_preset_list
node_panel_main -->|"attaches ordering"| node_drag_drop
node_panel_main -->|"initializes"| node_menu
node_panel_main -->|"loads settings"| node_storage_service
node_panel_main -->|"checks tabs"| node_tab_service
node_panel_main -->|"switches views"| node_views
node_panel_main -->|"shows messages"| node_messages
node_panel_main -->|"translates"| node_i18n
node_preset_service -->|"reads and writes"| node_storage_service
node_preset_service -->|"sends requests"| node_tab_service
node_preset_service -->|"refreshes"| node_preset_list
node_preset_service -->|"sets edit view"| node_views
node_preset_service -->|"reports status"| node_messages
node_preset_service -->|"uses"| node_sanitize
node_drag_drop -->|"saves order"| node_storage_service
node_drag_drop -->|"closes menus"| node_menu
node_preset_list -->|"loads presets"| node_storage_service
node_preset_list -->|"uses"| node_menu
node_preset_list -->|"localizes labels"| node_i18n
node_storage_service -->|"uses local storage"| node_chrome
node_tab_service -->|"queries and messages"| node_chrome
node_tab_service -->|"targets tab"| node_calendar
node_content_entry -->|"initializes"| node_message_handler
node_message_handler -->|"dispatches state request"| node_calendar_state
node_message_handler -->|"dispatches actions"| node_calendar_actions
node_message_handler -->|"dispatches view change"| node_view_type
node_calendar -->|"hosts script"| node_content_entry
node_calendar_state -->|"inspects DOM"| node_calendar_dom
node_calendar_state -->|"identifies calendars"| node_calendar_utils
node_calendar_actions -->|"expands and scrolls"| node_calendar_dom
node_calendar_actions -->|"identifies and toggles"| node_calendar_utils
node_calendar_actions -->|"updates selections"| node_calendar
node_view_type -->|"changes display"| node_calendar
node_bg_entry -->|"toggles panel"| node_sidepanel_control
node_bg_entry -->|"registers events"| node_tab_events
node_sidepanel_control -->|"reads state"| node_bg_state
node_tab_events -->|"updates state"| node_bg_state
node_sidepanel_control -->|"controls side panel"| node_chrome
node_tab_events -->|"tracks tabs"| node_chrome
node_constants -->|"defines view types"| node_i18n

click node_panel_main "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/main.js"
click node_preset_service "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/preset.js"
click node_storage_service "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/storage.js"
click node_tab_service "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/tabs.js"
click node_preset_list "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/preset-list.js"
click node_drag_drop "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/drag-drop.js"
click node_menu "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/menu.js"
click node_views "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/ui/views.js"
click node_messages "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/ui/messages.js"
click node_sanitize "https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/utils/sanitize.js"
click node_content_entry "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/main.js"
click node_message_handler "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/message-handler.js"
click node_calendar_state "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/state.js"
click node_calendar_actions "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/actions.js"
click node_calendar_dom "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/dom.js"
click node_calendar_utils "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/utils.js"
click node_view_type "https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/view-type.js"
click node_bg_entry "https://github.com/okonogi8284/calendar-preset/blob/main/src/background/main.js"
click node_sidepanel_control "https://github.com/okonogi8284/calendar-preset/blob/main/src/background/sidepanel.js"
click node_bg_state "https://github.com/okonogi8284/calendar-preset/blob/main/src/background/state.js"
click node_tab_events "https://github.com/okonogi8284/calendar-preset/blob/main/src/background/tabs.js"
click node_constants "https://github.com/okonogi8284/calendar-preset/blob/main/src/shared/constants.js"
click node_i18n "https://github.com/okonogi8284/calendar-preset/blob/main/src/shared/i18n.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_panel_main,node_preset_service,node_storage_service,node_tab_service,node_preset_list,node_drag_drop,node_menu,node_views,node_messages,node_sanitize,node_user toneBlue
class node_content_entry,node_message_handler,node_calendar_state,node_calendar_actions,node_calendar_dom,node_calendar_utils,node_view_type toneAmber
class node_bg_entry,node_sidepanel_control,node_bg_state,node_tab_events,node_chrome toneMint
class node_constants,node_i18n toneRose
class node_calendar toneIndigo
```

## Components

### Side panel

- [Panel coordinator](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/main.js): `src/sidepanel/main.js`
- [Preset management](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/preset.js): `src/sidepanel/services/preset.js`
- [Preset storage](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/storage.js): `src/sidepanel/services/storage.js`
- [Tab messaging](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/services/tabs.js): `src/sidepanel/services/tabs.js`
- [Preset list](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/preset-list.js): `src/sidepanel/components/preset-list.js`
- [Preset ordering](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/drag-drop.js): `src/sidepanel/components/drag-drop.js`
- [Preset menu](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/components/menu.js): `src/sidepanel/components/menu.js`
- [Panel views](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/ui/views.js): `src/sidepanel/ui/views.js`
- [Panel messages](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/ui/messages.js): `src/sidepanel/ui/messages.js`
- [Input sanitizing](https://github.com/okonogi8284/calendar-preset/blob/main/src/sidepanel/utils/sanitize.js): `src/sidepanel/utils/sanitize.js`

### Calendar control

- [Content entry](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/main.js): `src/content/main.js`
- [Message dispatch](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/message-handler.js): `src/content/message-handler.js`
- [State discovery](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/state.js): `src/content/calendar/state.js`
- [Calendar actions](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/actions.js): `src/content/calendar/actions.js`
- [Calendar DOM](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/dom.js): `src/content/calendar/dom.js`
- [Calendar identity](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/utils.js): `src/content/calendar/utils.js`
- [View type control](https://github.com/okonogi8284/calendar-preset/blob/main/src/content/calendar/view-type.js): `src/content/calendar/view-type.js`

### Background lifecycle

- [Background events](https://github.com/okonogi8284/calendar-preset/blob/main/src/background/main.js): `src/background/main.js`
- [Panel behavior](https://github.com/okonogi8284/calendar-preset/blob/main/src/background/sidepanel.js): `src/background/sidepanel.js`
- [Panel state](https://github.com/okonogi8284/calendar-preset/blob/main/src/background/state.js): `src/background/state.js`
- [Tab tracking](https://github.com/okonogi8284/calendar-preset/blob/main/src/background/tabs.js): `src/background/tabs.js`

### Shared services

- [Shared constants](https://github.com/okonogi8284/calendar-preset/blob/main/src/shared/constants.js): `src/shared/constants.js`
- [Localization](https://github.com/okonogi8284/calendar-preset/blob/main/src/shared/i18n.js): `src/shared/i18n.js`

### Other components

- **User**
- **Google Calendar**
- **Chrome APIs**

## Connections

- User → Panel coordinator: operates (evidence: `README.md`)
- Panel coordinator → Preset management: invokes (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Preset list: renders (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Preset ordering: attaches ordering (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Preset menu: initializes (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Preset storage: loads settings (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Tab messaging: checks tabs (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Panel views: switches views (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Panel messages: shows messages (evidence: `src/sidepanel/main.js`)
- Panel coordinator → Localization: translates (evidence: `src/sidepanel/main.js`)
- Preset management → Preset storage: reads and writes (evidence: `src/sidepanel/services/preset.js`)
- Preset management → Tab messaging: sends requests (evidence: `src/sidepanel/services/preset.js`)
- Preset management → Preset list: refreshes (evidence: `src/sidepanel/services/preset.js`)
- Preset management → Panel views: sets edit view (evidence: `src/sidepanel/services/preset.js`)
- Preset management → Panel messages: reports status (evidence: `src/sidepanel/services/preset.js`)
- Preset management → Input sanitizing: uses (evidence: `src/sidepanel/services/preset.js`)
- Preset ordering → Preset storage: saves order (evidence: `src/sidepanel/components/drag-drop.js`)
- Preset ordering → Preset menu: closes menus (evidence: `src/sidepanel/components/drag-drop.js`)
- Preset list → Preset storage: loads presets (evidence: `src/sidepanel/components/preset-list.js`)
- Preset list → Preset menu: uses (evidence: `src/sidepanel/components/preset-list.js`)
- Preset list → Localization: localizes labels (evidence: `src/sidepanel/components/preset-list.js`)
- Preset storage → Chrome APIs: uses local storage (evidence: `src/sidepanel/services/storage.js`)
- Tab messaging → Chrome APIs: queries and messages (evidence: `README.md`)
- Tab messaging → Google Calendar: targets tab (evidence: `README.md`)
- Content entry → Message dispatch: initializes (evidence: `src/content/main.js`)
- Message dispatch → State discovery: dispatches state request (evidence: `src/content/message-handler.js`)
- Message dispatch → Calendar actions: dispatches actions (evidence: `src/content/message-handler.js`)
- Message dispatch → View type control: dispatches view change (evidence: `src/content/message-handler.js`)
- Google Calendar → Content entry: hosts script (evidence: `README.md`)
- State discovery → Calendar DOM: inspects DOM (evidence: `src/content/calendar/state.js`)
- State discovery → Calendar identity: identifies calendars (evidence: `src/content/calendar/state.js`)
- Calendar actions → Calendar DOM: expands and scrolls (evidence: `src/content/calendar/actions.js`)
- Calendar actions → Calendar identity: identifies and toggles (evidence: `src/content/calendar/actions.js`)
- Calendar actions → Google Calendar: updates selections (evidence: `README.md`)
- View type control → Google Calendar: changes display (evidence: `README.md`)
- Background events → Panel behavior: toggles panel (evidence: `src/background/main.js`)
- Background events → Tab tracking: registers events (evidence: `src/background/main.js`)
- Panel behavior → Panel state: reads state (evidence: `src/background/sidepanel.js`)
- Tab tracking → Panel state: updates state (evidence: `src/background/tabs.js`)
- Panel behavior → Chrome APIs: controls side panel (evidence: `README.md`)
- Tab tracking → Chrome APIs: tracks tabs (evidence: `README.md`)
- Shared constants → Localization: defines view types (evidence: `src/shared/i18n.js`)
