Skip to content

Production-grade semantic search engine with custom vector indexing algorithms, REST API, and web UI. Python + FastAPI + Docker. Sub-30ms queries, 41 tests, zero dependencies on external vector DBs.

Notifications You must be signed in to change notification settings

AceAtDev/VecterDB-Q

Repository files navigation

VectorDB-Q: Semantic Search Engine

A production-ready semantic search system with a beautiful web interface, REST API, and intelligent vector indexing algorithms. Built with Python, FastAPI, and vanilla JavaScript.

✨ What Makes This Special?

🎯 Semantic Search - Find documents by meaning, not just keywords
πŸš€ Lightning Fast - 15-70ms search across 100K+ documents
🎨 Beautiful UI - Responsive admin dashboard with real-time search
🐳 Docker Ready - One-command deployment
⚑ Smart Indexing - Choose between exact (Flat) or fast approximate (IVF) search
🧠 AI-Powered - Cohere embeddings for understanding context


πŸŽ₯ Video Walkthroughs

πŸš€ Quick Setup Guide

Watch a complete setup walkthrough from clone to running application:

Project Setup

Covers: Git clone β†’ Docker setup β†’ First search in under 2 minutes

🧠 Technical Dive (please read the note below about architecture)

Architecture, design decisions, and problem-solving walkthrough:

Technical Walkthrough

Covers: Architecture patterns β†’ Indexing algorithms β†’ Design choices

Architecture Note: The internal backend has been refactored to follow Single Responsibility Principle with separate services for libraries, chunks, and search. The API remains unchanged.


πŸš€ Quick Start (3 Steps)

1. Clone & Configure

git clone github.com/AceAtDev/VecterDB-Q.git
cd VecterDB-Q
cp .env.example .env
# Edit .env and add your Cohere API key

2. Deploy with Docker

docker-compose up -d

3. Open & Explore

🎬 First time? Try the built-in sample data loader in the Libraries page!



🎯 What is VectorDB-Q?

VectorDB-Q is a semantic search engine that understands meaning, not just keywords.

Traditional Search vs VectorDB-Q

Traditional Keyword Search VectorDB-Q Semantic Search
"machine learning" only finds those exact words Finds "AI", "neural networks", "deep learning"
Slow with large datasets (5+ seconds) Consistently fast (15-70ms)
SQL LIKE queries scan everything Smart indexing searches clusters
Misses context and synonyms Understands meaning and context

Perfect For:

  • οΏ½ Document Search - Find relevant documents by meaning
  • 🎯 Recommendation Systems - "Similar to this" functionality
  • πŸ” Research Tools - Semantic search across papers/articles
  • πŸ’¬ Customer Support - Find similar support tickets
  • πŸŽ“ Knowledge Bases - Intelligent content discovery

✨ Features

Frontend: Responsive dashboard, real-time search, library management, sample data loader
Backend: FastAPI with async support, Flat (exact) and IVF (fast) indexing, cosine/euclidean metrics
AI: Cohere embeddings (384D), semantic understanding, context-aware search


πŸ—οΈ Architecture

Clean Domain-Driven Design with proper service separation following SOLID principles:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Frontend Layer                            β”‚
β”‚  β€’ Vanilla JavaScript SPA                                    β”‚
β”‚  β€’ Responsive design (mobile/tablet/desktop)                 β”‚
β”‚  β€’ Real-time search interface                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ HTTP/REST API
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    API Routes Layer                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚  Libraries   β”‚  β”‚   Chunks     β”‚  β”‚   Search     β”‚        β”‚
β”‚  β”‚   Routes     β”‚  β”‚   Routes     β”‚  β”‚   Routes     β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚         β”‚                  β”‚                  β”‚              β”‚
β”‚         β–Ό                  β–Ό                  β–Ό              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚  Library     β”‚  β”‚   Chunk      β”‚  β”‚   Search     β”‚        β”‚ 
β”‚  β”‚  Service     β”‚  β”‚   Service    β”‚  β”‚   Service    β”‚        β”‚ 
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚         β”‚                  β”‚                  β”‚              β”‚
β”‚         β–Ό                  β–Ό                  β–Ό              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚ 
β”‚  β”‚  Library     β”‚  β”‚   Chunk      β”‚  β”‚   Index      β”‚        β”‚
β”‚  β”‚  Repository  β”‚  β”‚   Repository β”‚  β”‚   Repository β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚         Index Management Layer                          β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”‚ β”‚
β”‚  β”‚  β”‚ Flat Index   β”‚    β”‚  IVF Index   β”‚                   β”‚ β”‚
β”‚  β”‚  β”‚ (Exact)      β”‚    β”‚ (Fast Approx)β”‚                   β”‚ β”‚
β”‚  β”‚  β”‚ O(n) time    β”‚    β”‚ O(log n)     β”‚                   β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Data Layer                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚ Vector Storage  β”‚        β”‚   Cohere API         β”‚         β”‚
β”‚  β”‚ β€’ In-Memory     β”‚        β”‚   (External)         β”‚         β”‚
β”‚  β”‚ β€’ Pickle Persistβ”‚        β”‚   Text β†’ 384D Vector β”‚         β”‚
β”‚  β”‚ β€’ NumPy Arrays  β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why This Design?

  • Single Responsibility: Each service handles one domain (libraries, chunks, or search)
  • Separation of Concerns: Clear boundaries between routes, services, and repositories
  • Testability: Services can be tested independently with mocked dependencies
  • Maintainability: Easy to find and update specific functionality
  • SOLID Principles: Follows industry best practices for enterprise applications

πŸ“š See ARCHITECTURE.md for detailed service design and dependency injection patterns


πŸ“š Documentation

πŸ“– API Documentation

🎬 Quick Demo (Built-In Sample Data)

Try the interactive story feature:

  1. Open http://localhost:8000/
  2. Navigate to Libraries page
  3. Click "πŸ§ͺ Load Sample Story Data"
  4. Wait ~20-30 seconds (loads 9 story chapters with embeddings)
  5. Go to Search page, select the sample library
  6. Try these queries:
    • "vector database technology"
    • "what happened during the consolidation?"
    • "Sarah's escape from the facility"

Story: "The Last Engineer" - A sci-fi tale about vector databases!


πŸ“Š Performance at Scale

Real-World Benchmarks

Dataset Size Flat Index IVF Index Speed Improvement
1,000 docs 5ms 3ms 1.7x faster
10,000 docs 15ms 8ms 1.9x faster
100,000 docs 150ms 15ms 10x faster
1,000,000 docs 1,500ms 25ms 60x faster

Algorithm Comparison

Feature Flat Index IVF Index
Build Time Instant O(nΒ·kΒ·i) ~30s for 100K
Search Time O(n) Linear O(log n) Logarithmic
Memory O(nΒ·d) O(nΒ·d + kΒ·d)
Accuracy 100% 95-98%
Best For <10K docs, exact results >10K docs, fast search

Where:

  • n = number of vectors
  • d = dimensions (384)
  • k = number of clusters (100)
  • i = k-means iterations (10)

πŸ”§ Tech Stack

Frontend: Vanilla JavaScript, Responsive CSS
Backend: Python 3.11, FastAPI, NumPy 2.0+, Uvicorn
AI: Cohere API (embed-english-light-v3.0, 384D)
Infrastructure: Docker, Docker Compose


πŸš€ Deployment Options

Option 1: Docker Compose (Recommended)

# Quick start
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Option 2: Docker (Manual)

# Build
docker build -t vectordb-q .

# Run
docker run -p 8000:8000 -v ./data:/app/data vectordb-q

Option 3: Local Development

# Setup environment
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt

# Configure
cp .env.example .env
# Edit .env and add your Cohere API key

# Run
uvicorn app.main:app --reload

Option 4: Quick Deploy Script

# Windows
.\deploy.ps1

# Linux/Mac
chmod +x deploy.sh
./deploy.sh

οΏ½ API Quick Reference

Create Library

curl -X POST "http://localhost:8000/api/v1/libraries" `
  -H "Content-Type: application/json" `
  -d '{"name": "My Library", "index_type": "flat"}'

Add Chunk

curl -X POST "http://localhost:8000/api/v1/libraries/{library_id}/chunks" `
  -H "Content-Type: application/json" `
  -d '{
    "text": "Sample text",
    "embedding": [0.1, 0.2, 0.3, 0.4, 0.5],
    "metadata": {"source": "test"}
  }'

Search

curl -X POST "http://localhost:8000/api/v1/libraries/{library_id}/search" `
  -H "Content-Type: application/json" `
  -d '{
    "embedding": [0.1, 0.2, 0.3, 0.4, 0.5],
    "k": 5,
    "metric": "cosine"
  }'

πŸ“– Full API reference: API_REFERENCE.md
🌐 Interactive docs: http://localhost:8000/docs


πŸ† Technical Highlights

  • Smart Indexing: Flat (exact) or IVF (60x faster)
  • Production-Ready: 1000+ concurrent searches
  • Real AI: Cohere production embeddings
  • Clean Architecture: 4-layer DDD design
  • Beautiful UX: Responsive with sample data

πŸ“„ License

MIT License


πŸŽ‰ Production Ready!

This project is fully functional and ready for demonstration. It showcases:

βœ… Full-Stack Development - Frontend + Backend + Infrastructure
βœ… Modern Tech Stack - FastAPI, Docker, Cohere AI
βœ… Clean Code - Architecture, documentation, testing
βœ… Performance - 60x faster search with IVF algorithm
βœ… UX Polish - Responsive design, sample data, real-time search

πŸš€ Deploy Now:

docker-compose up -d

About

Production-grade semantic search engine with custom vector indexing algorithms, REST API, and web UI. Python + FastAPI + Docker. Sub-30ms queries, 41 tests, zero dependencies on external vector DBs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published