backend-patterns

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

Updated Apr 18, 2026
One-click install
npx skills add https://github.com/JohnRebellion/.claude-public --skill backend-patterns-johnrebellion
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/JohnRebellion/.claude-public/tree/main/claude/skills/backend-patterns
Command: npx skills add https://github.com/JohnRebellion/.claude-public --skill backend-patterns-johnrebellion

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 that prevent common pitfalls like N+1 queries and unstructured error responses. ## Core Features & Use Cases - API Design Patterns: RESTful endpoint structure, repository pattern, service layer separation, and middleware composition for authentication and logging. - Database Optimization: Query optimization, N+1 prevention through batch fetching, and transaction handling with Supabase RPC functions. - Infrastructure Patterns: Redis caching with cache-aside strategy, rate limiting, background job queues, JWT authentication, role-based access control, and structured logging. - Use Case: When building a Next.js API route that needs authentication, input validation, cached database access, and centralized error handling, activate this Skill to get production-ready TypeScript implementations of each layer. ## Quick Start Ask the AI to design a REST API endpoint with authentication, caching, and error handling for your Next.js application.

Frequently Asked Questions about backend-patterns

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

FAQPage Schema
How do I structure a REST API in Next.js?▼

Use resource-based URLs like GET /api/markets for lists and GET /api/markets/:id for single resources, with query parameters for filtering, sorting, and pagination. Separate concerns into repository, service, and controller layers for maintainability.

How to prevent N+1 queries in Supabase?▼

Batch fetch related records instead of querying in a loop. Collect all foreign keys, fetch related records in one query, then map them back in memory using a Map keyed by ID.

What is the repository pattern in TypeScript?▼

The repository pattern abstracts data access behind an interface, so business logic depends on the interface rather than a specific database client. This lets you swap implementations, such as a Supabase repository for a cached one, without changing service code.

Does the cache-aside pattern work with Redis?▼

Yes, cache-aside works by checking Redis first, fetching from the database on a miss, then populating the cache with a TTL. The pattern shown uses setex with a 300-second expiry and explicit invalidation on updates.

When should I use middleware vs service layer for auth?▼

Use middleware like a withAuth wrapper for cross-cutting concerns applied to many routes, such as token verification. Use the service layer for business-rule authorization, like role-based permission checks tied to specific operations.

Why use exponential backoff for API retries?▼

Exponential backoff spaces retries at increasing intervals (1s, 2s, 4s) to avoid overwhelming a recovering service. It handles transient failures gracefully while still surfacing persistent errors after the maximum retry count.