Knowly is a minimal proof-of-concept web app that lets users upload PDFs and chat with their content using AI.
Architecture:
- Backend: FastAPI (Python) handles file upload, text extraction, chunking, embedding, and vector DB storage (Chroma). It exposes endpoints for uploading PDFs and querying (chat).
- Frontend: Next.js provides a UI to upload PDFs and chat.
- Embeddings & LLM: Supports OpenAI embeddings + completion and HuggingFace embeddings fallback. Vector DB: Chroma (local) by default.
This prototype focuses on simplicity and modularity.
Quickstart (development):
- Backend: install requirements
cd backend
pip install -r requirements.txtCreate a .env file (see .env.example) with your OpenAI API key.
Run backend:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000- Frontend:
cd frontend
npm install
npm run devNotes & next steps:
- This POC uses local Chroma for vector storage. You can swap in Qdrant by replacing the vector store layer.
- Security, scale, and production concerns are omitted for brevity.
If you're on Windows and prefer PowerShell (no WSL), here are PowerShell-friendly steps to run both backend and frontend.
Backend (PowerShell):
cd backend
# install requirements
pip install -r requirements.txt
# create a .env file (copy from example if present) and add your keys
copy .env.example .env # if .env.example exists
# run the backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend (PowerShell):
cd frontend
copy .env.local.example .env.local # if the example exists
npm install
npm run devOpen http://localhost:3000 in your browser. The frontend expects the backend at http://localhost:8000 by default (set NEXT_PUBLIC_API_URL in .env.local to change).
Notes on networking:
- If you run both frontend and backend on Windows, use
http://localhost:8000for the API URL. - If you run the backend in a remote container or VM, point
NEXT_PUBLIC_API_URLto that host/port and ensure CORS is configured inbackend/app/main.pyif necessary. Frontend notes
- The frontend reads
NEXT_PUBLIC_API_URLfrom.env.local. Default in the example ishttp://localhost:8000. - If you need CORS or host adjustments, update
backend/app/main.py.
Required variables (backend .env):
- OPENAI_API_KEY - your OpenAI API key (required for embeddings and ChatCompletion)
- CHROMA_DB_DIR - (optional) directory where Chroma will persist indices (default: ./chroma_db)
Optional variables:
- HUGGINGFACE_API_KEY - (optional) if you want to use HuggingFace hosted APIs or models
- QDRANT_URL / QDRANT_API_KEY - (optional) if you swap to a remote Qdrant vector DB
How to get the keys:
- OpenAI: visit https://platform.openai.com/account/api-keys, create a new API key, and paste it into your
.envasOPENAI_API_KEY=. - HuggingFace: visit https://huggingface.co/settings/tokens and create a token for inference if needed. Put it into
HUGGINGFACE_API_KEY=.
Treat API keys as secrets. Do not commit .env to git. .gitignore in the repo already excludes .env and chroma_db.