# apanzinc/moonfog architecture

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

- Interactive diagram: https://gitdiagram.com/apanzinc/moonfog
- Repository: https://github.com/apanzinc/moonfog

## Overview

MoonFog is a Chrome new-tab replacement. The user opens the page, configures its appearance and content, then uses search and shortcut navigation from the customized start page. Runtime capabilities include multiple background sources, image-derived themes, greetings, editable search engines, bookmark import, typography and preference backup/reset. The sampled app excerpt shows deferred initialization of search, shortcuts, settings and background; several other links below reflect README descriptions rather than inspected implementation. The README documents localStorage as the preference store.

Main entry points: [`js/app.js`](https://github.com/apanzinc/moonfog/blob/main/js/app.js) (Runtime coordinator), [`js/background.js`](https://github.com/apanzinc/moonfog/blob/main/js/background.js) (Background modes), [`js/settings.js`](https://github.com/apanzinc/moonfog/blob/main/js/settings.js) (Settings and data), [`js/boot-paint.js`](https://github.com/apanzinc/moonfog/blob/main/js/boot-paint.js) (First-paint boot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Page startup"]
  node_newtab["New-tab page<br/>[newtab.html]"]
  node_app["Runtime coordinator<br/>[app.js]"]
  node_boot["First-paint boot<br/>[boot-paint.js]"]
  node_bootstate["Boot state<br/>[boot-state.js]"]
  node_bootconfig["Boot configuration<br/>[boot-config.js]"]
  node_bootutils["Boot utilities<br/>[boot-utils.js]"]
end

subgraph group_appearance["Appearance"]
  node_background["Background modes<br/>[background.js]"]
  node_bing["Bing image cache<br/>[background.js]"]
  node_grain["Grain renderer<br/>[oobe-grain.js]"]
  node_thememanager["Theme manager<br/>[theme-manager.js]"]
  node_theme["Theme controls<br/>[theme.js]"]
  node_colorutils["Color utilities<br/>[color-utils.js]"]
end

subgraph group_content["Page content"]
  node_greeting["Greeting and quotes<br/>[greeting.js]"]
  node_search["Search and engines<br/>[search.js]"]
  node_suggestions["Search suggestions<br/>[search.js]"]
  node_shortcuts["Shortcut navigation<br/>[shortcuts.js]"]
  node_onboarding["First-run onboarding<br/>[oobe.js]"]
end

subgraph group_preferences["Preferences"]
  node_settings["Settings and data<br/>[settings.js]"]
  node_config["Preference configuration<br/>[config.js]"]
  node_storage[("Local preferences")]
end

node_user(("Browser user"))
node_bingservice["Bing image service"]
node_quoteservice["Quote service"]
node_suggestservice["Suggestion service"]
node_bookmarks["Browser bookmarks"]

node_user -->|"opens"| node_newtab
node_newtab -.->|"starts"| node_app
node_app -->|"initializes"| node_greeting
node_app -->|"initializes"| node_search
node_app -->|"renders"| node_shortcuts
node_app -->|"initializes"| node_settings
node_app -->|"initializes"| node_background
node_app -->|"checks"| node_onboarding
node_boot -.->|"paints early"| node_newtab
node_bootstate -.->|"provides state"| node_boot
node_bootconfig -.->|"provides settings"| node_boot
node_bootutils -.->|"supports startup"| node_boot
node_background -->|"loads"| node_bing
node_bing -->|"fetches image"| node_bingservice
node_background -->|"supports mode"| node_grain
node_background -->|"sets image palette"| node_thememanager
node_thememanager -.->|"generates palette"| node_colorutils
node_theme -.->|"applies theme"| node_thememanager
node_greeting -->|"fetches quote"| node_quoteservice
node_search -->|"requests suggestions"| node_suggestions
node_suggestions -->|"queries"| node_suggestservice
node_search -->|"opens search result"| node_user
node_shortcuts -->|"imports HTML"| node_bookmarks
node_settings -.->|"configures options"| node_config
node_settings -->|"imports and exports"| node_storage
node_config -->|"stores preferences"| node_storage
node_onboarding -.->|"guides setup"| node_settings

click node_newtab "https://github.com/apanzinc/moonfog/blob/main/newtab.html"
click node_app "https://github.com/apanzinc/moonfog/blob/main/js/app.js"
click node_boot "https://github.com/apanzinc/moonfog/blob/main/js/boot-paint.js"
click node_bootstate "https://github.com/apanzinc/moonfog/blob/main/js/boot-state.js"
click node_bootconfig "https://github.com/apanzinc/moonfog/blob/main/js/boot-config.js"
click node_bootutils "https://github.com/apanzinc/moonfog/blob/main/js/boot-utils.js"
click node_background "https://github.com/apanzinc/moonfog/blob/main/js/background.js"
click node_bing "https://github.com/apanzinc/moonfog/blob/main/js/background.js"
click node_grain "https://github.com/apanzinc/moonfog/blob/main/js/oobe-grain.js"
click node_thememanager "https://github.com/apanzinc/moonfog/blob/main/js/theme-manager.js"
click node_theme "https://github.com/apanzinc/moonfog/blob/main/js/theme.js"
click node_colorutils "https://github.com/apanzinc/moonfog/blob/main/js/color-utils.js"
click node_greeting "https://github.com/apanzinc/moonfog/blob/main/js/greeting.js"
click node_search "https://github.com/apanzinc/moonfog/blob/main/js/search.js"
click node_suggestions "https://github.com/apanzinc/moonfog/blob/main/js/search.js"
click node_shortcuts "https://github.com/apanzinc/moonfog/blob/main/js/shortcuts.js"
click node_onboarding "https://github.com/apanzinc/moonfog/blob/main/js/oobe.js"
click node_settings "https://github.com/apanzinc/moonfog/blob/main/js/settings.js"
click node_config "https://github.com/apanzinc/moonfog/blob/main/js/config.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_newtab,node_app,node_boot,node_bootstate,node_bootconfig,node_bootutils,node_user,node_bookmarks toneBlue
class node_background,node_bing,node_grain,node_thememanager,node_theme,node_colorutils toneAmber
class node_greeting,node_search,node_suggestions,node_shortcuts,node_onboarding toneMint
class node_settings,node_config,node_storage toneRose
class node_bingservice,node_quoteservice,node_suggestservice toneIndigo
```

## Components

### Page startup

- [New-tab page](https://github.com/apanzinc/moonfog/blob/main/newtab.html): `newtab.html`
- [Runtime coordinator](https://github.com/apanzinc/moonfog/blob/main/js/app.js): `js/app.js`
- [First-paint boot](https://github.com/apanzinc/moonfog/blob/main/js/boot-paint.js): `js/boot-paint.js`
- [Boot state](https://github.com/apanzinc/moonfog/blob/main/js/boot-state.js): `js/boot-state.js`
- [Boot configuration](https://github.com/apanzinc/moonfog/blob/main/js/boot-config.js): `js/boot-config.js`
- [Boot utilities](https://github.com/apanzinc/moonfog/blob/main/js/boot-utils.js): `js/boot-utils.js`

### Appearance

- [Background modes](https://github.com/apanzinc/moonfog/blob/main/js/background.js): `js/background.js`
- [Bing image cache](https://github.com/apanzinc/moonfog/blob/main/js/background.js): `js/background.js`
- [Grain renderer](https://github.com/apanzinc/moonfog/blob/main/js/oobe-grain.js): `js/oobe-grain.js`
- [Theme manager](https://github.com/apanzinc/moonfog/blob/main/js/theme-manager.js): `js/theme-manager.js`
- [Theme controls](https://github.com/apanzinc/moonfog/blob/main/js/theme.js): `js/theme.js`
- [Color utilities](https://github.com/apanzinc/moonfog/blob/main/js/color-utils.js): `js/color-utils.js`

### Page content

- [Greeting and quotes](https://github.com/apanzinc/moonfog/blob/main/js/greeting.js): `js/greeting.js`
- [Search and engines](https://github.com/apanzinc/moonfog/blob/main/js/search.js): `js/search.js`
- [Search suggestions](https://github.com/apanzinc/moonfog/blob/main/js/search.js): `js/search.js`
- [Shortcut navigation](https://github.com/apanzinc/moonfog/blob/main/js/shortcuts.js): `js/shortcuts.js`
- [First-run onboarding](https://github.com/apanzinc/moonfog/blob/main/js/oobe.js): `js/oobe.js`

### Preferences

- [Settings and data](https://github.com/apanzinc/moonfog/blob/main/js/settings.js): `js/settings.js`
- [Preference configuration](https://github.com/apanzinc/moonfog/blob/main/js/config.js): `js/config.js`
- **Local preferences**

### Other components

- **Browser user**
- **Bing image service**
- **Quote service**
- **Suggestion service**
- **Browser bookmarks**

## Connections

- Browser user → New-tab page: opens (evidence: `README.md`)
- New-tab page → Runtime coordinator: starts
- Runtime coordinator → Greeting and quotes: initializes (evidence: `js/app.js`)
- Runtime coordinator → Search and engines: initializes (evidence: `js/app.js`)
- Runtime coordinator → Shortcut navigation: renders (evidence: `js/app.js`)
- Runtime coordinator → Settings and data: initializes (evidence: `js/app.js`)
- Runtime coordinator → Background modes: initializes (evidence: `js/app.js`)
- Runtime coordinator → First-run onboarding: checks (evidence: `js/app.js`)
- First-paint boot → New-tab page: paints early
- Boot state → First-paint boot: provides state
- Boot configuration → First-paint boot: provides settings
- Boot utilities → First-paint boot: supports startup
- Background modes → Bing image cache: loads (evidence: `README.md`)
- Bing image cache → Bing image service: fetches image (evidence: `README.md`)
- Background modes → Grain renderer: supports mode (evidence: `README.md`)
- Background modes → Theme manager: sets image palette (evidence: `README.md`)
- Theme manager → Color utilities: generates palette
- Theme controls → Theme manager: applies theme
- Greeting and quotes → Quote service: fetches quote (evidence: `README.md`)
- Search and engines → Search suggestions: requests suggestions (evidence: `js/search.js`)
- Search suggestions → Suggestion service: queries (evidence: `README.md`)
- Search and engines → Browser user: opens search result (evidence: `js/search.js`)
- Shortcut navigation → Browser bookmarks: imports HTML (evidence: `README.md`)
- Settings and data → Preference configuration: configures options
- Settings and data → Local preferences: imports and exports (evidence: `README.md`)
- Preference configuration → Local preferences: stores preferences (evidence: `README.md`)
- First-run onboarding → Settings and data: guides setup
