<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR speeds up the file detail page by migrating from blocking server-side data fetching (multiple CLI executions + sequential DB calls) to a single consolidated `/details` API endpoint backed by a four-table SQL JOIN. The page now renders immediately with a skeleton loader while data arrives client-side, and `tauTilde` is renamed to `tau` throughout to align the chart with the updated DB schema.
Key changes:
- **New `/details` endpoint** (`details/+server.ts`): single query joining `netflow_stats`, `ip_stats`, `structure_stats`, and `spectrum_stats`, replacing 8 individual client-side fetches.
- **CLI routes removed**: `structure-function/+server.ts` (burstify binary) and the CLI path in `spectrum/+server.ts` (MAAD binary) are replaced with DB-backed reads.
- **`+page.server.ts` → `+page.ts`**: The blocking server load is replaced with a lightweight universal load that just parses the slug; all data loading happens client-side with skeleton UX.
- **`slugToBucketStart` extracted** to `utils.ts` so all file-detail endpoints share the same PST-aware timestamp conversion.
- **`tauTilde` → `tau` rename** applied consistently across types, charts, and all endpoints.
Three issues identified:
1. **Retry buttons reload entire page** (`+page.svelte`): `reloadStructure` and `reloadSpectrum` unconditionally call `loadSummary`, triggering a full-page skeleton reload for all routers instead of targeted chart retry. The `_router` and `_source` parameters are silently discarded.
2. **`StructureResponse` duplicates shared type** (`structure/+server.ts`): The locally-defined type is structurally identical to `StructureFunctionData` from `$lib/types/types`, creating two sources of truth.
3. **Empty arrays treated as valid data** (`details/+server.ts`): `buildStructureData` and `buildSpectrumData` pass through `[]` as non-null data instead of treating it as missing, which renders a blank chart instead of the "not found" empty state.
<h3>Confidence Score: 3/5</h3>
- Architectural changes are sound, but three issues need resolution: retry UX regression, type duplication, and empty-array handling logic bug.
- The PR delivers the core performance goal (consolidating multiple slow calls into a single JOIN), and the `tau` rename is applied consistently. However, three verified issues reduce confidence: (1) retry buttons now trigger full-page reloads instead of targeted re-fetch, degrading UX; (2) `StructureResponse` duplicates `StructureFunctionData`, creating type maintenance burden; (3) empty arrays in `buildStructureData`/`buildSpectrumData` are treated as valid data, rendering blank charts instead of "not found" states. The empty-array issue is a logic bug that could silently lose user visibility into missing data. These are addressable before or after merging, but should be reviewed.
- `netflow-webapp/src/routes/api/netflow/files/[slug]/+page.svelte` (retry UX), `netflow-webapp/src/routes/api/netflow/files/[slug]/details/+server.ts` (empty-array logic), and `netflow-webapp/src/routes/api/netflow/files/[slug]/structure/+server.ts` (type duplication).
<h3>Sequence Diagram</h3>
```mermaid
sequenceDiagram
participant Browser
participant PageTs as +page.ts (universal load)
participant PageSvelte as +page.svelte
participant DetailsAPI as /details/+server.ts
participant SingAPI as /singularities/+server.ts
participant DB as SQLite DB
Browser->>PageTs: navigate to /files/[slug]
PageTs-->>Browser: { slug, fileInfo } (no DB call)
Browser->>PageSvelte: mount with slug + fileInfo
PageSvelte->>DetailsAPI: GET /api/netflow/files/[slug]/details
DetailsAPI->>DB: SELECT ns.*, ip.*, st.*, sp.*\nFROM netflow_stats ns\nLEFT JOIN ip_stats\nLEFT JOIN structure_stats\nLEFT JOIN spectrum_stats\nWHERE file_path LIKE '%nfcapd.[slug]'
DB-->>DetailsAPI: rows[]
DetailsAPI-->>PageSvelte: NetflowFileDetailsResponse\n{ routers: [{ summary, ipCounts, structure, spectrum }] }
PageSvelte->>PageSvelte: applyDbDetails() → populate maps\nsummaryLoading = false
par Singularities (per router)
PageSvelte->>SingAPI: GET /singularities?router=A&source=true
SingAPI-->>PageSvelte: SingularitiesData
PageSvelte->>SingAPI: GET /singularities?router=A&source=false
SingAPI-->>PageSvelte: SingularitiesData
end
PageSvelte-->>Browser: render charts + summary
```
<sub>Last reviewed commit: 2fa97f7</sub>
> Greptile also left **3 inline comments** on this PR.
<!-- /greptile_comment -->13 files changedLine totals unavailable