Skip to content

Repository files navigation

RAG Document Retrieval API

A runnable Python/FastAPI portfolio project demonstrating the retrieval layer of a Retrieval-Augmented Generation (RAG) system without requiring a proprietary LLM or embedding API.

What It Demonstrates

  • FastAPI REST API
  • Document ingestion
  • Text chunking
  • Local vectorization
  • Cosine-similarity retrieval
  • Top-k search
  • Pydantic validation
  • Health checks
  • Automated API tests
  • Modular backend design
  • RAG architecture concepts

Design Choice

This project focuses on retrieval infrastructure. It uses a deterministic local bag-of-words vectorizer rather than an external embedding model so the repository is runnable without API keys.

Endpoints

  • GET /health
  • POST /v1/documents
  • GET /v1/documents
  • POST /v1/search

Run Locally

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
uvicorn app.main:app --reload

Interactive API docs are available at /docs.

Run Tests

pytest

Architecture

  1. Document text is chunked.
  2. Chunks are tokenized and vectorized locally.
  3. Query text is vectorized using the same method.
  4. Cosine similarity ranks chunks.
  5. The API returns the highest-scoring chunks with metadata.

Portfolio Note

All sample documents are synthetic. This repository demonstrates RAG retrieval architecture and does not claim production deployment of a generative model.

About

FastAPI RAG retrieval service with document ingestion, chunking, local vectorization, cosine-similarity search, API validation, automated tests, and Docker support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages