This repository contains a full-stack Retrieval-Augmented Generation (RAG) application. The backend is built with FastAPI and integrates with ChromaDB and Ollama for LLM inference and vector storage. The frontend is built with Angular and provides a user-friendly interface for document upload, querying, and viewing responses.
- Features
- Project Structure
- Prerequisites
- Setup Instructions
- Running the Application
- API Endpoints
- Sample Inputs
- Advanced RAG Techniques
- Available Scripts
- Implementation Overview
- Document Upload: Upload PDF or text files for ingestion and retrieval.
- Query Submission: Submit queries and receive retrieval-augmented responses.
- Advanced Retrieval: Supports hybrid, reranking, and semantic search strategies.
- Interactive UI: Angular-based frontend for seamless user experience.
- API Documentation: Swagger UI for backend API exploration.
.
├── backend/
│ ├── README.md
│ ├── requirements.txt
│ ├── chromadb/
│ ├── sample_inputs/
│ └── src/
│ ├── main.py
│ ├── api/
│ ├── models/
│ ├── services/
│ └── utils/
└── frontend/
├── README.md
├── angular.json
├── package.json
├── tsconfig.json
└── src/
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
└── app/
- Python 3.8+
- pip
- virtualenv (recommended)
- Ollama (for local LLMs)
- ChromaDB (included as files)
- Node.js (v14+)
- npm
- Angular CLI (v13.x)
-
Clone the Repository
git clone <repository-url> cd backend
-
Create and Activate a Virtual Environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Install Ollama
- macOS:
brew install ollamaor download from https://ollama.com/download - Windows: Download and install from https://ollama.com/download
- Start Ollama:
ollama serve - Pull a model:
ollama pull llama3
- macOS:
-
Prepare ChromaDB
- The
chromadb/directory is pre-populated. No manual setup required.
- The
-
(Optional) Add Environment Variables
- Create a
.envfile inbackend/if needed.
- Create a
-
Clone the Repository
cd frontend -
Install Dependencies
npm install
-
Install Angular CLI (if not already)
npm install -g @angular/cli@13
-
Start Ollama
ollama serve
-
Start FastAPI Server
cd backend/src uvicorn src.main:app --reload- API docs: http://127.0.0.1:8000/docs
- Start Angular Development Server
or
cd frontend npm startng serve
- App available at http://localhost:4200
- POST /upload: Upload a document (PDF or text) for ingestion.
- POST /query: Submit a query and receive a retrieval-augmented response.
- GET /health: Health check endpoint.
See Swagger UI for detailed schemas.
The backend/sample_inputs/ directory contains:
meditations.pdf: Example PDF for ingestion.sample_query.txt: Example query.sample.json: Example JSON input.sample.txt: Example plain text file.
When submitting a query, users can select the retrieval strategy:
- Basic: Standard retrieval-augmented generation.
- Hybrid Search: Combines keyword and semantic search.
- Reranking: Retrieves candidates and reranks them using a secondary model.
- Semantic Search: Uses embeddings for retrieval.
The selected technique is sent to the backend as a technique parameter in the /query endpoint.
- Start server: See above.
- Install dependencies:
pip install -r requirements.txt
- npm start / ng serve: Start dev server.
- npm run build / ng build: Build for production.
- npm test / ng test: Run unit tests.
- npm run lint / ng lint: Lint codebase.
- npm run e2e / ng e2e: Run end-to-end tests.
- Backend: FastAPI app with endpoints for document upload, query, and health check. Uses ChromaDB for vector storage and Ollama for LLM inference.
- Frontend: Angular app with components for upload, query, and results. Uses a dedicated service for API integration.
- Component-Based UI: Upload, query, and results display are organized as reusable Angular components.