Overview
Traditional market research in Saudi Arabia takes weeks, requires high agency budgets, and struggles to balance regional and demographic representation. Generic AI tools fail here too—producing repetitive, Western-leaning, or overly formal Arabic answers that miss local cultural nuances.
Sawt solves this by pairing a bilingual drag-and-drop survey studio with a Saudi-calibrated multi-AI orchestration engine, enterprise SaaS billing, and real-time segmentation analytics—spanning 210+ TypeScript files, 42 pages, 132 REST API endpoints, and 23 PostgreSQL tables.
The Challenge
- Slow, costly human fieldwork across Saudi Arabia's diverse regions (Riyadh/Central, Jeddah/Western, Dammam/Eastern, Southern, and Northern).
- Lack of regional dialect authenticity (Najdi, Hijazi, Gulf, Southern, Northern) and socio-economic realism in standard LLM outputs.
- Need for native Arabic RTL UX, Saudi local payment rails (Mada via Moyasar in SAR), strict plan-tier gating, and production resilience during long-running AI workloads.
System Architecture & Key Capabilities
- Saudi-Calibrated Multi-AI Engine:Combines OpenAI GPT-5 and Perplexity AI with a statistical Saudi demographic model (5 regions, 6 age brackets, 5 SAR socio-economic tiers, and cultural markers) to synthesize non-repetitive, demographically aligned responses.
- Live Database-Driven Prompt Management:All AI system and user prompts live in PostgreSQL (
backend_prompts) with dynamic template variables and an admin UI (/admin/backend-prompts), allowing zero-downtime prompt tuning without redeploying code. - Bilingual (EN / AR) RTL Experience:Full
[dir="rtl"]layout mirroring, dual Light/Dark themes, persistent app shell across navigations, drag-and-drop question builder (@dnd-kit), live cost estimator, interactive Recharts visualizations, and a bilingualreact-joyrideonboarding tour. - Localized Saudi Billing (Moyasar):Migrated payments from Stripe to Moyasar to natively support Mada, Visa, Mastercard, and Amex in SAR. Implements hybrid subscription quotas plus pay-as-you-go tokens charged only on response generation—not draft creation.
- Plan-Tier Feature Gating & Developer Platform:Server-side
requireFeature()middleware gates Pro+ SHA-256 hashed API keys (sk_), Enterprise HMAC-SHA256 signed webhooks (survey.created,survey.completed,survey.failed), and demographic cross-tabulation analytics. - Full Admin & Operations Console:11 dedicated admin views covering users, packages, token tiers/rates, live AI prompts, surveys, templates, in-app NPS/evaluations, audit logs, and 25 Outlook-compatible bilingual Handlebars email templates (Resend + SMTP queue).
Production Engineering Challenges Solved
- Eliminating Server-Wide Route Freezing:Diagnosed and resolved intermittent dashboard lockups during long AI runs caused by Neon Serverless WebSocket pool hangs and uncleaned retry timers—fixed by configuring explicit pool timeouts (
connectionTimeoutMillis,idleTimeoutMillis) inside a lazy DB proxy and pairing every retry withAbortControllerand guaranteedclearTimeoutcleanup. - Hardening Payment Security:Executed multi-round security hardening on the Moyasar checkout flow—enforcing server-side payment ownership verification, removing client-controlled refund values, fixing exact CSRF callback path matching, and adding idempotency replay protection.
- Zero-Flicker Auth & Bot Protection:Optimized SPA boot so landing pages render immediately without blocking on auth, eliminated full cache wipes on login, and added first-in-chain bot-protection middleware blocking exploit probes and scanner user agents before session lookup.
Tech Stack
- Frontend:React 18, TypeScript, Vite, Wouter, TanStack Query, Tailwind CSS (
tailwindcss-rtl), shadcn/ui (Radix UI), Framer Motion, GSAP, Recharts,@dnd-kit, React Joyride - Backend:Node.js, Express (TypeScript ESM), Passport.js (Local, Google, Twitter, Apple OAuth), PostgreSQL (Neon Serverless), Drizzle ORM, Zod
- AI, Payments & Comms:OpenAI GPT-5, Perplexity AI, Moyasar (SAR / Mada), Resend API, Nodemailer SMTP, Handlebars