API Usage Patterns¶
Chunk 13 introduces the first formal UI-to-API integration pattern for InfraLynx.
Principles¶
- the UI consumes API payloads through dedicated service functions
- raw transport payloads are normalized before they reach React components
- domain IDs stay explicit and stable across layers
- rendering code does not shape API requests directly
Current Flow¶
- The web app requests
/api/overview. src/services/api-client.tshandles transport and HTTP failures.src/services/domain-overview.tsnormalizes the payload into UI-specific contracts.- React hooks and reducer-backed state deliver a render-safe model to the shell.
Contract Discipline¶
- backend payloads may evolve as long as the UI normalization layer is updated deliberately
- React components should consume normalized models, not backend response types spread across the app
- future mutation calls should follow the same transport-and-normalization boundary