Skip to content

HealerCodeLabs/ai-semantic-search-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Semantic Search API 🧠

AI-powered semantic search API built with FastAPI, OpenAI Embeddings, and ChromaDB.

This project demonstrates the core concepts behind:

  • Embeddings
  • Semantic Search
  • Similarity Search
  • Vector Databases
  • RAG (Retrieval-Augmented Generation)

Features 🚀

  • Store documents with embeddings
  • Semantic similarity search
  • Vector database integration
  • Metadata filtering
  • FastAPI REST API
  • ChromaDB persistent storage

Tech Stack 🏗️

Technology Purpose
FastAPI Backend API
OpenAI Embeddings Semantic vector generation
ChromaDB Vector database
Python Core language

Project Structure 📁

app/
├── main.py
├── config.py
├── schemas.py
│
├── services/
│   ├── embedding_service.py
│   └── vector_store.py

Installation ⚙️

Clone Repository

git clone https://github.com/your-username/ai-semantic-search-api.git

Move Into Project

cd ai-semantic-search-api

Create Virtual Environment

Windows

python -m venv venv
venv\Scripts\activate

Linux / Mac

python3 -m venv venv
source venv/bin/activate

Install Dependencies 📦

pip install -r requirements.txt

Environment Variables 🔑

Create .env file:

OPENAI_API_KEY=your_openai_api_key

Run Server 🚀

uvicorn app.main:app --reload

Open Swagger Docs:

http://127.0.0.1:8000/docs

API Endpoints 📚

Method Endpoint Description
GET / Health check
POST /documents Add document
POST /search Semantic search
GET /documents List all documents
DELETE /documents Delete all documents

Example Document 📄

{
  "title": "FastAPI Tutorial",
  "content": "FastAPI is a modern Python framework for building APIs quickly.",
  "category": "backend"
}

Example Search 🔍

{
  "query": "How can I build API with Python?",
  "limit": 3
}

Semantic Search Example 🧠

Query:

How can I build APIs with Python?

Result:

FastAPI Tutorial

Even without exact keyword matching.

This works because embeddings capture semantic meaning.


Concepts Practiced 📖

This project helps practice:

  • Embeddings
  • Vector Search
  • Similarity Search
  • Cosine Similarity
  • Semantic Retrieval
  • Vector Databases
  • RAG Foundations

Future Improvements 🚀

  • PDF Upload Support
  • Text Chunking
  • PostgreSQL + pgvector
  • User Authentication
  • AI Chatbot Integration
  • RAG Pipeline
  • Redis Caching
  • Hybrid Search

Learning Goals 🎯

This project is designed for developers learning:

  • AI Engineering
  • RAG Systems
  • LLM Applications
  • Vector Databases
  • Semantic Search

License 📄

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages