All resources

How to add AI to an existing backend without rewriting the product

A staged architecture for an AI layer over a working system: data adapter, permissions, RAG, assist mode, quality evaluation and rollout.

AI should not become the source of truth

The existing system already owns users, documents, statuses and business rules. An AI service connects through a constrained adapter and returns a suggestion, classification or retrieved context.

This preserves rollback and audit and avoids asking a model to make decisions it cannot guarantee. Critical changes stay inside the existing approval flow.

Start in assist mode

Show a draft answer, retrieved passages or a suggested category to an operator instead of automating the final action. Confirmation creates examples of errors and time saved.

This establishes a baseline: how long the operation took before AI, how long it takes now and where a person is still required.

Permissions and data come before the model

Filter documents, personal data and roles in the adapter before the model call. A prompt is not a reliable access-control boundary.

Version prompts, indexes and data transforms. When output changes, the team should know which input or component changed.

Expand automation by measured thresholds

Track precision, confirmation rate, safe refusals, latency and cost. A draft email and a payment decision need different automation thresholds.

After the pilot, add queues, limits and a fallback to the ordinary workflow. AI becomes a product capability when failure is predictable and controlled.

Choose an operation with a clear error cost

A good first scenario has a baseline and reversible output: ticket classification, internal document search, a draft response or field extraction.

Do not start with an action that changes money, access or a legal obligation. It needs approval and stricter evaluation first.

Prepare data in a separate layer

Raw spreadsheets and documents are rarely model-ready. Add normalisation, deduplication, update rules and a link to the source object while keeping the original verifiable.

The adapter contract should be more stable than a model provider. Switching models then does not require a backend rewrite.

Give the pilot stop conditions

Define minimum precision, maximum cost and acceptable latency. If AI misses the threshold, return the operation to the ordinary workflow.

A fallback lets the experiment evolve without putting the business process at risk.

Scale trust with automation

Start with a suggestion, then automate only a narrow class of high-confidence cases. Keep the rest with a human and record rejection reasons.

A staged rollout creates decision history that improves prompts, retrieval and models without promising to replace staff overnight.

Put AI behind a boundary you can switch off

Start with a service or worker that receives limited context and returns a structured result. The core backend should keep working when the model is unavailable or a budget is exceeded.

This lets the team compare AI with the manual path and remove the experiment without migrating the domain model.

Evaluate quality on working examples

Build an anonymized set of requests, expected actions and unacceptable answers. Measure completeness, latency, cost and human handoff—not only the impression of a demo.

Log prompt, model and source versions as part of the experiment so an improvement can be reproduced or rolled back.

Start with a safe assist mode

Let AI suggest a classification, draft or source fragments while a person confirms any data change. Capture usefulness and corrections as product signals.

This validates value in real work without presenting an experiment as autonomy. Automatic actions follow measured error rates and a clear rollback.

Apply permissions before generation

Retrieval must not collect every document and rely on the model to hide the rest. Filter by organization, role and validity in the index or retrieval layer.

Test a user without access, conflicting roles and revoked permission. This is product security, not prompt tuning.

Count the full query cost

Budget embeddings, indexing, reranking, tokens, storage and retries. A longer context can raise cost without improving the answer, so set a measurable limit.

Cache stable results carefully: a permission or source-version change must invalidate an old answer immediately.

Instrument the path for improvement

Store an anonymized question, retrieved fragments, latency, model version and user decision. Keep secrets and unnecessary text out of shared logs.

A weekly error review should lead to a concrete change: document chunking, access rule, prompt or human handoff.

Start with a narrow AI contract

Instead of a universal agent define one operation and a strict response schema: classification, field extraction or a next-step suggestion. A narrow contract is easier to test, log and replace with another model. Expand after accuracy is proven, not because prompts multiplied.

Check privacy before sending data

Define which fields may reach an external provider, where masking happens and when temporary copies are deleted. For internal documents set storage region and index lifetime. This removes security blockers before a pilot becomes critical.

Keep the human route visible

When confidence is low, hand work to a person with retrieved sources and a reason for uncertainty. Do not hide this transition: it provides a quality signal and shows which rules are worth automating next.