# 🔴 Finance Module Recovery Blueprint — Root Cause Analysis & Recovery Plan **Date:** 2026-07-26 **Author:** Architect Mode **Status:** Pending Code Mode Execution **Priority:** CRITICAL — Multiple systemic bugs across Frontend & Backend --- ## STEP 1: ARCHITECTURAL COMPARISON — Dashboard vs. Finance ### 1.1 Layout Wrapper Comparison | Aspect | DashboardView (Working) | FinanceMainView (Broken) | |--------|-------------------------|--------------------------| | **Parent Layout** | PrivateLayout — provides BaseHeader with hamburger menu | FinanceLayout — provides same BaseHeader but with HeaderBackButton | | **Background** | Self-contained: `fixed inset-0` + `bg-[url('@/assets/garage-bg.png')]` in the component itself | Duplicated in layout: same `fixed inset-0` background in FinanceLayout | | **Header Teleport** | NO Teleport usage — DashboardView owns its own header via the background div | USES Teleport: FinanceMainView teleports `` into `#header-teleport-target` | | **Router Nesting** | Dash is a child of PrivateLayout | Finance is a child of FinanceLayout | ### 1.2 Card Component Comparison | Aspect | Working Dashboard Cards | Broken Finance Cards | |--------|------------------------|---------------------| | **Root Element** | Single `
` with CSS classes directly on the card (e.g., MyVehiclesCard.vue:2-4) | Same pattern: plain `
` with identical CSS ✅ | | **Click Handler** | Invisible overlay `
` with `@click` (e.g., MyVehiclesCard.vue:6-9) | Same pattern: invisible overlay with `@click` router push ✅ | | **Data Binding** | Uses Pinia stores (financeStore, vehicleStore, authStore) | Same Pinia stores used ✅ | | **Component Import** | Imports card components from dashboard/ | Standalone views — no card components imported, HTML inline | ### 1.3 Key Architectural Difference **The only structural difference is the Teleport usage.** The working `DashboardView` uses `` ONLY for its Flip Modal overlay, which is always available in the DOM. The broken `FinanceMainView` uses `` — a target that is conditionally rendered inside `BaseHeader`, which itself is nested inside `FinanceLayout`. --- ## STEP 2: ROOT CAUSE ANALYSIS OF 4 KNOWN BUGS ### 🔴 BUG 1: Teleport Freeze — `Failed to locate Teleport target with selector "#header-teleport-target"` **Root Cause:** Vue Router lifecycle timing mismatch between Teleport mount/unmount and DOM availability. **Evidence:** - `FinanceMainView.vue:38-40` uses `` to inject a page title - The target `#header-teleport-target` is defined in `BaseHeader.vue:15` - `BaseHeader` is rendered inside `FinanceLayout.vue:35` **Failure scenario:** 1. User navigates FROM `/finance` TO `/dashboard` 2. Vue Router starts unmounting the `/finance` route tree: FinanceMainView → FinanceLayout → BaseHeader 3. FinanceMainView tries to unmount its Teleported `` from `#header-teleport-target` 4. BUT BaseHeader (which contains the target) has already been destroyed or is in the process of being destroyed 5. Vue throws: `Failed to locate Teleport target with selector "#header-teleport-target"` 6. The app freezes because the Teleport cleanup throws an unhandled error that halts the transition **The same issue can happen on MOUNT:** if FinanceMainView renders before BaseHeader finishes mounting, the Teleport target doesn't exist yet. **Contrast with DashboardView:** The working `DashboardView:101` teleports to `"body"` — which **always** exists in the DOM, regardless of component lifecycle. ### 🔴 BUG 2: Component Resolution Error — `Failed to resolve component: TechDataTab` **Root Cause:** Missing import statement in `VehicleDetailModal.vue`. **Evidence:** - `VehicleDetailModal.vue:284` uses `` in its template - The `