data-layer

Define modular Firestore data access layers with domain-driven models, repositories, services, and use-cases.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/v-mobilelabs/care --skill data-layer-v-mobilelabs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-layer
Source: https://github.com/v-mobilelabs/care/tree/main/.github/skills/data-layer
Command: npx skills add https://github.com/v-mobilelabs/care --skill data-layer-v-mobilelabs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines a modular Firestore data access layer with domain-driven structure, including models, repositories, services, and use-cases for scalable data domains. It covers API routes, pagination, search, sort, caching, and error handling, with Zod validation and barrel exports.

Core Features & Use Cases

  • Domain-folder architecture: src/data/{domain}/ with models, repositories, service, use-cases, plus a barrel index.ts for imports.
  • Layered pattern: UseCase -> Service -> Repository with strict input validation at the boundary and consistent error handling.
  • SSR-ready patterns: cursor-based pagination, server-side counts using Firestore aggregation, and cache strategies via use cache and tags.
  • Multi-tenant support: profiles/{profileId}/{collection} scope and dependentId threading across layers.

Quick Start

Create a new domain under src/data/{domain} with models, repositories, service, and use-cases, and wire it into the barrel exports.

Frequently Asked Questions about data-layer

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

FAQPage Schema
How do I structure a Firestore data layer for scalable domains?

Structure a Firestore data layer using a domain-driven architecture of models, repositories, services, and use-cases. This modular organization supports scalable CRUD operations, pagination, and search while enforcing strict separation of concerns.

What is the best way to validate Firestore API boundaries with Zod?

Apply Zod schema validation directly at the use-case and service entry points to validate Firestore API boundaries. This ensures strict input validation before data reaches repositories, maintaining consistent error handling and data integrity.

How does cursor-based pagination work with Firestore aggregation queries?

Cursor-based pagination in Firestore uses query cursors to fetch subsequent pages alongside aggregation queries for accurate server-side counts. This SSR-ready pattern ensures efficient data fetching without loading entire collections into memory.

Can I use this domain-driven data layer for multi-tenant Firestore applications?

Yes, you can use this data layer for multi-tenant Firestore applications by scoping collections under profiles/{profileId}/{collection}. It threads dependentId parameters across architectural layers to maintain strict data isolation between tenants.

Does this Firestore data layer support SSR caching and RAG indexing?

Yes, the Firestore data layer supports SSR caching via use cache directives with tags and RAG indexing. These features are integrated into the service layer alongside pagination, search, and sort functionalities for server-rendered applications.