mcpField
D
django-recommender-search-backend-patterns

django-recommender-search-backend-patterns

github.com/pproencaDevelopment218124 installsUpdated 11w ago
Repository

About django-recommender-search-backend-patterns

A Django backend skill with 48 rules and Python templates for recommendation and OpenSearch search services. It helps developers build or review systems that coordinate ML and service calls, handle failures, and serve search or feed results.

Key features

  1. 0148 rules across eight backend categories
  2. 02Async downstream fan-out and protection patterns
  3. 03OpenSearch pagination and query guidance
  4. 04Recommendation blending and fallback strategies
  5. 05Caching, resilience, and API response patterns
  6. 06Five adaptable Python scaffolding templates

Use cases

  1. 01Reviewing Django recommendation endpoints
  2. 02Designing OpenSearch search and feed APIs
  3. 03Protecting downstream calls from overload or failure
  4. 04Implementing blended rankings and partial responses

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill django-recommender-search-backend-patterns

After installing, type/django-recommender-search-backend-patternsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
assets/templates/
_template.md
degraded_response.py.template
fanout_recommender_service.py.template
opensearch_search_view.py.template
redis_cache_with_stampede.py.template
result_blender.py.template
references/
_sections.md
api-compression-and-payload-shaping.md
api-cursor-pagination-in-drf.md
api-etag-and-cache-control-headers.md
api-serializer-perf-select-related.md
api-throttle-per-user-and-endpoint.md
async-cancel-on-client-disconnect.md
async-context-vars-for-request-scope.md
async-fire-and-forget-with-create-task.md
async-sync-to-async-orm.md
async-worker-model-uvicorn-vs-gunicorn.md
blend-anonymous-vs-personalized-paths.md
blend-cold-start-fallback.md
blend-dedup-across-sources.md
blend-mmr-for-diversity.md
blend-normalize-scores-across-sources.md
cache-negative-results.md
cache-redis-with-stampede-protection.md
cache-segment-keyed-isolation.md
cache-two-tier-process-and-redis.md
cache-version-on-model-deploy.md
orch-avoid-await-in-loop.md

Details

From the project README

Experimental Django Recommender + Search Backend Best Practices

Implementation patterns for a Django backend serving mixed-results recommendations (Personalize / Databricks / microservice fan-out) and OpenSearch-backed search/feeds. 48 rules across 8 categories, ordered by execution lifecycle impact — earlier categories cascade through everything downstream.

This is the backend peer of the react-fetch-cache-patterns skill. React handles client-side waterfalls and caching; this skill handles server-side fan-out, downstream protection, OpenSearch query design, and ML-blend orchestration.

When to Apply

  • Building or reviewing Django views that fan out to AWS Personalize, Databricks Model Serving, internal microservices, or any ML inference downstream
  • Designing OpenSearch query endpoints (search results, infinite feeds, faceted search)
  • Implementing a recommendations endpoint that blends multiple ranker outputs
  • Investigating "Django backend slow when downstream is degraded" or "Personalize quota exhausted"
  • Adding caching, retry, circuit breakers, or rate limiting to outbound calls
  • Choosing between sync and async Django views, configuring uvicorn vs gunicorn
  • Designing DRF response shapes for paginated feeds, partial results, or degraded paths

Rule Categories by Priority

#CategoryImpactPrefixRules
1Fan-out OrchestrationCRITICALorch-8
2External Service ProtectionCRITICALprotect-7
3OpenSearch Query PatternsCRITICALsearch-8
4Result Blending & PersonalizationHIGHblend-5
5Caching StrategyHIGHcache-5
6Resilience & Partial ResultsHIGHresilience-5
7Async & ConcurrencyMEDIUM-HIGHasync-5
8API Response DesignMEDIUMapi-5

Quick Reference

1. Fan-out Orchestration (CRITICAL)
2. External Service Protection (CRITICAL)
3. OpenSearch Query Patterns (CRITICAL)
4. Result Blending & Personalization (HIGH)
5. Caching Strategy (HIGH)
6. Resilience & Partial Results (HIGH)
7. Async & Concurrency (MEDIUM-HIGH)
8. API Response Design (MEDIUM)

How to Use

  1. Open references/_sections.md for category definitions and impact rationale
  2. Read individual rule files for incorrect-vs-correct code examples (each ~150-300 lines with Python code)
  3. For ready-to-use scaffolds, see scaffolding templates
  4. The AGENTS.md navigation document (auto-generated) provides a TOC for browsing

Scaffolding Templates

Five ready-to-adapt Python templates under assets/templates/:

TemplatePurpose
fanout_recommender_service.py.templateAsync fan-out client to Personalize/Databricks/microservice with per-downstream circuit breaker, bounded timeout, partial-result return
opensearch_search_view.py.templateDRF view + OpenSearch search_after cursor + function_score blending + _source filtering
result_blender.py.templateScore normalization + MMR diversity + canonical-ID dedup + cold-start fallback
redis_cache_with_stampede.py.templateStampede-safe cached function decorator with SETNX lock and jittered TTL
degraded_response.py.templatePartial-results envelope with per-source status flags + tier-based fallback

Reference Files

FileDescription
references/_sections.mdCategory definitions, ordering, impact rationale, tier definitions
assets/templates/_template.mdTemplate for authoring new rules
metadata.jsonVersion, references, abstract

Related Skills

  • react-fetch-cache-patterns — Client-side peer covering React data fetching/caching (Suspense, query libraries, prefetch)
  • io-bound-data-processing — Python async patterns for batch and pipeline workloads
  • inngest-nextjs-patterns — Workflow patterns for server-side step functions

Comments

Markdown supported