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.
- 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
git clone <your-repo-url>
cd Vector-databaseMake sure you have Python 3.8+ installed. Then install the required packages:
pip install -r requirements.txtMain dependencies:
fastapi,uvicorn(web server)sqlalchemy(SQL database)sentence-transformers(embeddings)chromadb(vector database)
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()- Go to
http://127.0.0.1:8000/adminin 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).
- Use the "Embed Files" button in the dashboard, or run:
python store_in_chroma.py
- Use the "Query" tab in the dashboard, or run a script to query Chroma directly.
- Run the script:
This prints the content of the first document in Chroma. You can modify the script to see more.
python view_chroma_db.py
MIT