Home / Insights / Architecture and Modernization
Architecture and Modernization
A Reference Architecture for AI-Enabled Products: Data, Models, APIs and Guardrails
Most AI features start as a prompt in a controller and grow into something nobody designed. This reference architecture sets out the layers an AI-enabled product needs, which decisions belong to each, and how to introduce them without over-engineering a first release.
TopicsArchitecture and ModernizationGenerative AI and LLMsAI Agents and Automation
Key takeaways
- Treat AI as a set of layers with clear contracts (data and retrieval, model gateway, orchestration, product APIs, guardrails, evaluation and operations) rather than as calls scattered through application code.
- A model gateway that owns provider access, routing, quotas, logging and cost attribution is the single most valuable early investment; it keeps model choice reversible.
- Guardrails belong in the request path and in the tool layer, not only in prompts: the OWASP Top 10 for LLM Applications 2025 puts prompt injection, sensitive data disclosure and excessive agency at the centre of the risk picture.
- Evaluation is part of the architecture. Versioned prompts, test sets and release gates turn model and prompt changes into deployable artefacts like any other code.
- Start with a thin version of every layer and thicken the ones your risks and volumes justify; a first release does not need a vector database, an agent framework and fine-tuning.
On this page
- Why AI features need an architecture of their own
- The seven layers of an AI-enabled product
- Data and retrieval: getting the right context safely
- Model gateway and orchestration: keeping models replaceable
- Guardrails: where controls sit in the request path
- Evaluation and operations: making AI changes deployable
- Implementation sequence, risks and checklist
- Frequently asked questions
- Sources and methodology
The first AI feature in a product is usually easy. A developer adds a call to a model API, writes a prompt and ships. By the fourth or fifth feature the picture changes: several prompts copied across services, API keys in different places, nobody sure what each feature costs, no way to test a model upgrade, and a security review asking what happens when a user pastes instructions into a support ticket that an AI later reads.
This article is for CTOs, architects and technical product leaders who want a shared picture of what an AI-enabled product looks like once it is designed rather than accreted. It proposes a layered reference architecture, explains the decisions each layer owns, compares the main options, and suggests how to sequence the work. It reflects the state of tooling and regulation as of February 2026.
This is the structure we use in software architecture consulting engagements when we design how models, retrieval and data pipelines fit into an existing system, and it draws on our delivery of AI features such as referral processing and dictation-to-report in a clinical operations platform for an Australian healthcare client.
Why AI features need an architecture of their own
AI components behave differently from the rest of your stack in four ways that matter architecturally.
- Non-deterministic output: the same input can produce different results, so correctness is measured statistically through evaluation, not asserted by unit tests alone.
- Instructions and data share a channel: anything the model reads, including retrieved documents and user content, can influence its behaviour. That is why prompt injection is the first entry (LLM01) in the OWASP Top 10 for LLM Applications 2025.
- Usage-based, volatile cost: spend scales with tokens and calls, and a prompt change can alter cost as much as a traffic spike. OWASP lists unbounded consumption (LLM10) as a risk in its own right.
- Fast-moving dependencies: model versions, providers and pricing change on a timescale of months, so the architecture must keep model choice reversible.
Frameworks such as the NIST AI Risk Management Framework (released January 2023, with a Generative AI Profile, NIST AI 600-1, in July 2024) describe the governance side of this. The architecture is where those intentions become controls: logging that supports accountability, evaluation that supports measurement, and guardrails that support risk management.
Action: list every place your product currently calls a model, who owns each, and how it is tested. That inventory is the baseline for the target architecture.
The seven layers of an AI-enabled product
The reference architecture has seven layers. Each has a clear responsibility and contract with its neighbours. Not every product needs every layer at full strength, but every product should know who owns each one.
| Layer | Responsibility | Typical components | Thin first version |
|---|---|---|---|
| 1. Data and knowledge | Sources of truth, permissions, data quality | Operational databases, document stores, data warehouse | Existing databases with documented access rules |
| 2. Retrieval | Finding the right context for a request, respecting permissions | Search index, vector store, hybrid ranking, chunking pipeline | Keyword or database search filtered by user permissions |
| 3. Model gateway | Provider access, routing, quotas, logging, cost attribution | Internal gateway service or managed gateway | A single internal client library with central configuration |
| 4. Orchestration | Prompts, workflows, tool calls, agent loops | Workflow code, agent framework, tool registry | Plain code with versioned prompt templates |
| 5. Product APIs and UX | Exposing AI capability to users and other systems | REST or GraphQL endpoints, streaming, review screens | One endpoint per feature with human review where needed |
| 6. Guardrails | Input and output checks, policy, tool permissions | Classifiers, validators, allow-lists, approval steps | Schema validation, PII redaction, tool allow-lists |
| 7. Evaluation and operations | Quality, safety, cost and reliability over time | Test sets, tracing, dashboards, release gates | A test set per feature and request logging with cost |
The AWS Well-Architected Generative AI Lens, published in November 2025, offers a complementary view organised by pillar (operational excellence, security, reliability, performance, cost and sustainability) and by lifecycle phase from scoping through continuous improvement. The layers above map onto it well; we find layers easier for assigning ownership.
Action: assign an owning team to each layer, even if one team owns several. Unowned layers are where incidents start.
Data and retrieval: getting the right context safely
Most quality problems in AI features trace back to context: the model was given the wrong documents, stale data or too much text. Most data leaks trace back to the same place: the model was given documents the user should not see.
Design principles
- Permissions travel with the query: retrieval must filter by the requesting user’s rights at query time. Never rely on the prompt to tell the model what not to reveal; OWASP’s sensitive information disclosure entry (LLM02) is largely about this failure.
- Keep a source of truth: indexes and embeddings are derived data. Rebuild them from the system of record, and record which version of a document produced which chunk.
- Prefer hybrid retrieval: combining keyword and semantic search usually beats either alone for business documents full of codes, names and numbers.
- Protect the vector store: OWASP added vector and embedding weaknesses (LLM08) in its 2025 list, covering issues such as cross-tenant leakage and poisoned content. Treat the store as sensitive data with the same access controls as the source.
When you need a vector database
Not on day one for many products. If your corpus is small or highly structured, database queries and a search index can serve a first release. Add semantic retrieval when you have evidence, from evaluation, that keyword retrieval is missing relevant context.
Action: for each AI feature, document which data it can read, how permissions are enforced, and how stale the index may be. Our guide on choosing an embedding model for enterprise search goes deeper on the retrieval choices.
Model gateway and orchestration: keeping models replaceable
The model gateway
A model gateway is a single internal entry point for all model calls. It is the layer we recommend building first, because it makes almost every other control cheaper.
- Provider abstraction: features request a capability or model alias; the gateway maps it to a provider and version, so switching models is configuration, not a code change across services.
- Quotas and budgets: per feature, tenant and user, protecting against runaway consumption.
- Logging and tracing: request, response metadata, latency, tokens and cost, with personal data handled according to your retention policy.
- Routing and fallback: cheaper models for simple tasks, fallbacks when a provider is unavailable.
- Central secrets: API keys held in one place, not in each service.
Orchestration options
| Approach | Best for | Trade-offs |
|---|---|---|
| Single prompt per feature | Summaries, classification, extraction | Simple and testable; limited for multi-step tasks |
| Fixed workflow (chain of steps in code) | Document processing, report drafting | Predictable and debuggable; less flexible |
| Agent with tools | Open-ended tasks across several systems | Flexible; harder to test, higher cost, larger attack surface |
| Multi-agent | Complex research or operations workflows | Highest flexibility and highest operational complexity |
Choose the least autonomous approach that meets the requirement. In our clinical document work, fixed workflows with human review have been more appropriate than open-ended agents, because each step needs to be auditable.
Tools and protocols
Where models call tools, standardising the interface helps. The Model Context Protocol specification defines servers that expose resources, prompts and tools to AI applications, and states key principles: users must consent to data access and operations, tool descriptions should be treated as untrusted unless obtained from a trusted server, and hosts must obtain explicit consent before invoking tools. Whether or not you adopt MCP, those principles belong in your tool layer. Record choices such as orchestration style and tool permissions as architecture decision records so they stay reviewable.
Action: route every model call through one gateway, even a thin library, before adding the next AI feature.
Guardrails: where controls sit in the request path
Guardrails are often described as a filter on the model’s output. In a well-designed product they are a set of controls at several points, most of them deterministic.
- Before the model: authentication, rate limits, input size limits, PII redaction where the model does not need it, and classification of clearly out-of-scope or abusive requests.
- Around context: permission-filtered retrieval, marking untrusted content (user uploads, emails, web pages) so downstream logic can treat it differently.
- In the tool layer: allow-lists of tools per feature, least-privilege credentials, read-only by default, and human approval for actions that change money, records or external communications. This directly addresses excessive agency (LLM06).
- After the model: schema validation of structured output, checks for leaked system prompts or secrets, policy classifiers for harmful content, and safe rendering (no raw HTML or executable output), addressing improper output handling (LLM05).
- In the user experience: showing sources, marking AI-generated content, and making review and correction easy.
Regulatory context
For products sold into the EU, the AI Act’s obligations for general-purpose AI models have applied since 2 August 2025, and its general application, including transparency rules, is scheduled from 2 August 2026, according to the European Commission. In November 2025 the Commission proposed a digital omnibus that would push back some high-risk deadlines; at the time of writing that proposal had not been adopted. Logging, transparency to users and human oversight are easier to provide if the architecture already has them.
Action: for each AI feature, write the guardrail table: what is checked before, during and after the model call, and which checks are deterministic. Our article on guardrails for generative AI covers policy design in detail.
Evaluation and operations: making AI changes deployable
The difference between a prototype and a product is whether you can change prompts, models and retrieval with confidence. That requires treating them as versioned artefacts with release gates.
What to version
- Prompt templates and system instructions.
- Model alias to provider and version mapping.
- Retrieval configuration: chunking, ranking, filters.
- Tool definitions and permissions.
- Evaluation sets and scoring rubrics.
Evaluation in the pipeline
- Maintain a test set per feature drawn from real, anonymised cases, including edge cases and known attacks.
- Score automatically where possible (exact match, schema validity, retrieval hit rate) and with human or model-assisted review where judgement is needed.
- Gate releases: a prompt or model change ships only if it meets agreed thresholds on quality, safety and cost per request.
- Monitor in production: sample outputs for review, track user corrections, and alert on cost or latency anomalies.
Operational metrics
Track cost per successful task rather than cost per call, plus latency, error and fallback rates, guardrail trigger rates and human override rates.
Action: before the next model upgrade, build the test set and run old and new models against it. If you cannot, the evaluation layer is your next priority.
Implementation sequence, risks and checklist
A practical sequence
- Inventory and gateway: list current AI usage, introduce the gateway, centralise keys and logging.
- Evaluation baseline: a test set and scoring for each existing feature.
- Guardrails in the path: schema validation, redaction, tool allow-lists, approval for side-effecting actions.
- Retrieval hardening: permission filtering, index rebuild from source, freshness monitoring.
- Scale out: new features reuse the layers; add agents, semantic search or fine-tuning only where evaluation shows the need.
Common risks
- Over-engineering: adopting an agent framework, vector database and multi-model routing before the first feature has users.
- Under-engineering: no gateway or evaluation, so every change is a gamble.
- Vendor lock-in: provider-specific features spread through application code.
- Hidden data flows: logs containing personal data shipped to third-party observability tools without review.
- Ownership gaps: nobody responsible for evaluation sets, so they decay.
Architecture review checklist
- Every model call goes through a gateway with logging, quotas and cost attribution.
- Model choice is configuration; at least one alternative model has been tested.
- Retrieval enforces user permissions at query time.
- Untrusted content is identified and cannot directly trigger tools.
- Tools follow least privilege; side-effecting actions require approval.
- Structured outputs are schema-validated; rendered output is sanitised.
- Prompts, retrieval settings and tool definitions are versioned.
- Each feature has a test set and release gate.
- Production monitoring covers quality samples, cost, latency and guardrail triggers.
- Data retention and residency for prompts and logs are documented.
- Each layer has a named owner.
Action: score your current product against this checklist. The first three unchecked items are usually your next quarter’s architecture backlog.
Frequently asked questions
Do we need a vector database to build AI features?
No. Many first releases work with database queries and a keyword search index filtered by permissions. Add semantic retrieval when evaluation shows keyword retrieval is missing relevant context.
Should we build our own model gateway or buy one?
Either can work. The important thing is that one component owns provider access, quotas, logging and cost attribution. A thin internal library is enough to start; managed gateways become attractive as features and teams multiply.
When is an AI agent the right choice over a fixed workflow?
When the task genuinely requires choosing between tools or steps based on intermediate results. For predictable processes such as document extraction or report drafting, fixed workflows are cheaper, easier to test and easier to audit.
Are prompt instructions enough to stop data leaks?
No. Prompt instructions can be overridden by injected content. Enforce permissions in retrieval and tools, redact data the model does not need, and validate outputs outside the model.
How does the EU AI Act affect our architecture?
Depending on your use case, you may need transparency to users, logging and human oversight. Building these into the architecture now is easier than retrofitting them. Take legal advice on how your specific features are classified.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- OWASP: Top 10 for LLM Applications 2025 — accessed 9 November 2026. Risk categories including prompt injection, sensitive information disclosure, improper output handling, excessive agency, vector and embedding weaknesses and unbounded consumption.
- NIST: AI Risk Management Framework — accessed 9 November 2026. AI RMF release in January 2023 and Generative AI Profile (NIST AI 600-1) in July 2024.
- AWS: Well-Architected Generative AI Lens (November 2025) — accessed 9 November 2026. Pillar-based best practices and generative AI lifecycle phases.
- Model Context Protocol: Specification (2025-06-18) — accessed 9 November 2026. Host, client and server roles; resources, prompts and tools; consent and tool safety principles.
- European Commission: AI Act regulatory framework — accessed 9 November 2026. Application dates for GPAI obligations and general application, and the November 2025 digital omnibus proposal.
Related reading
Continue your research
Would your AI features pass an architecture review today?
We can review how models, retrieval, guardrails and evaluation fit into your product and give you a prioritised roadmap for the layers that matter most.
