# hteen/apple-store-helper architecture

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

- Interactive diagram: https://gitdiagram.com/hteen/apple-store-helper
- Repository: https://github.com/hteen/apple-store-helper

## Overview

Apple Store 预约助手 is a desktop GUI for monitoring iPhone pickup availability by region, store, and product. The user selects those options, adds watch items, and starts or pauses polling; on a match, the app pauses, opens Apple’s cart, and alerts locally and optionally through Bark. Region/product/store catalogs and persisted preferences support that workflow. The excerpts show the main GUI, catalog services, polling and alert behavior, and settings; other files are represented only where the tree or README supports them.

Main entry points: [`main.go`](https://github.com/hteen/apple-store-helper/blob/master/main.go) (GUI entry point), [`services/listen.go`](https://github.com/hteen/apple-store-helper/blob/master/services/listen.go) (Watch and poll), [`services/store.go`](https://github.com/hteen/apple-store-helper/blob/master/services/store.go) (Store catalog), [`services/area.go`](https://github.com/hteen/apple-store-helper/blob/master/services/area.go) (Area service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Desktop interface"]
  node_app["GUI entry point<br/>[main.go]"]
  node_view["Window handles<br/>[view.go]"]
end

subgraph group_catalog["Region and catalog"]
  node_areas["Area definitions<br/>[area.go]"]
  node_area_service["Area service<br/>[area.go]"]
  node_store_service["Store catalog<br/>[store.go]"]
  node_product_service["Product catalog<br/>[product.go]"]
  node_store_model["Store records<br/>[store.go]"]
  node_product_model["Product records<br/>[product.go]"]
  node_config_service["Embedded config<br/>[config.go]"]
  node_catalog_data["Regional catalog data"]
end

subgraph group_monitoring["Availability monitoring"]
  node_watcher["Watch and poll<br/>[listen.go]"]
end

subgraph group_preferences["Preferences"]
  node_settings["Settings service<br/>[setting.go]"]
  node_settings_file[("User settings file")]
end

subgraph group_alerts["Alerts and resources"]
  node_theme["Theme and sound<br/>[theme.go]"]
  node_sound_asset["Bundled sound"]
end

node_user(("User"))
node_apple["Apple availability API"]
node_cart["Apple cart page"]
node_bark["Bark notification API"]

node_user -->|"uses"| node_app
node_app -->|"sets up window"| node_view
node_app -->|"loads options"| node_area_service
node_app -->|"loads options"| node_store_service
node_app -->|"loads options"| node_product_service
node_app -->|"adds and controls"| node_watcher
node_app -->|"loads and saves"| node_settings
node_app -->|"sets theme"| node_theme
node_area_service -->|"reads regions"| node_areas
node_area_service -->|"reads product data"| node_config_service
node_store_service -->|"reads store data"| node_config_service
node_config_service -->|"reads embedded files"| node_catalog_data
node_store_service -->|"builds records"| node_store_model
node_product_service -->|"builds records"| node_product_model
node_watcher -->|"looks up store"| node_store_service
node_watcher -->|"looks up product"| node_product_service
node_watcher -->|"requests availability"| node_apple
node_watcher -->|"opens on match"| node_cart
node_app -->|"persists preferences"| node_settings_file
node_watcher -->|"shows match dialog"| node_view
node_watcher -->|"plays alert"| node_theme
node_theme -->|"loads resource"| node_sound_asset
node_watcher -.->|"sends optional push"| node_bark

click node_app "https://github.com/hteen/apple-store-helper/blob/master/main.go"
click node_view "https://github.com/hteen/apple-store-helper/blob/master/view/view.go"
click node_areas "https://github.com/hteen/apple-store-helper/blob/master/model/area.go"
click node_area_service "https://github.com/hteen/apple-store-helper/blob/master/services/area.go"
click node_store_service "https://github.com/hteen/apple-store-helper/blob/master/services/store.go"
click node_product_service "https://github.com/hteen/apple-store-helper/blob/master/services/product.go"
click node_store_model "https://github.com/hteen/apple-store-helper/blob/master/model/store.go"
click node_product_model "https://github.com/hteen/apple-store-helper/blob/master/model/product.go"
click node_config_service "https://github.com/hteen/apple-store-helper/blob/master/config/config.go"
click node_catalog_data "https://github.com/hteen/apple-store-helper/tree/master/config/files"
click node_watcher "https://github.com/hteen/apple-store-helper/blob/master/services/listen.go"
click node_settings "https://github.com/hteen/apple-store-helper/blob/master/services/setting.go"
click node_theme "https://github.com/hteen/apple-store-helper/blob/master/theme/theme.go"
click node_sound_asset "https://github.com/hteen/apple-store-helper/tree/master/theme/mp3"

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_app,node_view,node_user toneBlue
class node_areas,node_area_service,node_store_service,node_product_service,node_store_model,node_product_model,node_config_service,node_catalog_data toneAmber
class node_watcher,node_apple,node_bark toneMint
class node_settings,node_settings_file toneRose
class node_theme,node_sound_asset,node_cart toneIndigo
```

## Components

### Desktop interface

- [GUI entry point](https://github.com/hteen/apple-store-helper/blob/master/main.go): `main.go`
- [Window handles](https://github.com/hteen/apple-store-helper/blob/master/view/view.go): `view/view.go`

### Region and catalog

- [Area definitions](https://github.com/hteen/apple-store-helper/blob/master/model/area.go): `model/area.go`
- [Area service](https://github.com/hteen/apple-store-helper/blob/master/services/area.go): `services/area.go`
- [Store catalog](https://github.com/hteen/apple-store-helper/blob/master/services/store.go): `services/store.go`
- [Product catalog](https://github.com/hteen/apple-store-helper/blob/master/services/product.go): `services/product.go`
- [Store records](https://github.com/hteen/apple-store-helper/blob/master/model/store.go): `model/store.go`
- [Product records](https://github.com/hteen/apple-store-helper/blob/master/model/product.go): `model/product.go`
- [Embedded config](https://github.com/hteen/apple-store-helper/blob/master/config/config.go): `config/config.go`
- [Regional catalog data](https://github.com/hteen/apple-store-helper/tree/master/config/files): `config/files`

### Availability monitoring

- [Watch and poll](https://github.com/hteen/apple-store-helper/blob/master/services/listen.go): `services/listen.go`

### Preferences

- [Settings service](https://github.com/hteen/apple-store-helper/blob/master/services/setting.go): `services/setting.go`
- **User settings file**

### Alerts and resources

- [Theme and sound](https://github.com/hteen/apple-store-helper/blob/master/theme/theme.go): `theme/theme.go`
- [Bundled sound](https://github.com/hteen/apple-store-helper/tree/master/theme/mp3): `theme/mp3`

### Other components

- **User**
- **Apple availability API**
- **Apple cart page**
- **Bark notification API**

## Connections

- User → GUI entry point: uses (evidence: `README.md`)
- GUI entry point → Window handles: sets up window (evidence: `main.go`)
- GUI entry point → Area service: loads options (evidence: `main.go`)
- GUI entry point → Store catalog: loads options (evidence: `main.go`)
- GUI entry point → Product catalog: loads options (evidence: `main.go`)
- GUI entry point → Watch and poll: adds and controls (evidence: `main.go`)
- GUI entry point → Settings service: loads and saves (evidence: `main.go`)
- GUI entry point → Theme and sound: sets theme (evidence: `main.go`)
- Area service → Area definitions: reads regions (evidence: `services/area.go`)
- Area service → Embedded config: reads product data (evidence: `services/area.go`)
- Store catalog → Embedded config: reads store data (evidence: `services/store.go`)
- Embedded config → Regional catalog data: reads embedded files (evidence: `config/config.go`)
- Store catalog → Store records: builds records (evidence: `services/store.go`)
- Product catalog → Product records: builds records
- Watch and poll → Store catalog: looks up store (evidence: `services/listen.go`)
- Watch and poll → Product catalog: looks up product (evidence: `services/listen.go`)
- Watch and poll → Apple availability API: requests availability (evidence: `services/listen.go`)
- Watch and poll → Apple cart page: opens on match (evidence: `services/listen.go`)
- GUI entry point → User settings file: persists preferences
- Watch and poll → Window handles: shows match dialog (evidence: `services/listen.go`)
- Watch and poll → Theme and sound: plays alert (evidence: `services/listen.go`)
- Theme and sound → Bundled sound: loads resource (evidence: `theme/theme.go`)
- Watch and poll → Bark notification API: sends optional push (evidence: `services/listen.go`)
