dal-service-patterns

Route entity service CRUD operations through a DAL via NATS request-reply with MsgPack.

1|Updated Apr 17, 2026
One-click install
npx skills add https://github.com/PremModhaOfficial/motadata-ai-pipeline --skill dal-service-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dal-service-patterns
Source: https://github.com/PremModhaOfficial/motadata-ai-pipeline/tree/main/.claude/skills/dal-service-patterns
Command: npx skills add https://github.com/PremModhaOfficial/motadata-ai-pipeline --skill dal-service-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Data Access Layer (DAL) patterns enable entity services to delegate all data operations to a centralized database service, ensuring tenant isolation, consistent QueryStruct messaging, and safe caching strategies.

Core Features & Use Cases

  • NATS request-reply flow for QueryStruct messages between entity services and DAL
  • QueryStruct building in entity services and MsgPack response pass-through
  • L1 freecache checks before calling DAL to reduce latency
  • Batch transaction support for atomic multi-entity writes
  • DAL internal execution pipeline handling SQL compilation and data retrieval
  • Cache invalidation events to keep L1/L2 caches consistent
  • Clear separation: entity services do not execute SQL or import pgx; DAL handles SQL
  • Cross-tenant and per-tenant schema handling with provenance and routing rules

Quick Start

Configure your entity service to package queries as QueryStruct MsgPack and send them to the DAL via NATS.

Frequently Asked Questions about dal-service-patterns

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

FAQPage Schema
How do I centralize data access for entity services using NATS and MsgPack?

Centralize data access by routing all CRUD operations through a data-access-layer using NATS request-reply and MsgPack encoding, ensuring entity services delegate SQL execution to the DAL.

How does L1 caching work with DAL request-reply patterns?

L1 caching works by checking a freecache layer before calling the DAL, reducing latency. Cache invalidation events are then used to keep L1 and L2 caches consistent after data mutations.

Can I execute batch transactions atomically through a data-access-layer?

Yes, you can execute batch transactions atomically through the DAL. The pattern supports atomic multi-entity writes by packaging multiple operations into a single DAL request.

Does the DAL pattern enforce tenant isolation for entity services?

The DAL pattern enforces tenant isolation by handling cross-tenant and per-tenant schema routing, ensuring entity services delegate data operations without direct database access.

Why should entity services not import pgx or execute SQL directly?

Entity services should not import pgx or execute SQL directly to maintain a clear architectural separation, ensuring the DAL handles all SQL compilation, data retrieval, and database connectivity.

How do I build QueryStruct messages for NATS data access requests?

Build QueryStruct messages in entity services by packaging query parameters into the structure, then encode and send them via NATS request-reply to receive MsgPack columnar results from the DAL.