A local RAG web application that accepts batches of PDF, TXT, and CSV files, indexes their contents with Sentence Transformers and FAISS, and answers questions with Groq.
- React sends selected files as multipart form data.
- FastAPI streams each file to
backend/data/uploads. - The loader extracts text and preserves the filename and PDF page.
- The embedding pipeline splits the text into overlapping chunks.
- New vectors and metadata are appended to the persisted FAISS index.
- A SQLite registry tracks uploaded documents and their processing status.
- Search retrieves the closest chunks and asks Groq to answer only from them.
| Layer | Tech |
|---|---|
| Frontend | React, Vite, JavaScript, CSS |
| Backend | Python, FastAPI, Uvicorn, Pydantic |
| RAG pipeline | LangChain document loaders and text splitters |
| Embeddings | Sentence Transformers (all-MiniLM-L6-v2) |
| Vector search | FAISS |
| LLM | Groq through langchain-groq |
| Data storage | SQLite, local file storage, persisted FAISS metadata |
| Document processing | PyPDF, TXT, and CSV loaders |
Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activateInstall backend dependencies:
pip install -r requirements.txtInstall frontend dependencies:
npm installCopy the environment template and add your Groq key:
cp .env.example .envStart FastAPI in the first terminal:
source .venv/bin/activate
python app.pyStart React in a second terminal:
npm run devOpen http://localhost:5173.
The first backend start may download all-MiniLM-L6-v2 from Hugging Face.
POST /api/documentsuploads and indexes up to 50 files per request.GET /api/documentslists registered documents and the indexed chunk count.DELETE /api/documents/{document_id}removes a file and its vectors.POST /api/searchanswers a question and returns retrieved sources.
Uploads accept PDF, TXT, and CSV files up to 20 MB each. Repeated upload batches let the library grow over time; the limit is per request, not the whole library.
The application stores runtime data in:
backend/data/uploads/for original uploadsbackend/data/documents.sqlite3for the document registryfaiss_store/faiss.indexfor vectorsfaiss_store/metadata.pklfor chunk text and source metadata
Run a single FastAPI worker with this local FAISS architecture. A production multi-worker deployment should use shared object storage, a job queue, and a network-accessible vector database.