CASE STUDY 06
Production Live · 6 Branches

SAPT Loyalty & Dual-Intent AI Shopping Assistant

On-Premise Fine-Tuned LLM · pgvector RAG · React Native Expo

React NativeExpo SDK 51Cairo Font (RTL)Odoo 17PostgreSQL (pgvector)OllamaUnslothNgrokJWT
SAPT Loyalty & Dual-Intent AI Shopping Assistant
SYSTEM_MONITOR // SAPT-LOYALTY-AI
SCROLL
THE PROBLEM

Retailers need intelligent shopping assistants, but cloud LLM API fees destroy margins.

SAPT Central Markets required a loyalty mobile application to replace verbal phone-number lookups at checkout. In addition, customers on the shop floor needed a fast, bilingual (AR/EN) conversational shopping assistant to query product prices, stock, and loyalty information. Pushing all traffic to a commercial cloud LLM API created unsustainable ongoing costs and posed data privacy concerns, while direct transactional DB queries for fuzzy/semantic text searches overloaded the Odoo ERP database.

THE STANDARD APPROACH FAILS BECAUSE:

Commercial LLM APIs incur unsustainable token costs at scale
Direct DB queries for fuzzy/semantic search overload Odoo ERP
LLMs frequently hallucinate prices and stock, eroding customer trust
Standard RAG lacks real-time Odoo context injection
THE ENGINEERING CHALLENGE

Deliver sub-second, bilingual AI search and conversation without incurring cloud API costs, while guaranteeing 100% accurate pricing to prevent hallucination.

"Hosted an auto-tuned Qwen2.5-3B-Instruct model locally on Ollama, fine-tuned via Unsloth LoRA on a custom grocery dataset."

— KEY ARCHITECTURAL DECISION

TECHNICAL DECISIONS // 5 MADE

01

On-premise deployment of Qwen2.5-3B-Instruct via Ollama to eliminate token costs

02

Fine-tuned via Unsloth LoRA on a custom Saudi-grocery dataset

03

Dual-intent routing engine: Semantic RAG vs Navigation

04

Strict Tool-Wait streaming interruption protocol to prevent price hallucinations

05

Secure JWT authentication tunneled over Ngrok

SYSTEM ARCHITECTURE
PRODUCTION_EVIDENCE // VAULT_01
Buffer_Active
SSD_R_1.2GB/s
AI ASSISTANT
AI ASSISTANT

Sub-second bilingual (AR/EN) conversational search

LIVE_PROD
IMG_ID: 1042
WHAT WAS BUILT

Dual-Intent AI Engine

ON-PREMISE LLM
  • Product & Price Queries: Routes to high-performance pgvector cosine similarity search
  • Strict Tool-Wait Protocol: Interrupts stream generation to inject real Odoo data and prevent hallucination
  • General Info & Navigation: Identifies intents (points, vouchers) and returns deep-linked markdown
  • Vision Search: Local Llama 3.2 Vision (11B) extracts brand text from user photos

Mobile Application

REACT NATIVE + EXPO
  • Auto-Brightness Barcode: Maximizes screen illumination during loyalty barcode displays
  • Dynamic CMS Flyer: Weekly flyer viewer with multi-image caching and zoom
  • Branch-Aware Locators: Real-time open/closed indicators based on local branch time logic
  • Encrypted JWT tokens for authenticated JSON-RPC requests via Expo SecureStore