Build Guide 003 cover: a staff or customer request and a ranked parts list whose third row is excluded by rule, with the AI SDK, OpenRouter, Zod and PostgreSQL reference stack
Build Guide · 003

Build an Agentic Search Engine for Any Store

An implementation-grade Build Guide for multilingual parts and product search across a catalogue and its branches that interprets natural language, calls grounded catalogue tools, applies deterministic business rules, asks useful follow-ups and returns auditable ranked products.

Difficulty
Advanced
Reference build
5–10 days
Architecture type
Tool-using grounded search
Updated
November 2026
Language
English

Production scope and quote come from an AI Solution Blueprint.

On this page

Need it on your systems? Start an AI Solution Blueprint

Before you start

What you’ll build and why

The problem

A business with a structured catalogue and several branches gets product requests in every form: an exact SKU, a product name, a list of attributes, a synonym or a typo, in Arabic or in English, from staff or from customers. Search that only matches words misses many of these, and it cannot tell whether a product fits or which branch has it in stock. Handing the whole decision to a language model does not fix it either. On its own, a model can name a product that is not in the catalogue, ignore a compatibility rule or follow an instruction hidden in product text. Price, stock, compatibility and policy are business rules, and they should not depend on a model’s guess.

What you’ll build

This Build Guide walks you through a reference agentic search engine that reads a natural-language request in either language and turns it into a validated contract. The model chooses from a small allowlist of approved tools for the catalogue, inventory and compatibility. Application code then validates, filters and ranks the results, with stock per branch, and owns eligibility, price, policy and the final score. When a detail is missing or the fit is uncertain, the engine asks one focused question instead of showing false confidence, and a correction starts a new turn that reruns the same deterministic gates. Every product it shows carries an ID that came from a tool result, together with the rules that were applied, so each answer can be traced and audited. If the model provider or the schema check fails, search falls back to deterministic word and attribute matching, and the interface says so.

Who it’s for

The guide is for developers and technical leads at any business with a structured catalogue, a stable ID for every product, stock per branch and written inventory, compatibility and ranking policies. Those are the reference’s assumptions, and every record and name in it is fictional. The named stack is AI SDK for the tool loop, OpenRouter as a server-side model gateway, Zod at every boundary, Postgres for catalogue and search state, and a Web Hoster / Cloud Infrastructure for the application runtime. All of them are educational choices you can replace. The reference deliberately leaves out checkout, payment and order creation, live VIN, identity or customer-profile lookups, any mechanical, medical or safety diagnosis, and Ting’s prompts, private integrations and production scoring.

01 · Reference boundary

A reusable search pattern, not a one-branch build

This reference covers the critical path for any business with a structured catalogue and several branches: understand an English or Arabic request from staff or a customer, preserve safe session context, call approved tools, apply deterministic catalogue, stock and branch rules, ask for missing details, and return traceable ranked products. The records are fictional and the architecture is a reference implementation.

Included

  • Natural-language product, SKU and attribute search
  • English and Arabic request handling
  • Grounded catalogue, inventory and compatibility tools
  • Deterministic filtering, ranking and clarification

Not included

  • Checkout, payment or order creation
  • A live VIN, identity or customer-profile service
  • A mechanical, medical or safety diagnosis
  • Ting prompts, private integrations or production scoring
02 · Control flow

Interpret, retrieve, validate and rank

The language model converts a staff or customer request into a validated contract and chooses from a small allowlist of tools. Catalogue results are then validated, filtered and ranked by application code, with stock per branch. Every customer-visible product ID must originate in a tool result.

Reference map · 003Agentic search, end to end
Request

“Front brake pads for a 2021 sedan, 2.5 engine, in Jeddah today.”

Arabic or English
Search orchestrator
  1. 1Read language, intent and entities
  2. 2Ask one focused follow-up if context is missing
  3. 3Call approved catalogue, fitment and stock tools

Enough context? If not, ask, then interpret again

Rules & ranking in code
  • Eligibility and compatibility
  • Deterministic ranking
Grounded results
  • Approved part IDs only
  • Stock per branch
  • A traceable next action

Price, stock, fitment, policy, scoring and privacy stay outside the model.

Reference map. The state diagram below defines the executable behaviour, including fallback.
Search state transitions
WaitingIDLEReads the requestINTERPRETINGAsks one questionNEEDS_CLARIFICATIONCatalogue lookupRETRIEVINGFitment rulesVALIDATINGRankingRANKINGAnswerRESPONDINGCompleteCOMPLETESafe fallbackFALLBACKFailedFAILEDmissing detailcorrectionvalidcontractuncertain fitgroundedcandidatesprovider orschema failuretimeoutdeterministic resultno saferesult
Source
stateDiagram-v2
    [*] --> IDLE
    IDLE --> INTERPRETING
    INTERPRETING --> NEEDS_CLARIFICATION: missing detail
    NEEDS_CLARIFICATION --> INTERPRETING: correction
    INTERPRETING --> RETRIEVING: valid contract
    RETRIEVING --> VALIDATING
    VALIDATING --> RANKING: grounded candidates
    VALIDATING --> NEEDS_CLARIFICATION: uncertain fit
    RANKING --> RESPONDING
    RESPONDING --> COMPLETE
    INTERPRETING --> FALLBACK: provider or schema failure
    RETRIEVING --> FALLBACK: timeout
    FALLBACK --> COMPLETE: deterministic result
    FALLBACK --> FAILED: no safe result
03 · Educational choices

Named reference stack

The reference uses AI SDK for the tool loop, OpenRouter as a server-side model gateway, Zod for every boundary, Postgres for catalogue/search state, and a Web Hoster / Cloud Infrastructure for the application runtime. These are educational choices, not claims about Ting’s production stack.

OpenRouter

A server-side model gateway with an approved model and explicit timeout, cost and fallback policy.

Official documentation

Postgres

Catalogue mirror, search sessions, policy versions, evaluation cases and audit events.

Official documentation

Web Hoster / Cloud Infrastructure

Application runtime, same-origin API, secret injection, health checks and rollback.

Official documentation
In the full Build Guide

Setup, code, tests and deployment are in the PDF

This page shows the scope, the architecture and the reference stack with its official documentation. The implementation sections listed below are in the full Build Guide PDF: enter your name and mobile number once and it downloads. This device then stays unlocked for every free Ting resource.

  1. 04 · Project and setupIn the PDF
  2. 05 · Data contractsIn the PDF
  3. 06 · Tools and retrievalIn the PDF
  4. 07 · Rules and rankingIn the PDF
  5. 08 · Response contractIn the PDF
  6. 09 · API and fallbackIn the PDF
  7. 10 · Evaluation and testsIn the PDF
  8. 11 · Deployment and observabilityIn the PDF
  9. 12 · Safety checklistIn the PDF
FAQ

Questions about this Build Guide

What does this Build Guide cover?
A reference agentic search engine for a structured catalogue across branches: natural-language product, SKU and attribute search, English and Arabic request handling, grounded catalogue, inventory and compatibility tools, and deterministic filtering, ranking and clarification, with a transparent fallback when the model is unavailable.
Who is it for, and what do I need before starting?
Developers and technical leads at a business with a structured catalogue and several branches. The reference assumes a stable product ID, stock per branch and written inventory, compatibility and ranking policies, plus a server-side OpenRouter key and a Postgres database.
Which tools does the reference use?
AI SDK for the tool loop, OpenRouter as a server-side model gateway, Zod to validate every request, interpretation, tool input and response, Postgres for the catalogue mirror and search state, and a Web Hoster / Cloud Infrastructure for the runtime. They are educational choices, not claims about Ting’s production stack.
Where are the code, setup and tests?
In the full Build Guide PDF. This page shows the scope, the architecture and state flow, and the reference stack. The project setup, data contracts, tools and retrieval, ranking rules, response contract, API and fallback, evaluation and tests, deployment and safety checklist are in the PDF: enter your name and mobile number once and it downloads.
Is this Ting’s production system?
No. It is an educational reference architecture inspired by the capabilities demonstrated on the Ting website. It is not Ting’s production architecture, internal prompt system, or proprietary implementation. For your catalogue, languages, business rules and integrations, Ting specifies the production version in an AI Solution Blueprint, with a defined quote to build it.