backend-patterns

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

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/diazMelgarejo/orama-system --skill backend-patterns-diazmelgarejo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/diazMelgarejo/orama-system/tree/main/.cursor/.agents/skills/backend-patterns
Command: npx skills add https://github.com/diazMelgarejo/orama-system --skill backend-patterns-diazmelgarejo

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 & Layered Architecture: RESTful endpoint design, repository pattern, service layer separation, and middleware composition for auth and logging. - Database & Caching: Query optimization, N+1 prevention, Supabase transactions, Redis cache-aside strategies, and cache invalidation. - Resilience & Security: Centralized error handling, retry with exponential backoff, JWT validation, role-based access control, and rate limiting. - 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. ## Quick Start Apply backend patterns to design a cached, authenticated REST endpoint for listing markets in my Next.js app.

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 APIs?

Batch fetch related records instead of querying in a loop. Collect all foreign keys, run a single query for the related entities, build a Map keyed by ID, and attach results in memory.

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

Wrap the handler with a higher-order middleware function that extracts the Bearer token, verifies the JWT, and attaches the user to the request. Return 401 responses for missing or invalid tokens before the handler executes.

What caching pattern works with Redis and a database repository?

Use the cache-aside pattern: check Redis first, fetch from the database on a miss, then populate the cache with a TTL such as 300 seconds. A decorator repository class can wrap the base repository to add this behavior transparently.

Does the repository pattern work with Supabase?

Yes, define a repository interface and implement it with a Supabase client that builds filtered queries using eq, limit, and select. This abstracts data access so the service layer stays independent of the database client.

When should I use exponential backoff for API retries?

Use exponential backoff when calling external APIs that may fail transiently, retrying up to three times with delays of 1s, 2s, and 4s. Avoid retrying non-idempotent operations or permanent errors like 4xx validation failures.