backend-patterns

Implements backend architecture patterns for Node.js, Express, and Next.js API development.

2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/adamreger/ecc-antigravity --skill backend-patterns-adamreger
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/adamreger/ecc-antigravity/tree/main/skills/backend-patterns
Command: npx skills add https://github.com/adamreger/ecc-antigravity --skill backend-patterns-adamreger

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building scalable server-side applications requires consistent patterns for API design, database access, caching, and error handling, and this Skill provides proven implementations to avoid common pitfalls like N+1 queries and unstructured error responses. ## Core Features & Use Cases - API Design Patterns: RESTful resource structure, repository pattern, service layer separation, and middleware composition for authentication and logging. - Database Optimization: Query column selection, N+1 query prevention with batch fetching, and transaction handling via Supabase RPC functions. - Caching & Resilience: Redis cache-aside patterns, retry with exponential backoff, rate limiting, and background job queues. - Use Case: When building a Next.js API route that fetches markets with their creators, apply the batch-fetch pattern to eliminate N+1 queries and wrap the handler with JWT auth middleware and a centralized error handler. ## Quick Start Ask the AI to design a REST API endpoint with repository pattern, caching, and error handling for your Node.js or Next.js backend.

Frequently Asked Questions about backend-patterns

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

FAQPage Schema
How do I prevent N+1 queries in Node.js backend code?▼

Prevent N+1 queries by batch fetching related records instead of querying in a loop. Collect all foreign key IDs, fetch them in one query, then build a Map for O(1) lookups when joining data in memory.

How to structure a Next.js API route with authentication middleware?▼

Wrap your handler with a higher-order function that verifies the JWT token from the Authorization header before calling the handler. The middleware attaches the authenticated user to the request and returns 401 for invalid tokens.

What is the repository pattern in backend development?▼

The repository pattern abstracts data access behind an interface, separating business logic from database queries. Implementations like a Supabase repository handle filtering, pagination, and error mapping while services consume the interface.

Does the cache-aside pattern work with Redis in Node.js?▼

Yes, cache-aside works by checking Redis first, falling back to the database on a miss, then populating the cache with a TTL. Use setex with an expiration like 300 seconds and invalidate keys when data changes.

When should I use a job queue instead of processing in the request?▼

Use a job queue for long-running tasks like indexing or embedding generation that would block the HTTP response. Queue the job, return immediately with a success message, and process asynchronously with error logging.