# App.js Modularization ## Overview Original `app.js` (1370 lines) has been split into 7 ES6 modules totaling 1427 lines. ## Module Structure ``` js/ ├── config.js (136 lines) - Constants and configuration ├── api.js (56 lines) - API service layer ├── utils.js (132 lines) - Utility functions ├── wizard.js (199 lines) - Server recommendation wizard ├── pricing.js (502 lines) - Pricing table component ├── dashboard.js (350 lines) - Dashboard and Telegram integration └── app.js (52 lines) - Main entry point ``` ## Module Responsibilities ### config.js - `TELEGRAM_BOT_URL` - Telegram bot URL constant - `PRICING_DATA` - Legacy pricing data (VAT included, monthly basis) - `MOCK_SERVERS`, `MOCK_STATS`, `MOCK_NOTIFICATIONS` - Mock data for UI testing - `WIZARD_CONFIG` - Server recommendation wizard configuration ### api.js - `API_CONFIG` - API configuration (base URL, timeout, etc.) - `ApiService` - API request helper with error handling ### utils.js - `formatPrice()` - KRW price formatting - `switchTab()` - Tab switching (n8n/Terraform) - `updatePing()`, `startPingUpdates()`, `stopPingUpdates()` - Ping simulation - DOM event listeners for visibility change and keyboard navigation ### wizard.js - `calculateRecommendation()` - Rule-based server recommendation logic - `createWizardMethods()` - Wizard state and methods for Alpine.js ### pricing.js - `pricingTable()` - Pricing table component with API integration - Caching, filtering, sorting, and modal interactions - Supports Global (Tokyo/Osaka/Singapore) and Seoul regions - Subtabs for instance types (Standard/Dedicated/Premium/High Memory) ### dashboard.js - `createDashboardMethods()` - Dashboard state and methods - Telegram Mini App integration - Web login widget support (Telegram Login Widget) - Server management (start/stop/delete) - Stats and notifications ### app.js - Module imports and integration - `anvilApp()` - Main Alpine.js data function (merges wizard + dashboard) - Global function exposure (`window.anvilApp`, `window.pricingTable`) - `window.onTelegramAuth()` - Telegram web login callback - `window.AnvilDevTools` - Development tools ## Usage in HTML ```html ``` ## Alpine.js Integration All modules expose functions to `window` for Alpine.js `x-data`: ```html