Architecture · Local AI + governed backend

Private AI and RAG Backend Architecture for WordPress

Use supported on-device AI where it fits, then route workloads that need server-side models, RAG, citations or public frontend access to a configured backend rather than a mandatory shared plugin SaaS runtime.

WordPress editor / frontend
   ├→ supported local AI
   └→ configured API endpoint
          ↓
      API Gateway + Lambda
          ├→ Bedrock model access
          ├→ knowledge retrieval
          └→ logs / controls

WordPress remains the content source; backend ownership is explicit.

Trust and data path

Local processing and backend processing are distinct execution modes

AI-Kit can perform supported tasks locally in compatible browsers. Pro workflows can instead use a configured API endpoint, typically in the customer's AWS account. Public chatbot and DocSearch features need a browser-reachable backend path because the visitor cannot depend on WordPress PHP after static publishing.

Editor task
  ├→ local browser model when supported
  └→ /admin/* configured backend route

Visitor chatbot / DocSearch
  → /frontend/* configured backend route
       → retrieval / model execution
       → answer + source data

Knowledge sources
  WordPress content → prepared documents + metadata → knowledge backend

Boundary A configured backend does not make every AI action local or private by definition. The important architectural decision is where each workload executes, which content crosses that boundary, and who controls the backend, logs and model access.

What the AI-Kit backend stack provisions

The backend is a collection of explicit runtime responsibilities, not one opaque AI proxy. This inventory shows the API, model, retrieval, storage, abuse-control and observability components behind the configured path.

Building blockPurposeKey design choiceOperational note
API Gateway REST APIExposes admin and optional frontend AI routes/admin/* is always the trusted surface; /frontend/* appears only when feature toggles enable itKeep public and privileged routes separate even when they share handler code.
AiHandlerFunctionUnified Lambda handler for prompt and language capabilitiesOne warm execution path for prompt, write, rewrite, summarize, translate, proofread, detect-language and KB listingShared validation, metrics, guardrails and middleware reduce operational spread.
Amazon Bedrock modelsRuns generation, translation-style tasks and RAG answer synthesisFrontend model can be cheaper/lighter than admin model through parameterized model selectionModel IDs are architecture parameters, not hard-coded plugin assumptions.
Bedrock Knowledge Base + S3 VectorsProvides managed retrieval over documentation or client contentCreate a new KB or reuse an existing one via stack parametersKnowledgeBaseId and DataSourceId outputs are part of the integration contract.
Docs and temp assets S3 bucketStores KB documents and temporary prompt image uploadsSeparate document prefix, configuration prefix and temp-assets prefixTemp image objects should expire quickly; KB documents should be versioned deliberately.
KnowledgeBaseSyncFunctionRuns document ingestion workflowsS3/EventBridge/DynamoDB debounce loop avoids starting ingestion for every small file eventUseful when WordPress regenerates multiple KB documents during publishing.
reCAPTCHA + SSM/KMSProtects open frontend endpointsSecret stored as encrypted SSM parameter and fetched by handlersImportant when FrontendApiAuthMode is NONE for static-site friendliness.
AWS WAF and throttlingLimits abuse on public/admin API pathsSeparate allow/deny/rate rules for frontend and admin surfacesAI endpoints are cost-bearing; public access needs protection beyond CORS.
CloudWatch, DLQ and alertsProvides logs, metrics, failed invocation capture and optional notificationsPer-function log retention, custom metrics and shared SQS DLQAI features need observability because cost, latency and quality are all runtime concerns.

Endpoint surface: one backend, two trust zones

The backend can expose several capabilities, but admin and frontend routes must remain distinct. This table shows which visitor routes exist only when their feature is enabled and which configuration routes stay admin-only.

CapabilityAdmin routeFrontend routeWhen frontend is createdDesign note
Prompt / chatbot / DocSearch/admin/prompt/frontend/promptEnableChatbotBackend=trueCan use KB, citations, regeneration, feedback metadata and optional image inputs.
Generate upload URL/admin/generate-upload-url/frontend/generate-upload-urlEnableChatbotBackend=trueUploads images to S3 via presigned PUT, then passes keys to prompt requests.
Summarize/admin/summarize/frontend/summarizeEnableSummarizerBackend=trueSummarization usually disables KB by default because the source text is already supplied.
Writer/admin/write/frontend/writeEnableLanguageAIBackend=trueUseful as backend fallback for editor or frontend generation features.
Rewriter/admin/rewrite/frontend/rewriteEnableLanguageAIBackend=trueHonors tone, format and length controls while keeping secrets out of the browser.
Translator/admin/translate/frontend/translateEnableLanguageAIBackend=trueCan be paired with automatic language detection flows.
Proofreader/admin/proofread/frontend/proofreadEnableLanguageAIBackend=trueReturns corrected text and structured correction metadata.
Language detector/admin/detect-language/frontend/detect-languageEnableLanguageAIBackend=trueUses a backend language detection path instead of assuming the browser always provides it.
Knowledge bases/admin/knowledge-basesNot a public routeAdmin onlyListing and selecting backend knowledge resources belongs to trusted configuration UX.

Grounding policy is a product decision

Retrieval behavior should match the risk and user expectation of the experience. This table compares strict KB-only answers, clarification-first behavior and KB-preferred answers.

Grounding modeWhen to useBehavior when KB has no relevant snippetsEditorial implication
KB_ONLYRegulated, high-stakes or strict documentation answersState that the documentation does not contain the requested informationAuthors must keep the KB complete enough for expected questions.
ASK_WHEN_NO_KBAmbiguous source sets or category-dependent answersAsk one clarification question instead of guessingMetadata taxonomy becomes part of UX design.
KB_PREFERREDMarketing, product education and general supportUse KB when available; otherwise answer with clear separation from retrieved docsGood balance for public websites that mix documentation and general explanation.

Authentication and protection matrix

Admin routes, public chat, language tools, uploads and knowledge management have different trust levels. This matrix shows the default posture and the protection each surface needs.

SurfaceDefault posturePossible auth modesRecommended protectionWhy
Admin AI routesTrusted/adminIAM or CognitoIAM by default, optional IP allow list, logs and alertsThese routes can expose broader capabilities and should not be public.
Frontend chatbotPublic or member-facingNONE, IAM or CognitoreCAPTCHA + WAF for public; Cognito scopes for member-onlyChat endpoints are cost-bearing and can receive arbitrary user input.
Frontend summarizer/language toolsFeature-gated public surfaceNONE, IAM or CognitoOnly enable needed routes; throttle and validate payload sizeEach route adds an abuse surface and a model-cost surface.
Image upload helperTemporary asset ingressFollows prompt surfaceStrict content type, size, key prefix and lifecycle expiryPresigned uploads are powerful and should be bounded tightly.
Knowledge Base managementAdmin onlyIAM or privileged CognitoNever expose as anonymous frontend endpointKB selection and backend resources are configuration, not visitor UX.

Model selection and cost posture

Different AI workloads create different cost and quality pressures. This table keeps editor tasks, public chat, DocSearch and multimodal requests from being forced into one model and protection profile.

WorkloadCost pressureQuality requirementArchitecture choice
Editor rewrite / translate / proofreadUsually moderate and admin-controlledConsistent output and low frictionTry local AI first, use backend fallback when unavailable or when policy requires backend processing.
Frontend chatbotPotentially high because visitors can trigger usageGrounded, safe, understandable answersEnable only needed routes, use lighter frontend model, reCAPTCHA/WAF, and bounded response settings.
DocSearchDepends on search volume and retrieved contextGood citations and accurate source selectionRAG-first approach; optional rerank only where relevance improvement justifies extra calls.
Multimodal promptHigher because images add storage and processingUseful for selected support or content workflowsUse presigned S3 uploads, object size limits and lifecycle expiration.

How the deploy wizard changes the operating model

The wizard turns product-level choices into explicit backend configuration. This table shows how feature selection, authentication, template source and stack outputs affect both CloudFormation and WordPress.

Wizard decisionCloudFormation effectWordPress effect
Frontend featuresEnables only the backend routes required for chatbot, DocSearch, summarization or language tools.The plugin can expose only the surfaces the site actually wants to support.
Admin auth modeDefaults toward Cognito for admin operations and can enforce scopes.Admin/backend actions are not accidentally treated as public AI calls.
Template sourceUses an S3 template URL that CloudFormation can read.The user sees an AWS-native stack review flow instead of a hidden SaaS provisioning step.
OutputsProduces ApiBaseUrl and other stack outputs.WordPress stores the endpoint contract; it does not own the backend runtime.

Implementation path

Choose the execution path from the workload and governance requirement

Do not force every AI feature through one route simply because the plugin can expose several AI capabilities.

  1. Classify editor and visitor workloads — Separate editor-side rewriting, translation or metadata work from public chatbot, DocSearch and other visitor-triggered requests.
  2. Use local execution where it is actually supported — Keep compatible on-device tasks in the browser when that meets the capability and policy requirement; do not claim local execution for browsers or tasks that do not support it.
  3. Configure the backend trust zones — Keep privileged admin routes distinct from public frontend routes and add the appropriate authentication, WAF, throttling or abuse controls for each exposed surface.
  4. Govern retrieval and source use — Define which WordPress content enters the knowledge source, how it is split or excluded, and how source or citation data is returned so grounded answers can be reviewed.

When this architecture adds useful control

Good fit

AI workloads with different privacy and runtime needs

  • Some editor tasks can stay on-device while other features need a server-side model or retrieval backend.
  • You want the configured backend and its AWS resources in an account you control rather than requiring one shared vendor AI proxy.
  • Visitor-facing DocSearch or chatbot features need grounded answers and must keep working on a static frontend.

Keep it simpler

A simpler AI path may be enough when

  • The site only needs occasional editor-side tasks already covered by supported local browser AI.
  • A conventional SaaS AI integration meets the organization's data, governance and operational requirements.
  • There is no need for public AI, RAG, citations, backend observability or customer-controlled infrastructure.

Problem guides

Buyer problems this architecture explains

How do I use AI in WordPress without sending every draft through an AI SaaS?

Start with Use AI in WordPress Without Sending Every Draft Through an AI SaaS. It distinguishes supported local processing from the optional configured backend path and avoids claiming that every AI task stays local.

How do I give visitors grounded answers from WordPress content?

See Give Visitors Answers from Your WordPress Content — With Sources. The solution covers DocSearch and chatbot use; this architecture explains the knowledge-source, retrieval and backend boundaries behind grounded answers and sources.

Where does AI image metadata generation fit?

See Fix Missing WordPress Image Alt Text and Metadata at Scale. Media metadata generation is an editor workflow and can use the supported AI-Kit execution modes; human review remains important for accessibility-sensitive alt text.

Can frontend AI still work after static publishing?

Yes when the browser can reach the configured backend directly. See Make WordPress Static Without Losing Dynamic Features for the broader rule that static page delivery and dynamic browser services can remain separate.

Start from the AI data path

Choose where the AI workload should run before choosing the model

Use the Private AI guide for the data-path decision, then use the grounded-answer guide when the site also needs retrieval over WordPress content.