Analytics Domain
This domain covers the Analytics experience implemented under
frontend/src/pages/analytics.
1️⃣ Domain Purpose
The Analytics domain provides a single place to: - explore analytics KPIs and trends (stock value, movement, pricing, low stock, finance) - filter analytics by date range and optionally by supplier - deep-link and share analytics views via URL state
A key intent is that the URL is the source of truth for the current section and filters, so analytics views are bookmarkable.
2️⃣ Scope & Boundaries
Included: - Page orchestration in Analytics.tsx
(tabs/section routing, filter state, URL sync) - Filters UI
(components/filters/*) including quick presets +
custom ranges - Section navigation
(components/AnalyticsNav.tsx) based on route
segments - Analytics blocks (blocks/*) that each
fetch and render a single chart/table
Excluded: - API-level mechanics (Axios client, caching rules, normalization) — see Data Access - Global routing rules (guards, shells) — see Routing - Shared layout chrome (header/sidebar) — see App Shell
3️⃣ High-Level Diagram
4️⃣ Domain Notes (Implementation-facing)
- Section selection is URL-driven:
/analytics/:section?(e.g./analytics/pricing). - Filters are URL-synced:
from,to, andsupplierIdare written back to search params. - Supplier list for the filter is fetched
once via React Query (
['analytics','suppliers']) and then passed into the filter component. - Many blocks gate fetching via
enabledwhen a required parameter is missing (e.g., low-stock table requires a supplier).
5️⃣ Domain Map (Deep-dives)
- Analytics URL & Section Routing
- Analytics Filters & URL Sync
- Analytics Blocks & Data Fetching
- Supplier-Gated Blocks
Related ADRs
- ADR-0003: Page model and domain separation
- ADR-0002: API layer abstraction (httpClient + domain modules)
- ADR-0005: Application shell split (authenticated vs public)