⬅️ Back to Frontend Architecture Index
Data Access
1️⃣ Section Purpose
This section documents how the frontend talks to the backend and how API responses are shaped into UI-ready data.
The goal is to make data access: - predictable (consistent layering and query keys) - resilient (tolerant parsing and user-friendly errors) - testable (API logic stays out of components)
2️⃣ Scope & Boundaries
Included: - The shared HTTP client and cross-cutting
request/response behavior - Domain API modules under
frontend/src/api/* (inventory, suppliers,
analytics) - Parsing/normalization utilities (envelopes, type
guards, field pickers) - React Query hooks (query keys, caching,
conditional fetching)
Excluded: - Authentication UI flows and route-guards (see Routing) - Global app state providers (see State) - UI component details (see UI Components)
3️⃣ High-Level Diagram
4️⃣ Section Map (Links to nested docs)
Contents
- Layering & Contracts - The intended dependency direction and what UI code should (and should not) import
- HTTP Client & Auth
Boundaries - Base URL, cookies
(
withCredentials), and 401 redirect rules - React Query Hooks -
Query keys, caching
(
staleTime/gcTime), andenabledconditions - Response Shapes & Normalization - Envelope tolerance (array vs Page) and defensive normalizers
- Errors & Fallbacks - Converting failures into user-friendly messages and safe UI defaults
- Connectivity
& Session Probes - Health/db check and
/api/mesession validation
Related ADRs
- ADR-0002: API layer abstraction with shared httpClient
- ADR-0006: Global state with Context modules (boundary vs server-state)
- ADR-0001: Frontend folder structure strategy