# w1249178256/xyzw_web_helper architecture

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

- Interactive diagram: https://gitdiagram.com/w1249178256/xyzw_web_helper
- Repository: https://github.com/w1249178256/xyzw_web_helper

## Overview

#### Purpose and Runtime
XYZW Web Helper is a browser-based automation and monitoring client for the XYZW game. It manages multiple game tokens locally, communicates with game servers over encrypted BON-protocol WebSockets, displays game state, and executes individual or batch game tasks. The primary runtime is a Vue 3/Vite SPA with Pinia state; a separate Python service optionally hosts `.bin` files and issues token URLs.

Entry points: `src/main.js`, `src/App.vue`, `src/router/index.js`.

#### Application Shell and Navigation
The SPA bootstraps Vue, global styling, stores, and route-driven feature views. `DefaultLayout` provides the shared authenticated application frame; routes separate login/token-import flows from dashboards, daily tasks, batch automation, role management, legion war, and profile views. Route metadata/guards form the boundary preventing token-dependent pages from running without an imported role.

Paths: `src/main.js`, `src/router/index.js`, `src/layout/DefaultLayout.vue`.

#### Token and Role Lifecycle
Token import supports manual, URL, and `.bin`-derived inputs. Token stores own the selected role, persisted credentials, refresh metadata, and connection association; role state captures game-facing identity and status. Browser persistence is the core security boundary: game credentials are intended to remain client-side, with IndexedDB available for durable local data.

Paths: `src/views/TokenImport/index.vue`, `src/stores/tokenStore.ts`, `src/stores/gameRoles.js`.

#### Game Transport and Protocol Boundary
The transport layer converts game commands into BON payloads, applies supported encryption/encoding formats, and sends them through WebSocket clients. It handles connection lifecycle, message routing, queues, and reconnect behavior. Incoming messages are decoded and propagated into event-specific Pinia stores, separating opaque server protocol traffic from UI-facing game state.

Paths: `src/utils/bonProtocol.js`, `src/utils/xyzwWebSocket.js`, `src/stores/events/index.ts`.

#### State Projection and Feature UI
Feature views compose card and domain components around reactive stores: dashboard/status, daily activities, team, towers, clubs, rankings, and legion war. Event stores partition server updates by concern—role, activity, tower, team, chat, hangup, study, legion, and clock—so UI components consume normalized live state rather than direct socket traffic.

Paths: `src/views/Dashboard.vue`, `src/views/DailyTasks.vue`, `src/stores/events/role.ts`.

#### Automation Execution
Automation is command-driven rather than server-hosted. Single-task runners coordinate helper/daily actions, while the batch subsystem schedules and executes task families such as arena, bottle, car, dungeon, hang-up, items, store, and tower. It relies on the shared command/connection layer, making WebSocket availability and token validity prerequisites for automation.

Paths: `src/utils/helperTaskRunner.js`, `src/utils/dailyTaskRunner.js`, `src/utils/batch/index.js`.

#### Deployment and Optional Services
The frontend builds to static assets and can run behind Cloudflare Pages. `worker.js` is the edge/API proxy boundary; `wrangler.toml` configures its Cloudflare runtime. Docker packaging includes Nginx for static delivery. The optional Python backend, declared under `server/requirements.txt`, provides authenticated multi-user `.bin` storage and token-URL retrieval; it is separate from normal local-token operation.

Paths: `worker.js`, `wrangler.toml`, `server/requirements.txt`.

Main entry points: [`src/utils/xyzwWebSocket.js`](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/xyzwWebSocket.js) (WebSocket client), [`src/stores/tokenStore.ts`](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/tokenStore.ts) (Token store), [`src/stores/events/index.ts`](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/events/index.ts) (Event store registry), [`src/router/index.js`](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/router/index.js) (Routes and guards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_spa["Vue SPA"]
  node_main["SPA bootstrap<br/>Vue entry<br/>[main.js]"]
  node_router["Routes and guards<br/>Vue Router<br/>[index.js]"]
  node_layout["Authenticated layout<br/>Vue layout<br/>[DefaultLayout.vue]"]
  node_token_import["Token import<br/>Vue view<br/>[index.vue]"]
  node_dashboard["Dashboard<br/>Vue view<br/>[Dashboard.vue]"]
  node_daily_ui["Daily tasks UI<br/>Vue view<br/>[DailyTasks.vue]"]
  node_task_runners["Single-task runners<br/>automation"]
  node_daily_runner["Daily task runner<br/>automation<br/>[dailyTaskRunner.js]"]
  node_batch["Batch automation<br/>scheduler<br/>[index.js]"]
end

subgraph group_state["Local State"]
  node_token_store[("Token store<br/>Pinia store<br/>[tokenStore.ts]")]
  node_role_store[("Role state<br/>Pinia store<br/>[gameRoles.js]")]
  node_event_stores[("Event store registry<br/>Pinia stores<br/>[index.ts]")]
  node_role_events[("Role event state<br/>Pinia store<br/>[role.ts]")]
  node_browser_storage[("Browser persistence<br/>IndexedDB/local storage")]
end

subgraph group_protocol["Game Protocol"]
  node_bon{{"BON codec<br/>protocol codec<br/>[bonProtocol.js]"}}
  node_websocket{{"WebSocket client<br/>transport<br/>[xyzwWebSocket.js]"}}
  node_game_servers(("XYZW game servers<br/>external service"))
end

subgraph group_deployment["Deployment Services"]
  node_edge_worker{{"Edge API proxy<br/>Cloudflare Worker<br/>[worker.js]"}}
  node_cloudflare_config["Cloudflare config<br/>deployment config<br/>[wrangler.toml]"]
  node_python_service["Optional .bin service<br/>Python backend<br/>[requirements.txt]"]
end

node_main -->|"installs"| node_router
node_main -->|"initializes"| node_token_store
node_router -->|"renders protected routes"| node_layout
node_router -->|"routes to import"| node_token_import
node_layout -->|"hosts"| node_dashboard
node_layout -->|"hosts"| node_daily_ui
node_token_import -->|"imports credentials"| node_token_store
node_token_store -->|"persists locally"| node_browser_storage
node_token_store -->|"selects role"| node_role_store
node_dashboard -->|"reads live state"| node_event_stores
node_daily_ui -->|"reads live state"| node_event_stores
node_event_stores -->|"includes"| node_role_events
node_websocket -->|"encodes and decodes via"| node_bon
node_websocket -->|"encrypted BON WebSocket"| node_game_servers
node_websocket -->|"routes incoming events"| node_event_stores
node_task_runners -->|"runs daily actions"| node_daily_runner
node_task_runners -->|"sends commands"| node_websocket
node_batch -->|"executes commands"| node_websocket
node_token_store -->|"supplies connection credentials"| node_websocket
node_python_service -.->|"provides token URLs/.bin inputs"| node_token_import
node_cloudflare_config -->|"configures"| node_edge_worker

click node_main "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/main.js"
click node_router "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/router/index.js"
click node_layout "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/layout/DefaultLayout.vue"
click node_token_import "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/TokenImport/index.vue"
click node_dashboard "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/Dashboard.vue"
click node_daily_ui "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/DailyTasks.vue"
click node_token_store "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/tokenStore.ts"
click node_role_store "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/gameRoles.js"
click node_event_stores "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/events/index.ts"
click node_role_events "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/events/role.ts"
click node_bon "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/bonProtocol.js"
click node_websocket "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/xyzwWebSocket.js"
click node_task_runners "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/helperTaskRunner.js"
click node_daily_runner "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/dailyTaskRunner.js"
click node_batch "https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/batch/index.js"
click node_edge_worker "https://github.com/w1249178256/xyzw_web_helper/blob/main/worker.js"
click node_cloudflare_config "https://github.com/w1249178256/xyzw_web_helper/blob/main/wrangler.toml"
click node_python_service "https://github.com/w1249178256/xyzw_web_helper/blob/main/server/requirements.txt"

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_main,node_router,node_layout,node_token_import,node_dashboard,node_daily_ui,node_task_runners,node_daily_runner,node_batch toneBlue
class node_token_store,node_role_store,node_event_stores,node_role_events,node_browser_storage toneAmber
class node_bon,node_websocket,node_game_servers toneMint
class node_edge_worker,node_cloudflare_config,node_python_service toneRose
```

## Components

### Vue SPA

Browser client runtime and feature shell.

- [SPA bootstrap](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/main.js): Vue entry · `src/main.js`
- [Routes and guards](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/router/index.js): Vue Router · Guards isolate token-dependent pages. · `src/router/index.js`
- [Authenticated layout](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/layout/DefaultLayout.vue): Vue layout · `src/layout/DefaultLayout.vue`
- [Token import](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/TokenImport/index.vue): Vue view · Accepts manual, URL, and .bin-derived tokens. · `src/views/TokenImport/index.vue`
- [Dashboard](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/Dashboard.vue): Vue view · `src/views/Dashboard.vue`
- [Daily tasks UI](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/views/DailyTasks.vue): Vue view · `src/views/DailyTasks.vue`
- [Single-task runners](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/helperTaskRunner.js): automation · Coordinates helper and daily commands. · `src/utils/helperTaskRunner.js`
- [Daily task runner](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/dailyTaskRunner.js): automation · `src/utils/dailyTaskRunner.js`
- [Batch automation](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/batch/index.js): scheduler · Executes arena, dungeon, hang-up, store, tower, and other task families. · `src/utils/batch/index.js`

### Local State

Pinia stores and browser-held credentials.

- [Token store](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/tokenStore.ts): Pinia store · Owns selected role, credentials, refresh data, and connection association. · `src/stores/tokenStore.ts`
- [Role state](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/gameRoles.js): Pinia store · Holds game-facing identity and status. · `src/stores/gameRoles.js`
- [Event store registry](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/events/index.ts): Pinia stores · Partitions incoming state by game domain. · `src/stores/events/index.ts`
- [Role event state](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/stores/events/role.ts): Pinia store · `src/stores/events/role.ts`
- **Browser persistence**: IndexedDB/local storage · Client-side credential and durable data boundary.

### Game Protocol

Encrypted BON WebSocket boundary.

- [BON codec](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/bonProtocol.js): protocol codec · Builds, encrypts, encodes, and decodes game payloads. · `src/utils/bonProtocol.js`
- [WebSocket client](https://github.com/w1249178256/xyzw_web_helper/blob/main/src/utils/xyzwWebSocket.js): transport · Manages lifecycle, queues, routing, and reconnects. · `src/utils/xyzwWebSocket.js`
- **XYZW game servers**: external service

### Deployment Services

Optional edge and token-hosting services.

- [Edge API proxy](https://github.com/w1249178256/xyzw_web_helper/blob/main/worker.js): Cloudflare Worker · `worker.js`
- [Cloudflare config](https://github.com/w1249178256/xyzw_web_helper/blob/main/wrangler.toml): deployment config · `wrangler.toml`
- [Optional .bin service](https://github.com/w1249178256/xyzw_web_helper/blob/main/server/requirements.txt): Python backend · Authenticated multi-user .bin storage and token-URL retrieval. · `server/requirements.txt`

## Connections

- SPA bootstrap → Routes and guards: installs
- SPA bootstrap → Token store: initializes
- Routes and guards → Authenticated layout: renders protected routes
- Routes and guards → Token import: routes to import
- Authenticated layout → Dashboard: hosts
- Authenticated layout → Daily tasks UI: hosts
- Token import → Token store: imports credentials
- Token store → Browser persistence: persists locally
- Token store → Role state: selects role
- Dashboard → Event store registry: reads live state
- Daily tasks UI → Event store registry: reads live state
- Event store registry → Role event state: includes
- WebSocket client → BON codec: encodes and decodes via
- WebSocket client → XYZW game servers: encrypted BON WebSocket
- WebSocket client → Event store registry: routes incoming events
- Single-task runners → Daily task runner: runs daily actions
- Single-task runners → WebSocket client: sends commands
- Batch automation → WebSocket client: executes commands
- Token store → WebSocket client: supplies connection credentials
- Optional .bin service → Token import: provides token URLs/.bin inputs
- Cloudflare config → Edge API proxy: configures
