How supch/prunplanner-zh works
Purpose and runtime
PRUNplanner 中文版 is a localized Vue single-page planner for the Prosperous Universe game. It provides plan creation, production/economy analysis, market/exchange tools, FIO operations, account-backed data, and shareable plans. The browser app is bootstrapped at src/main.ts, composed by src/App.vue and src/AppProvider.vue, and served through Vite or a Docker static deployment (Dockerfile, docker-compose.yaml). Production is deployed to Cloudflare Pages; netlify.toml and public/_redirects support SPA deep-link routing.
Application shell, navigation, and localization
Routing maps feature views to the SPA at src/router/index.ts; primary screens live in src/views/, notably src/views/PlanView.vue, src/views/EmpireView.vue, and src/views/tools/ProductionChainView.vue. Shared navigation, progress states, and version notifications are in src/layout/components/NavigationBar.vue, src/layout/components/ComputingProgress.vue, and src/layout/components/VersionUpdateNotification.vue. Internationalization is backed by src/locales/index.ts, src/locales/en.json, and src/locales/zh.json; translated Markdown help is held under src/assets/help/.
Remote API and validation boundary
Feature-specific API clients isolate calls to the configured PRUNplanner backend: src/features/api/gameData.api.ts, src/features/api/planData.api.ts, src/features/api/empireData.api.ts, plus account, optimization, CX, and sharing clients. Transport/configuration is centralized in src/lib/apiService.ts and src/lib/config.ts, using VITE_API_BASE_URL; schemas in src/features/api/schemas/ validate API payloads at the client boundary. Share links use the independently configurable VITE_SHARE_BASE_URL.
Data loading, caching, and persistence
Route/feature wrappers orchestrate game and planning-data acquisition before rendering: src/features/wrapper/useGameDataLoader.ts, src/features/wrapper/usePlanningDataLoader.ts, and their loader components. Query caching is a distinct repository/store layer in src/lib/query_cache/queryRepository.ts, src/lib/query_cache/queryStore.ts, and src/lib/query_cache/useQuery.ts. Browser-local structured data is abstracted behind IndexedDB in src/database/composables/useDB.ts, src/database/composables/useIndexedDBStore.ts, and src/database/schema.ts; domain services expose building, material, planet, and exchange datasets.
Planning engine and state
Planning is the core computation pipeline. Plan persistence/loading is represented by src/features/planning_data/usePlan.ts; application state is held in src/stores/planningStore.ts. src/features/planning/usePlanCalculation.ts coordinates precomputation and handlers, feeding specialized deterministic calculations for buildings, extraction, bonuses, habitation optimization, and workforce under src/features/planning/calculations/. Results drive the plan workspace (src/features/planning/components/PlanArea.vue, PlanProduction.vue, PlanMaterialIO.vue) and downstream tools such as construction/supply carts, COGM, POPR, and repair analysis.
Domain analysis and graph stages
Empire and plan outputs feed economic analysis: src/features/empire/components/EmpireAnalysis.vue and src/features/empire/components/EmpireMaterialIO.vue aggregate plan-level behavior. ROI, resource ROI, market exploration, planet search, and CX pricing are separated feature modules, e.g. src/features/roi_overview/useROIOverview.ts, src/features/market_exploration/useMarketExploration.ts, and src/features/cx/useCXData.ts. Production-chain visualization transforms production relationships into nodes and edges in src/features/production_chain/productionGraph.ts, productionNode.ts, and productionEdge.ts; src/features/production_chain/useGraph.ts applies graph state/layout, rendered through GraphVueFlow.vue with Dagre configuration.
Identity, user operations, and external game actions
User/session state is separated in src/stores/userStore.ts, with login/registration/reset UI under src/features/account/components/ and account API access in src/features/api/userData.api.ts. Preferences and endpoint/API-key management are modularized in src/features/preferences/usePreferences.ts and src/features/endpoints/useEndpoints.ts. FIO and XIT actions form explicit external-operation boundaries through src/features/fio/useFIORepair.ts, src/features/xit/useXITAction.ts, and their action components. Analytics is isolated behind src/lib/analytics/useAnalytics.ts and src/lib/analytics/usePostHog.ts.
Main entry points: AppProvider.vue App Provider & Shell · usePlanningDataLoader.ts Game & Planning Loaders · PlanView.vue Planner & Empire Views · planningStore.ts Plan State & Persistence
Components 25
SPA Shell
- Vue Bootstrap
src/main.ts - App Provider & Shell
src/AppProvider.vue - Feature Router
src/router/index.ts - Planner & Empire Views
src/views/PlanView.vue - Navigation & Status
src/layout/components/NavigationBar.vue - Chinese / English i18n
src/locales/index.ts
Data Boundary
- API Transport · Uses the configured PRUNplanner backend URL.
src/lib/apiService.ts - Domain API Clients
src/features/api/gameData.api.ts - Payload Schemas · Validates backend payloads at the client boundary.
src/features/api/schemas/gameData.schemas.ts - Game & Planning Loaders
src/features/wrapper/usePlanningDataLoader.ts - Query Cache
src/lib/query_cache/queryRepository.ts - IndexedDB Domain Data
src/database/composables/useDB.ts
Planning Engine
- Plan State & Persistence
src/stores/planningStore.ts - Plan Calculation Pipeline · Coordinates precomputation and specialized plan handlers.
src/features/planning/usePlanCalculation.ts - Production Calculations · Building, extraction, bonus, habitation, and workforce calculations.
src/features/planning/calculations/buildingCalculations.ts - Plan Workspace
src/features/planning/components/PlanArea.vue
Analysis Tools
- Empire Analysis · Aggregates plan-level material and economic behavior.
src/features/empire/components/EmpireAnalysis.vue - ROI & Market Tools
src/features/market_exploration/useMarketExploration.ts - Production Chain Graph · Builds production nodes and edges for visualization.
src/features/production_chain/productionGraph.ts - Vue Flow Graph View · Applies graph state and Dagre layout.
src/features/production_chain/useGraph.ts
User Operations
- User Session
src/stores/userStore.ts - Account API
src/features/api/userData.api.ts - Preferences & Endpoints
src/features/preferences/usePreferences.ts - FIO & XIT Actions · Explicit boundary for game actions.
src/features/fio/useFIORepair.ts - Analytics
src/lib/analytics/useAnalytics.ts
Connections 28
- Vue Bootstrap → App Provider & Shell: mounts
- App Provider & Shell → Feature Router: hosts
- App Provider & Shell → Navigation & Status: renders
- App Provider & Shell → Chinese / English i18n: initializes
- Feature Router → Planner & Empire Views: selects
- Planner & Empire Views → Game & Planning Loaders: loads data
- Game & Planning Loaders → Domain API Clients: requests
- Game & Planning Loaders → Query Cache: reads and writes
- Domain API Clients → Payload Schemas: validates with
- Domain API Clients → API Transport: uses
- IndexedDB Domain Data → Game & Planning Loaders: provides local datasets
- Planner & Empire Views → Plan Workspace: renders
- Game & Planning Loaders → Plan State & Persistence: hydrates
- Plan Workspace → Plan State & Persistence: edits
- Plan State & Persistence → Plan Calculation Pipeline: feeds
- Plan Calculation Pipeline → Production Calculations: runs
- Production Calculations → Plan Workspace: produces results
- Plan State & Persistence → Empire Analysis: aggregates plans
- Empire Analysis → ROI & Market Tools: informs
- Production Calculations → Production Chain Graph: supplies relationships
- Production Chain Graph → Vue Flow Graph View: builds graph
- Planner & Empire Views → Vue Flow Graph View: renders tool
- Account API → API Transport: uses
- Account API → User Session: updates
- User Session → Preferences & Endpoints: scopes
- User Session → FIO & XIT Actions: authorizes
- FIO & XIT Actions → API Transport: executes through
- App Provider & Shell → Analytics: tracks through