backend-patterns

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

2|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/Shubh2310-developer/ENGUNITYCORE --skill backend-patterns-shubh2310-developer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/Shubh2310-developer/ENGUNITYCORE/tree/main/.claude/skills/cc-skill-backend-patterns
Command: npx skills add https://github.com/Shubh2310-developer/ENGUNITYCORE --skill backend-patterns-shubh2310-developer

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 TypeScript implementations for each concern. ## Core Features & Use Cases - API & Layering Patterns: RESTful route design, repository pattern, service layer separation, and middleware composition for Next.js API routes. - Data & Performance Patterns: Query optimization, N+1 query prevention, transaction handling with Supabase, Redis caching, and cache-aside strategies. - Resilience & Security Patterns: Centralized error handling, retry with exponential backoff, JWT authentication, role-based access control, rate limiting, job queues, and structured logging. - Use Case: When building a new Next.js API endpoint that needs authentication, caching, and clean error responses, apply the middleware, cache-aside, and centralized error handler patterns directly from this Skill. ## Quick Start Apply the backend patterns skill to design a RESTful API route with JWT authentication, Redis caching, and centralized error handling for my 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 RESTful 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 using the repository pattern for data access and a service layer for business logic.

How to prevent N+1 query problems in backend code?

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

What is the cache-aside pattern with Redis?

Cache-aside checks Redis first for a key, and on a miss fetches from the database and writes the result to Redis with a TTL. This keeps frequently accessed data like market records fast to retrieve while the database remains the source of truth.

How do I implement JWT authentication in Next.js API routes?

Extract the Bearer token from the authorization header, verify it with jsonwebtoken against your JWT secret, and attach the decoded payload to the request. Wrap handlers in a withAuth middleware or call a requireAuth helper that throws a 401 ApiError on failure.

When should I use the repository pattern?

Use the repository pattern when you want to abstract data access behind an interface so business logic stays independent of the database. It is most valuable in larger codebases where you may swap implementations, such as moving from Supabase to another store, or need testable data layers.