# TASKS.md - EZSCALE Site Task Tracker

## Phase 1: Foundation & Core Setup ✅
- [x] Initialize Laravel 12 project with Vue + Inertia starter kit (base install in `website/`)
- [x] Configure domain routing (ezscale.dev, account.ezscale.dev, admin.ezscale.dev)
- [x] Set up MySQL 8.x database (ezscale_billing + test DB)
- [x] Configure Redis (cache, queue, sessions)
- [x] Install core dependencies (cashier, fortify, passport, paypal, spatie, inertia, vue3)
- [x] Create complete database schema (30 migrations, 15 custom tables)
- [x] Set up Laravel Fortify with Vue/Inertia auth pages (7 pages: login, register, forgot/reset password, verify email, confirm password, 2FA challenge)
- [x] Implement 2FA (TOTP via Fortify)
- [x] Configure spatie roles: `admin` and `customer`
- [x] Set up middleware: auth, role-based, rate limiting, HandleInertiaRequests, EnsureUserNotSuspended
- [x] Create 14 Eloquent models with factories, relationships, and casts
- [x] Create seeders (roles/permissions, plans, admin user)
- [x] Build customer dashboard + admin dashboard (placeholder)
- [x] Set up Pest testing framework (24 Phase 1 tests passing)
- [x] Dark mode UI across all pages
- [x] Migrate frontend from Tailwind CSS to Vuetify 3 (Vuexy design system) with TypeScript
- [ ] Configure Cloudflare Zero Trust for admin panel
- [ ] Set up GitHub Actions CI/CD pipeline
- [ ] Create staging environment (staging.account.ezscale.cloud)
- [ ] Configure Mailgun or SendGrid for emails

## Phase 2: Billing & Subscriptions ✅
- [x] Implement `BillingServiceInterface` abstraction
- [x] Build `StripeBillingService` (wraps Laravel Cashier)
- [x] Build `PayPalBillingService` (wraps srmklive/laravel-paypal)
- [x] Create plan catalog with seeder (6 sample plans across VPS, dedicated, hosting, game)
- [x] Implement subscription creation flow (plan browsing → checkout → payment → coupon support)
- [x] Build payment method management (add/remove/set default via Stripe)
- [x] Build invoice and transaction history pages (paginated, download support)
- [x] Set up webhook handlers for Stripe and PayPal
- [x] Build subscription management (cancel/resume/swap plan)
- [x] Build dunning system (DunningService + scheduled ProcessDunning command)
- [x] Implement coupon system (validation, redemption, percentage/fixed discounts)
- [x] Automatic suspension policy (grace period → suspend → terminate)
- [x] Event-driven architecture (PaymentSucceeded/Failed, SubscriptionCreated/Cancelled)
- [x] 8 Vue pages for billing flow (plans, checkout, subscriptions, billing/invoices/transactions)
- [x] 29 Phase 2 tests (53 total passing)
- [x] Invoice PDF generation (barryvdh/laravel-dompdf)
- [ ] Multi-currency support (EUR, GBP, USD, etc.)
- [ ] Tax calculation integration (TaxJar/Avalara or manual rates)
- [ ] Proration logic for upgrades/downgrades (Cashier swap method)
- [x] Admin coupon management CRUD
- [x] Email notifications for payment events

## Frontend Migration: Tailwind → Vuetify/Vuexy ✅ (superseded by redesign below)
- [x] Install Vuetify 3, TypeScript, Pinia, Sass, vite-plugin-vuetify
- [x] Remove Tailwind CSS
- [x] Configure TypeScript (tsconfig.json, path aliases, strict mode)
- [x] Set up Vuetify plugin (theme, defaults, icons)
- [x] Rename resources/js → resources/ts, convert to TypeScript
- [x] Copy Vuexy @core SCSS overrides (38 files — base + template + 25 components)
- [x] Create @layouts stubs for Vuexy SCSS compatibility
- [x] Configure Vite aliases (@core-scss, @configured-variables, @layouts)
- [x] Create 4 layouts: AccountLayout, AdminLayout, AuthLayout, MarketingLayout
- [x] Create shared components: FlashMessages, StatCard, StatusChip, ThemeSwitcher
- [x] Create AppTextField, AppSelect, AppTextarea wrapper components (Vuexy pattern)
- [x] Migrate all 19 existing pages to Vuetify + TypeScript
- [x] Create 9 marketing pages (Home, Products, VPS, Dedicated, Web, Game, Pricing, About, Contact)
- [x] Create navigation configs (account.ts, admin.ts, marketing.ts)
- [x] Set purple primary color (#7367F0) matching Vuexy demo
- [x] 252 tests passing, 1310 assertions (12 pre-existing VpsControllerTest failures)

## Full Frontend Redesign (2026-03-14) ✅
- [x] Phase 0 — Foundation: new SCSS design system (8 files), navy blue palette (#1d4ed8), Plus Jakarta Sans + JetBrains Mono fonts, removed Vuexy @core SCSS (38 files), installed echarts/vue-echarts/@vueuse/core
- [x] Phase 1 — Layout Infrastructure: 8 new shared components (AppSidebar, AppTopNavbar, CommandPalette, ToastStack, NotificationPanel, SkeletonLoader, EmptyState, Breadcrumbs), Pinia toast store, rebuilt all 4 layouts
- [x] Phase 2 — Marketing Components: 9 new components (HeroSection, NetworkHero, VpsHero, DedicatedHero, WebHostingHero, GameServerHero, GlassCard, ScrollReveal, PricingCard)
- [x] Phase 3 — Page Migration: replaced AppTextField/AppSelect/AppTextarea with native Vuetify across 28 pages, merged Products→Home and BattlefieldAcp→GameServers, added 301 redirects
- [x] Phase 4 — Polish: theme persistence (localStorage), theme-aware CSS custom properties, headless Chrome visual verification

## Bug Fixes (2026-03-14) ✅
- [x] placeOrder() column name fixes (payment_method→payment_gateway, removed non-existent columns)
- [x] VirtFusion provisioning_info stored in credentials via array_merge (was using non-existent column)
- [x] PayPal webhook header verification (PAYPAL-TRANSMISSION-* headers)
- [x] VPS root password moved from success flash to secure new_password flash key with dialog
- [x] ensure_not_suspended middleware applied to account routes with impersonation bypass + banned check
- [x] User::invoices() renamed to billingInvoices() to avoid Cashier conflict (updated 7+ call sites)
- [x] Impersonation stop route added on account subdomain
- [x] Performance indexes migration (invoices.status, orders.status, audit_logs.action/created_at)
- [x] Invoice number collision fix (Str::random(6) instead of count()+1/rand())
- [x] Dashboard stats caching (Cache::remember with 5-min TTL)
- [x] Stripe last_four→last4 property fix in BillingController
- [x] FlashProps type updated with info and new_password keys

## Notifications System ✅
- [x] Create notification classes (PaymentSucceeded, PaymentFailed, SubscriptionCreated, SubscriptionCancelled, ServiceProvisioned, InvoiceGenerated)
- [x] Configure mail and database notification channels
- [x] Wire notifications to relevant events (PaymentSucceeded, PaymentFailed, SubscriptionCreated, SubscriptionCancelled, ServiceProvisioned, InvoiceGenerated)
- [x] Build NotificationBell component in Account and Admin layouts
- [x] Implement NotificationController (index, markAsRead, markAllAsRead)
- [x] FlashMessages supports info alerts
- [x] Inertia shared data includes impersonation state

## Phase 3: Provisioning Automation ✅
- [x] Create `ProvisioningServiceInterface` abstraction
- [x] Build VirtFusion provisioning service:
  - [x] Create VPS via API
  - [x] Suspend/unsuspend VPS
  - [x] Terminate VPS
  - [x] Get status and resource usage
  - [x] Credential generation and secure storage
- [x] Build Pterodactyl provisioning service:
  - [x] Create game server via API
  - [x] Suspend/unsuspend server
  - [x] Delete server
  - [x] Get server status and resources
- [x] Build SynergyCP provisioning service:
  - [x] Provision dedicated server
  - [x] Suspend/unsuspend server
  - [x] Terminate server
  - [x] Get server details
  - [x] Handle limited hardware inventory (waitlist/semi-auto)
- [x] Build Enhance provisioning service:
  - [x] Create web hosting account
  - [x] Suspend/delete account
  - [x] Get account status
- [x] Implement event-driven provisioning (listen to `PaymentSucceeded` events)
- [x] Build provisioning failure handling and retry logic
- [x] Send credentials email on successful provisioning
- [x] Log all provisioning actions to `provisioning_logs` table
- [x] Idempotent provisioning (Service::firstOrCreate to prevent duplicates on retry)
- [x] Provisioning retry command (provisioning:retry scheduled every 5 minutes)

## Support Ticket System (Standalone) ✅
- [x] TicketReply model with relationships
- [x] Updated SupportTicket model with replies() relationship and department field
- [x] Migration: ticket_replies table + department column on support_tickets
- [x] Customer TicketController (index, create, store, show, reply, close)
- [x] Admin TicketController (index with filters, show, reply, updateStatus)
- [x] SupportTicketFactory with open/closed/urgent states
- [x] TicketReplyFactory with staffReply state
- [x] Customer Vue pages: Tickets/Index, Tickets/Create, Tickets/Show
- [x] Admin Vue pages: Admin/Tickets/Index, Admin/Tickets/Show
- [x] Ticket status/priority color resolvers
- [x] TypeScript interfaces for SupportTicket and TicketReply
- [x] Navigation items for both account and admin sidebars
- [x] Routes for both account and admin subdomains
- [x] 42 Pest tests for tickets (252 total, 1310 assertions)

## Phase 4: Customer Dashboard (account.ezscale.cloud)
- [x] Build service overview dashboard:
  - [x] Active services list with status indicators
  - [ ] Resource usage widgets (CPU, RAM, disk, bandwidth)
  - [x] Next invoice and payment due date
  - [x] Recent support tickets
  - [x] Quick actions (renew, upgrade, create ticket)
- [x] Build service detail pages:
  - [x] VPS details (IP, credentials, resource graphs, control buttons)
  - [x] Game server details (connect info, resource usage, restart button)
  - [x] Dedicated server details (IPs, access info, bandwidth graph)
  - [x] Web hosting details (domain, cPanel/Enhance link, disk usage)
- [ ] Bandwidth usage graphs (from ElastiFlow integration)
- [x] Billing section:
  - [x] Invoice history (with PDF download)
  - [x] Payment history
  - [x] Manage payment methods (add/remove cards, set default)
  - [x] Upcoming renewals
- [x] Plan upgrade/downgrade flow (self-service with proration)
- [x] Subscription cancellation flow (with optional survey)
- [x] Profile and account settings:
  - [x] Contact information
  - [x] Billing/shipping addresses
  - [x] Tax ID
  - [x] Password change
  - [x] 2FA setup (TOTP, passkeys)
## Phase 5: Admin Panel (admin.ezscale.cloud) ✅
- [x] Analytics dashboard:
  - [x] MRR (Monthly Recurring Revenue) graph
  - [x] ARR (Annual Recurring Revenue)
  - [x] Churn rate calculation and graph
  - [x] Customer growth chart
  - [x] Revenue trends (daily, monthly, yearly)
  - [x] Popular plans and conversion rates
  - [x] Outstanding invoices total
  - [x] Overdue accounts list
- [x] Customer management:
  - [x] Customer list (searchable, filterable)
  - [x] Customer detail view (profile, services, billing history, notes)
  - [x] Edit customer information
  - [x] Impersonate customer (with audit logging)
  - [x] Add admin notes to customer account
  - [x] View customer audit log
- [x] Service management:
  - [x] All services list (filter by type, status, platform)
  - [x] Manually provision service
  - [x] Suspend/unsuspend service
  - [x] Terminate service
  - [x] Modify service (change plan)
  - [x] Extend service expiry (admin override subscription end date)
  - [x] View provisioning logs
  - [x] Archive/restore services (soft-delete with SoftDeletes trait)
- [x] Order management:
  - [x] Pending orders list
  - [x] Approve/reject orders (for semi-automated provisioning)
  - [x] View order details
- [x] Invoice management:
  - [x] All invoices list (filter by status, date, customer)
  - [x] Create manual invoice
  - [x] Edit invoice (before sending)
  - [x] Void/refund invoice
  - [x] Resend invoice email
- [x] Coupon management:
  - [x] Create coupon (percentage, fixed, applies to plans)
  - [x] Edit coupon details
  - [x] View redemption history
  - [x] Deactivate/delete coupon
- [x] Plan management:
  - [x] Create new plan (set pricing, features, billing cycle)
  - [x] Edit existing plan
  - [x] Archive/hide plan
  - [x] Set stock quantity (for limited dedicated servers)
- [x] System configuration:
  - [x] Email template editor (7 templates with variable substitution, preview, reset to default)
  - [x] Tax rate configuration (by country/region, inclusive/exclusive, priority-based)
  - [x] Suspension policy settings (days before suspend/terminate)
  - [x] Bandwidth overage rates (in billing settings tab)
  - [x] Discord webhook URLs (4 channels with test buttons)
  - [x] API credentials (VirtFusion, Pterodactyl, SynergyCP, Enhance — with test connection)
- [x] Audit log viewer:
  - [x] Filter by user, action, date
  - [x] View changes (before/after state with expandable rows and detail dialog)
  - [x] Export logs

## Phase 6: Bandwidth Monitoring & Billing
- [ ] Set up NetFlow/sFlow export from Juniper switches
- [ ] Deploy ElastiFlow collector
- [ ] Build `BandwidthService` to query ElastiFlow API
- [ ] Create scheduled job to collect daily bandwidth data
- [ ] Store bandwidth usage in `bandwidth_usage` table
- [ ] Build bandwidth usage graphs for customer dashboard
- [ ] Implement multi-threshold alerts:
  - [ ] 75% quota warning email
  - [ ] 90% quota warning email
  - [ ] 100% quota reached email
  - [ ] Discord webhook for high usage customers
- [ ] Implement automatic overage billing:
  - [ ] Calculate overages at end of billing cycle
  - [ ] Generate overage invoice
  - [ ] Email customer with overage details
- [ ] Build admin bandwidth reports:
  - [ ] Top bandwidth users
  - [ ] Total bandwidth by service type
  - [ ] Overage revenue report

## Phase 8: Marketing Frontend (ezscale.cloud)
- [x] Homepage:
  - [x] Hero section with value proposition
  - [x] Featured services/plans
  - [x] Trust indicators (uptime, customers, years in business)
  - [x] Call to action (Get Started, View Plans)
- [x] Product pages:
  - [x] VPS hosting page with plan comparison
  - [x] Dedicated servers page with configurations
  - [x] Web hosting page with features
  - [x] Game server hosting page with supported games
- [x] Pricing page:
  - [x] Interactive plan comparison table
  - [x] Billing cycle toggle (monthly/quarterly/semi-annual/annual)
  - [x] Service type tabs with per-type feature display
  - [x] Popular/Best Value badges on plans
  - [ ] Currency selector (USD, EUR, GBP)
  - [ ] Coupon code application
  - [ ] Add to cart / checkout flow
- [x] About page
- [x] Contact page with form submission backend
- [ ] Blog/news section (optional, or use WordPress?)
- [ ] Knowledge base / FAQ:
  - [ ] Getting started guides
  - [ ] Tutorials
  - [ ] Troubleshooting
  - [ ] API documentation
- [x] Legal pages:
  - [x] Terms of Service
  - [x] Privacy Policy
  - [x] Acceptable Use Policy
  - [x] SLA (Service Level Agreement)
  - [x] Footer links to legal pages
- [x] Signup flow:
  - [x] Plan selection (CTAs on pricing + product pages link to checkout)
  - [x] Account creation (register/login pages show plan context)
  - [x] Payment information (checkout page with Stripe/PayPal)
  - [x] Order confirmation (success redirect with flash message)
  - [x] Redirect to account dashboard (via Fortify intended URL)

## Phase 9: API Development ✅
- [x] Customer API (RESTful, Passport auth):
  - [x] GET /api/v1/services - List customer's services (paginated)
  - [x] GET /api/v1/services/{id} - Service details
  - [x] POST /api/v1/services/{id}/reboot - Reboot server (VPS only)
  - [x] GET /api/v1/invoices - Invoice history (filterable by status)
  - [x] GET /api/v1/invoices/{id}/pdf - Download invoice PDF
  - [ ] GET /api/v1/bandwidth - Bandwidth usage (depends on Phase 6)
  - [x] POST /api/v1/subscriptions/{id}/cancel - Cancel subscription
  - [x] POST /api/v1/tickets - Create support ticket
  - [x] GET /api/v1/tickets/{id} - Ticket details with replies
  - [x] POST /api/v1/tickets/{id}/reply - Reply to ticket
  - [x] GET /api/v1/subscriptions - List subscriptions
- [x] Admin API:
  - [x] GET /api/v1/admin/customers - List all customers (searchable, filterable)
  - [x] GET /api/v1/admin/customers/{id} - Customer details
  - [x] GET /api/v1/admin/services - List all services (filterable)
  - [x] GET /api/v1/admin/services/{id} - Service details
  - [x] POST /api/v1/admin/services/{id}/suspend - Suspend service
  - [x] POST /api/v1/admin/services/{id}/unsuspend - Unsuspend service
  - [x] GET /api/v1/admin/analytics - Analytics data (MRR, ARR, churn, growth)
- [x] API documentation (public marketing page at /api-docs with all endpoints, params, responses)
- [x] API rate limiting and throttling (60/min customer, 120/min admin)
- [x] API versioning strategy (v1 prefix)
- [x] API Resources (Service, Invoice, Subscription, Ticket, Customer, AdminService, Analytics)
- [x] 49 API tests (373 assertions)

## Phase 10: Testing, Migration & Launch
- [ ] Unit tests for all services and models
- [ ] Feature tests for critical user flows:
  - [ ] Signup and subscription creation
  - [ ] Payment processing (Stripe + PayPal)
  - [ ] Service provisioning (all platforms)
  - [ ] Upgrades/downgrades
  - [ ] Cancellations
  - [ ] Invoice generation
  - [ ] Bandwidth overage billing
- [ ] Integration tests:
  - [ ] VirtFusion API integration
  - [ ] Pterodactyl API integration
  - [ ] SynergyCP API integration
  - [ ] Enhance API integration
  - [ ] ElastiFlow API integration

- [ ] Security testing:
  - [ ] Penetration testing (OWASP Top 10)
  - [ ] Dependency vulnerability scanning
  - [ ] CSRF and XSS testing
  - [ ] SQL injection testing
  - [ ] Rate limiting testing
- [ ] Performance testing:
  - [ ] Load testing (100+ concurrent users)
  - [ ] Database query optimization
  - [ ] Redis caching implementation
  - [ ] CDN for static assets
- [ ] WHMCS migration:
  - [ ] Create migration commands:
    - [ ] `migrate:whmcs-customers`
    - [ ] `migrate:whmcs-subscriptions`
    - [ ] `migrate:whmcs-invoices`
    - [ ] `migrate:whmcs-payments`
    - [ ] `migrate:whmcs-services`
    - [ ] `migrate:whmcs-tickets`
  - [ ] Test migration in staging
  - [ ] Verify data integrity
  - [ ] Map WHMCS product IDs to new plan IDs
  - [ ] Coordinate Stripe/PayPal subscription transfer
- [ ] Pre-launch checklist:
  - [ ] Email customers about migration
  - [ ] Set up WHMCS URL redirects
  - [ ] Configure monitoring (Laravel Telescope, log aggregation)
  - [ ] Set up error tracking (Sentry, Bugsnag)
  - [ ] Configure backups (database, files, Redis)
  - [ ] DNS configuration for all domains
  - [ ] SSL certificates for all domains
  - [ ] Cloudflare Zero Trust for admin panel
- [ ] Launch:
  - [ ] Execute final WHMCS migration during maintenance window
  - [ ] Enable production mode
  - [ ] Monitor for errors and performance issues
  - [ ] 30-day parallel operation (keep WHMCS read-only)
  - [ ] Gather customer feedback
  - [ ] Address bugs and issues
- [ ] Post-launch:
  - [ ] Monitor analytics and revenue
  - [ ] Track customer satisfaction
  - [ ] Iterate based on feedback
  - [ ] Plan future features

## Phase 11: Future Enhancements (Post-Launch)
- [ ] Mobile app (iOS/Android) using API
- [ ] Advanced analytics (cohort analysis, LTV predictions)
- [ ] Automated resource scaling (auto-upgrade when limits reached)
- [ ] Custom server configurations (customer can configure RAM, CPU, disk)
- [ ] Marketplace for add-ons (additional IPs, backups, snapshots)
- [ ] Advanced bandwidth analytics (top talkers, traffic patterns)
- [ ] Integration with accounting software (QuickBooks, Xero)
- [ ] Advanced reporting (custom reports, scheduled exports)
- [ ] Customer referral program (instead of affiliates)
- [ ] Live chat support integration
- [ ] Status page for service health
- [ ] Automated security scanning for customer servers
- [ ] Backup management interface
- [ ] Server snapshots and restoration
