Skip to content

Dev-Vis1/Vector-database

Repository files navigation

Vector Database Project

This project provides a modern admin dashboard (FastAPI + HTML/JS) for uploading, viewing, deleting, embedding, and querying documents using a Chroma vector database. It also demonstrates how to create a traditional SQL database with SQLAlchemy and build a vector database from uploaded documents.

Features

  • Modern admin dashboard at /admin (upload, view, delete, embed, query)
  • Upload documents via web interface
  • Store document metadata and content in a SQL database (SQLAlchemy)
  • Generate vector embeddings from documents (Sentence Transformers)
  • Store and query embeddings using Chroma vector database
  • Progress bars for embedding and querying
  • View all files and delete from dashboard
  • Inspect Chroma DB contents with a script

Getting Started

1. Clone the Repository

git clone <your-repo-url>
cd Vector-database

2. Install Dependencies

Make sure you have Python 3.8+ installed. Then install the required packages:

pip install -r requirements.txt

Main dependencies:

  • fastapi, uvicorn (web server)
  • sqlalchemy (SQL database)
  • sentence-transformers (embeddings)
  • chromadb (vector database)

Usage

1. Create a SQL Database with SQLAlchemy

Below is a minimal example of how to define a document table and create a database using SQLAlchemy:

from sqlalchemy import create_engine, Column, Integer, String, Text
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

Base = declarative_base()

class Document(Base):
    __tablename__ = 'documents'
    id = Column(Integer, primary_key=True)
    filename = Column(String, unique=True)
    content = Column(Text)

# Create SQLite database
engine = create_engine('sqlite:///documents.db')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()

2. Use the Admin Dashboard

  • Go to http://127.0.0.1:8000/admin in your browser.
  • Add File: Upload documents (content and metadata stored in SQL database).
  • View Files: See all uploaded files and delete as needed.
  • Embed Files: Click to generate and store embeddings in Chroma (progress bar shown).
  • Query: Enter a text query to search the vector database (progress bar shown, references returned).

3. Generate Embeddings and Store in Chroma

  • Use the "Embed Files" button in the dashboard, or run:
    python store_in_chroma.py

4. Query the Vector Database

  • Use the "Query" tab in the dashboard, or run a script to query Chroma directly.

5. Inspect Chroma DB

  • Run the script:
    python view_chroma_db.py
    This prints the content of the first document in Chroma. You can modify the script to see more.

References


License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published