Skip to content
Engineering blueprint

Adding AI search and summaries to an existing SaaS product

AI that answers from the customer's own records, respects their permissions and can be tested before it ships.

A B2B SaaS product where customers store large volumes of documents, tickets or records and struggle to find what they need.

Overview

How does CodeWorx approach adding AI search and summaries to an existing SaaS product?

AI that answers from the customer's own records, respects their permissions and can be tested before it ships. The product calls an AI service that retrieves only what the user may see, sends it to the model with a controlled prompt and returns an answer with sources.

  • Users find information in their own records faster
  • Answers can be traced to the records they came from
  • Changes are tested against known questions before they ship
  • Cost per request is visible from day one

The starting point

Customers ask for AI features. The product team knows search and summaries would help, but not how to ship them safely.

Records belong to tenants and users with different permissions. An AI feature that ignores those permissions is a data leak.

Nobody can say in advance what a good answer looks like, so there is no way to know whether a change made it better or worse.

What gets in the way
  • Model output varies, so normal tests are not enough on their own.
  • Costs grow with usage and are hard to predict.
  • Customers in regulated sectors will ask where their data goes.
The approach

5 stages, each useful on its own.

  1. 01

    Pick one job for AI

    Start with a single, well-defined task, such as answering questions from a customer's own documents, rather than a general assistant.

  2. 02

    Retrieve within permissions

    Index content per tenant and filter every retrieval by the user's existing permissions before anything reaches the model.

  3. 03

    Build an evaluation set first

    Collect real questions with known good answers. Every prompt or model change is measured against them before release.

  4. 04

    Show sources, allow review

    Answers cite the records they came from. Where the output drives an action, a person confirms it first.

  5. 05

    Measure cost and quality in production

    Track cost per request, latency and user feedback, so the feature can be tuned rather than guessed at.

Illustration of AI search in a SaaS product: a question answered with a cited summary drawn from the customer's own documents
The architecture

The product calls an AI service that retrieves only what the user may see, sends it to the model with a controlled prompt and returns an answer with sources.

  • Per-tenant index with permission filtering at retrieval
  • Model access through one service, so providers can change
  • Evaluation set run on every change
  • Logging of prompts, sources, cost and feedback
Decision record

The calls that shape the outcome.

ADR 01

Why retrieval instead of fine-tuning?

Customer content changes daily and must respect permissions. Retrieval keeps the model current and the access rules intact.

ADR 02

Why one provider abstraction?

Models, prices and terms change quickly. The product should not be rebuilt each time.

ADR 03

What would change the plan

If customers cannot allow data to leave their region, model hosting and provider choice come first.

What this improves

Typical technology

Chosen for the problem, not fixed in advance.
  • TypeScript
  • Python
  • PostgreSQL
  • RAG
  • Vector retrieval
  • OpenAI
  • Anthropic

Facing a problem like this?

Tell us where your system is today. We will tell you which parts of this blueprint apply.

Your privacy choices

We use necessary storage to run this site. With your permission, we also use Google Analytics and Google Ads measurement to see how the site is used and which campaigns lead to enquiries. Nothing else runs until you choose. Privacy Policy Cookie Policy

Cookie preferences

Choose what this site may use. You can change this at any time from Cookie settings in the footer.

Necessary

Always active

Keeps the site working and secure, and stores the choice you make here (one first-party cookie). It cannot be switched off.

Analytics

Google Analytics measures visits and how pages are used, so we can improve the site. It sets Google cookies only when allowed.

Advertising

Google Ads measurement shows which ads lead to enquiries. Google may use the email or phone number you enter in a form, in hashed form, for this. It runs through the same Google tag as Analytics, so it can only be switched on together with Analytics.