AI & Search EngineeringProduction Case Study

Natural Language Search for Market Intelligence

A production-grade semantic search system that enables non-technical stakeholders to query complex financial data using natural language queries instead of rigid database filters. Built with OpenAI embeddings, vector similarity, and hybrid search algorithms.

Role

Full-Stack & AI Engineer

Timeline

3 Weeks Execution

Status

Live in Production

Platform

African Intelligence Dash

OpenAI EmbeddingspgvectorPostgreSQLSupabase RPCCosine SimilarityNext.js 14React Query
Natural Language Search Interface
Standard · AI · Web Modes
Natural Language Search Interface

Product Interface: Clean, executive-focused search bar with instant AI semantic mode toggling, real-time result cards, and transparent relevance indicators.

10,000+

Searchable Entities

Companies, investors, funds, & transaction records

1,536

Vector Dimensions

High-density OpenAI semantic embedding vectors

<200ms

Search Latency

Sub-200ms instant query execution speed

95%+

Query Precision

Accurate plain-English intent matching

The Problem

Unlocking Complex Databases for Business Users

Finding investors in "agritech sector with investments in the last 5 years" previously required navigating multiple dropdown menus, selecting date ranges, and manually applying industry filters. It was mechanical, slow, and frustrating for executive decision-makers.

The core challenge was communication: while the underlying database required rigid SQL queries, business users naturally think in conversational plain English. They needed to simply type "show me climate-focused fintech startups in Nigeria" and receive instant, relevant results without building a structured query manually.

Traditional Manual Dropdown Filtering
  • Requires clicking through 5+ dropdown menus
  • Fails to match synonyms or related industry terms
  • High friction resulting in search abandonment
Natural Language AI Search
  • Instant execution from a single plain-English prompt
  • Understands semantic intent across 1,536 dimensions
  • Displays transparent relevance scores for trust
The Solution Strategy

Semantic Vector Matching & Hybrid Search Architecture

I engineered a semantic search layer directly integrated with PostgreSQL using OpenAI vector embeddings. Every entity in the database (companies, investors, funds, transactions) is converted into a 1,536-dimensional vector representing its semantic meaning.

When a user enters a query, it is converted into vector format in real-time. A PostgreSQL function calculates vector cosine similarity using pgvector to locate closely matching entities. To ensure precision, the system combines AI vector matching with exact keyword search in a hybrid balance: 70% semantic similarity + 30% keyword match.

Automated Vector Pipeline

Converts 10,000+ entities into OpenAI embeddings stored in a dedicated vector table with metadata for rapid retrieval.

Hybrid Search Algorithm

Balances AI semantic similarity with PostgreSQL full-text keyword matching using configurable weighting.

Real-Time Query Processing

Converts user prompts into embeddings on-the-fly with query caching to maintain sub-200ms latency.

Cosine Similarity Ranking

Uses vector distance calculations to compute match relevance and present ranked results with confidence scores.

System Architecture

End-to-End Processing Architecture

A 4-step pipeline bridging natural language queries directly to structured database results.

Step 01

Database Layer

PostgreSQL + Supabase hosting 10,000+ companies, investors, and financial deals.

10,000+ Entities
Step 02

Embeddings Generation

OpenAI embedding model generates 1,536-dimensional vectors stored in vector tables.

1,536 Vector Dimensions
Step 03

Hybrid Search Router

Combines Cosine Similarity (70%) with PostgreSQL Full-Text Keyword Search (30%).

70/30 Hybrid Weight
Step 04

User Interface

React Query rendering real-time results with transparent score indicators.

<200ms Latency

Key Architectural Capabilities

1,536-dimensional embedding vectors for semantic matching
Cosine similarity for vector distance calculation
Hybrid scoring combining AI and keyword approaches
Configurable weight adjustment (70% semantic + 30% keyword)
Real-time query embedding with caching layer
Batch entity processing for vector storage
Similarity threshold filtering (>0.7 for relevance)
Multi-entity type search with category filtering
Progressive result loading for instant feedback
Transparent score display (similarity, keyword, final)
Automatic fallback to keyword search on API timeout
Query deduplication reducing API costs by 80%
Sub-200ms response time optimization
Graceful error handling for high reliability
Interface & Evidence

Product Screenshots & Technical Evidence

Visual documentation of database schemas, vector search functions, server actions, and relevance UI.

Supabase Embeddings Table Structure (`entity_embeddings`)Wide Schema View
Supabase entity_embeddings table structure

Dedicated database table storing 1,536-dimensional vectors for 10,000+ entities with entity types, JSONB metadata, and foreign keys for vector retrieval.

PostgreSQL Cosine Similarity RPC Function (`ai_semantic_search.sql`)Database Search Engine
PostgreSQL ai_semantic_search RPC Function

Database RPC function performing cosine similarity vector comparison with threshold filtering and score normalization.

Server Action Logic (`ai-search.actions.ts`)
Main AI Search Action in TypeScript

Server action executing query embeddings, caching, hybrid score blending, and multi-entity data transforms.

Score Transparency UI (`AIScoreIndicator.tsx`)
AI Score Indicator Transparency Component

React component rendering similarity score, keyword score, and final blended score progress bars.

Technical Capabilities

Core System Modules

Embeddings Architecture

Converts 10,000+ entities into 1,536-dimensional vectors using OpenAI embeddings stored with pgvector indexing for sub-50ms lookup.

Real-Time Query Processing

Converts user queries into embeddings on-the-fly with caching, deduplication, and sub-200ms latency.

Hybrid Search Algorithm

Combines 70% AI semantic similarity with 30% PostgreSQL keyword matching for balanced precision.

Cosine Distance Math

Calculates vector distance using pgvector dot product math and filters low-relevance results below 0.7 threshold.

Multi-Entity Support

Unified search across companies, investors, funds, transactions, contacts, and news with category filtering.

Transparent Scoring UI

Exposes similarity, keyword, and blended scores in the UI with progress bars for user confidence.

Natural Language Prompts Supported Out-of-the-Box

"Show me investors backing climate tech startups recently"
"Companies in fintech with Series A funding in Nigeria"
"Private equity funds focused on healthcare in East Africa"
"Advisors with experience in renewable energy deals"
"Transactions involving agriculture in the last 2 years"
"Contact executives at companies with 100-500 employees"
"News about companies raising funding in Ghana"
Outcomes & Impact

Performance Outcomes & Strategic Learnings

95%+

Query Precision

Users locate target entities matching intent on first query attempt.

<200ms

Search Latency

Sub-200ms query execution provides instant user feedback.

80%

API Cost Reduction

Achieved via query deduplication and embedding caching.

The Shipped & Sunset Strategic Reflection

This feature was successfully shipped into production, used by real analysts, and eventually sunset when product priorities shifted toward B2B platform integration. Shipping an AI feature into live production and watching its lifecycle provided crucial experience: evaluating whether AI features are load-bearing business value or decorative additions.

Ready to Build?

Interested in AI-powered search or custom data systems?

Let's discuss how semantic vector search and automated data pipelines can simplify workflows for your team.