Case Study: 07Completed

Karla: Voice-First Inventory Intelligence

Node.jsAI AgentsNatural Language to SQLWeb Speech APISQLite

Project Overview

Karla is a voice-first inventory management utility designed for rapid, hands-free data retrieval. The project explores the intersection of the Web Speech API and Large Language Models (LLMs) to create a natural language bridge between a user and a complex e-commerce inventory database.


01 // The Core Architecture: Natural Language to SQL

The primary technical challenge was translating human speech into safe, executable SQLite queries.

Technical Implementation:

  • Decoupled Intelligence: Orchestrated a backend engine that consumes transcribed text and maps it against a dynamic schema.
  • System Prompt Orchestration: Built a system that injects aliases.json (user shorthand) and attributes.json (valid data keys) into the LLM context at runtime, allowing for zero-shot query generation.
  • SQL Safety Layer: Implemented a validation engine that uses regex and semantic analysis to ensure the AI-generated output is restricted to SELECT operations, preventing command injection.

02 // Voice-First UX & The Web Speech API

Designed as a PWA, Karla prioritizes "eyes-off" interaction.

  • Bidirectional Audio: Utilizes the Web Speech API for both Speech-to-Text (STT) ingestion and Text-to-Speech (TTS) response synthesis.
  • Conversational Logic: Instead of returning raw JSON tables, the system passes the database results back to the LLM to generate a human-readable sentence (e.g., "You have four 2XL Navy Blue shirts left in stock.").
  • PWA Reliability: Optimized for mobile deployment on a localized VPS, ensuring low-latency responses during active warehouse management.

03 // Real-Time Data Synchronization

To maintain accuracy, Karla implements an automated sync pipeline.

  • eBay API Integration: A dedicated Node.js service polls the eBay Trading API to fetch the latest stock levels.
  • DML Normalization: Raw API responses are normalized into a structured SQLite schema, with product variations stored as searchable JSONB objects.
  • Differential Updates: The system performs idempotent upserts to minimize database I/O and ensure the voice interface always reflects the live marketplace state.

04 // Result: A Technical Proof-of-Concept

The project successfully demonstrated that LLMs can serve as high-fidelity "Translators" for structured data systems.

  • Fidelity: Achieved >95% accuracy on complex multi-attribute queries (e.g., "How many long-sleeve petrol blue shirts do I have in XL?").
  • Efficiency: Reduced the time to check specific stock levels from ~30 seconds (manual search) to < 5 seconds (voice query).
  • Extensibility: The JSON-mapped architecture allows for new product aliases or attributes to be added without modifying the core translation logic.

[Technical Metadata]

  • Runtime: Node.js 20+ (Express)
  • Database: SQLite3 with JSON1 extension
  • AI Stack: Google Gemini (via @google/generative-ai)
  • Frontend: Vanilla JS PWA / Tailwind CSS