# naru-kami/backgroundmanager-plugin architecture

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

- Interactive diagram: https://gitdiagram.com/naru-kami/backgroundmanager-plugin
- Repository: https://github.com/naru-kami/backgroundmanager-plugin

## Overview

Background Manager is a single-file Discord client plugin for managing theme background images. Users open its popup, add images, select a background, and configure slideshow and transition behavior. The plugin also persists images in IndexedDB and exposes CSS variables for themes, including an optional accent color derived from the active image. The source is one large monolithic file, so the component boundaries below are logical responsibilities, not separate modules; links rely on README statements or the shown source excerpts.

Main entry points: [`BackgroundManager.plugin.js`](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js) (Background selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Plugin interface"]
  node_plugin["Background Manager"]
  node_gallery["Image gallery popup"]
  node_image_add["Image adding"]
  node_settings["Plugin settings"]
end

subgraph group_background["Background behavior"]
  node_selection["Background selection"]
  node_slideshow["Slideshow and shuffle"]
  node_transitions["Image transitions"]
end

subgraph group_storage["Image storage"]
  node_indexeddb[("IndexedDB image store")]
end

subgraph group_integration["Theme integration"]
  node_theme["Compatible Discord theme"]
  node_css_vars["Exported CSS variables"]
  node_accent["Image accent color"]
end

node_user(("Discord user"))

node_user -->|"opens popup"| node_gallery
node_gallery -->|"adds images"| node_image_add
node_gallery -->|"selects image"| node_selection
node_user -->|"adjusts timings"| node_settings
node_image_add -->|"stores images"| node_indexeddb
node_selection -.->|"persists selection"| node_indexeddb
node_settings -->|"configures"| node_slideshow
node_settings -->|"configures"| node_transitions
node_slideshow -.->|"switches images"| node_selection
node_selection -->|"animates swap"| node_transitions
node_selection -->|"updates image URL"| node_css_vars
node_selection -->|"provides active image"| node_accent
node_accent -->|"exports accent color"| node_css_vars
node_css_vars -->|"supplies CSS values"| node_theme
node_plugin -.->|"provides popup"| node_gallery
node_plugin -->|"opens database"| node_indexeddb

click node_plugin "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_gallery "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_image_add "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_settings "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_selection "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_slideshow "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_transitions "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_indexeddb "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_css_vars "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js"
click node_accent "https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.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_plugin,node_gallery,node_image_add,node_settings,node_user toneBlue
class node_selection,node_slideshow,node_transitions toneAmber
class node_indexeddb toneMint
class node_theme,node_css_vars,node_accent toneRose
```

## Components

### Plugin interface

- [Background Manager](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Image gallery popup](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Image adding](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Plugin settings](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`

### Background behavior

- [Background selection](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Slideshow and shuffle](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Image transitions](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`

### Image storage

- [IndexedDB image store](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`

### Theme integration

- **Compatible Discord theme**
- [Exported CSS variables](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`
- [Image accent color](https://github.com/naru-kami/backgroundmanager-plugin/blob/main/BackgroundManager.plugin.js): `BackgroundManager.plugin.js`

### Other components

- **Discord user**

## Connections

- Discord user → Image gallery popup: opens popup (evidence: `README.md`)
- Image gallery popup → Image adding: adds images (evidence: `README.md`)
- Image gallery popup → Background selection: selects image (evidence: `README.md`)
- Discord user → Plugin settings: adjusts timings (evidence: `README.md`)
- Image adding → IndexedDB image store: stores images (evidence: `README.md`)
- Background selection → IndexedDB image store: persists selection (evidence: `BackgroundManager.plugin.js`)
- Plugin settings → Slideshow and shuffle: configures (evidence: `README.md`)
- Plugin settings → Image transitions: configures (evidence: `README.md`)
- Slideshow and shuffle → Background selection: switches images (evidence: `BackgroundManager.plugin.js`)
- Background selection → Image transitions: animates swap (evidence: `README.md`)
- Background selection → Exported CSS variables: updates image URL (evidence: `README.md`)
- Background selection → Image accent color: provides active image (evidence: `README.md`)
- Image accent color → Exported CSS variables: exports accent color (evidence: `README.md`)
- Exported CSS variables → Compatible Discord theme: supplies CSS values (evidence: `README.md`)
- Background Manager → Image gallery popup: provides popup (evidence: `BackgroundManager.plugin.js`)
- Background Manager → IndexedDB image store: opens database (evidence: `BackgroundManager.plugin.js`)
