Backend & APIs
AuraScore 81/100

Low-Latency Generative Ad Copy Engine Architecture Specification

Architect a high-performance backend service that serves dynamic marketing copy with strict caching, fallbacks, and latency SLOs.

Use this template when building backend infrastructure that powers programmatic copywriting and real-time ad variation generation. It produces a detailed technical specification for request routing, multi-tiered prompt caching, token budgets, and provider failover.

Template

Role: Staff Backend Engineer specializing in High-Throughput Content Delivery and LLM Orchestration Infrastructure.

Context

  • Latency Budget (P99): {{p99_latency_budget}}
  • LLM Upstream Providers & Fallbacks: {{llm_provider_fallbacks}}
  • Tiered Cache TTL & Invalidation Policy: {{cache_ttl_policy}}
  • Dynamic Prompt Assembly Engine: {{prompt_assembly_rules}}
  • Content Safety & Brand Guardrails: {{content_safety_filters}}
  • Tenant Rate Limits: {{rate_limit_policy}}

Task

Draft an advanced backend engineering specification for an automated ad-copy generation API that satisfies strict enterprise latency budgets, implements semantic and exact-match caching, and guarantees graceful degradation under upstream LLM provider outages.

Method

  1. Translate {{p99_latency_budget}} into discrete latency allocations across network transit, auth, cache lookup, LLM inference, and validation.
  2. Design the dual-layer caching subsystem (L1 in-memory exact match, L2 vector-based semantic similarity) governed by {{cache_ttl_policy}}.
  3. Specify the runtime prompt construction pipeline that merges customer variables into {{prompt_assembly_rules}} without introducing injection vulnerabilities.
  4. Map out the upstream orchestration layer detailing connection pooling, active health checks, and fallback mechanisms across {{llm_provider_fallbacks}}.
  5. Design the streaming response middleware incorporating inline {{content_safety_filters}} before tokens reach the calling marketing frontend.
  6. Detail tenant throttling, token quota enforcement, and tier prioritization according to {{rate_limit_policy}}.
  7. Formulate a degradation matrix defining fallback behavior (e.g., pre-generated static templates) when upstream providers breach error budgets.

Constraints

  • MUST NOT allow unvalidated or unsanitized prompt interpolations to reach upstream model gateways.
  • MUST implement an automated circuit breaker that routes traffic to secondary providers within 200ms of primary failure.
  • P99 cache hits MUST be served in under 15ms.
  • Include exact OpenAPI 3.1 path definitions and error payload schemas.

Output format

    1. System Topology & Latency Budget Allocation (Table format, 200 words)
    1. Dual-Layer Caching & Eviction Specification (300 words)
    1. Dynamic Prompt Assembly & Guardrail Middleware Flow (250 words)
    1. Provider Failover, Circuit Breaking & Fallback Matrix (300 words)
    1. OpenAPI 3.1 Schema & Error Handling Contracts (YAML or JSON snippet)

Self-review

  • Is every stage of the request pipeline accounted for within the specified P99 latency budget?
  • Does the failover logic handle context window differences between primary and secondary LLM providers?
  • Are safety filter latencies decoupled or parallelized with stream generation where appropriate?
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering10/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-backend-apis
business-strategy-marketing-sales
llm-backend
copywriting-api
caching-strategy