data-fetching-architecture

Standardize client-side data fetching with service layers, Zustand stores, and SWR hooks.

1|Updated May 20, 2026
One-click install
npx skills add https://github.com/mDevsLabs/mAI --skill data-fetching-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-fetching-architecture
Source: https://github.com/mDevsLabs/mAI/tree/main/.agents/skills/data-fetching-architecture
Command: npx skills add https://github.com/mDevsLabs/mAI --skill data-fetching-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Standardizes frontend data fetching by establishing a modular pattern that cleanly separates concerns among service calls, store management, and UI components, reducing boilerplate and errors.

Core Features & Use Cases

  • Service Layer for all API interactions to centralize business logic.
  • SWR-based Hooks for data fetching, caching, and revalidation.
  • Optimistic Updates & Cache Invalidation to provide responsive UI and consistent state.
  • ** Patterns Coverage** for list-detail and parent-keyed data flows using store-driven architecture.

Quick Start

Create a new domain service and wire it into the store following the canonical data-fetching architecture pattern.

Frequently Asked Questions about data-fetching-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize frontend data fetching with Zustand and SWR?

Standardize frontend data fetching by centralizing API interactions in a service layer, managing state with a Zustand store, and using SWR hooks for caching and revalidation to ensure consistent end-to-end data workflows.

What is the best way to separate service calls from UI state in a React frontend?

Separate service calls from UI state by establishing a modular pattern that centralizes business logic in a service layer, delegating data fetching to SWR hooks, and managing state via a Zustand store to reduce boilerplate and errors.

How do I handle cache invalidation and optimistic updates using SWR and Zustand?

Handle cache invalidation and optimistic updates by defining distinct cache keys and applying appropriate refresh strategies using SWR's mutate function alongside the Zustand store to provide a responsive UI and consistent state.

Can I use this service layer architecture for list and detail view data flows?

Yes, this service layer architecture provides patterns coverage for list-detail and parent-keyed data flows, applying a store-driven architecture to maintain consistent data access and caching across complex frontend views.

When do I need a dedicated service layer for client-side data fetching?

You need a dedicated service layer for client-side data fetching when your frontend architecture requires consistent data access, centralized business logic, and standardized caching workflows across multiple components to prevent errors.

Does data-fetching-architecture require specific dependencies to implement SWR hooks?

The data-fetching-architecture pattern requires integrating a service layer, a Zustand-based store, SWR hooks, defined cache keys, and mutate refresh strategies, operating within a frontend architecture needing consistent data access.