Mhonn YbañezSRE, DevOps, AI Engineer
 Projects
Read the full page

RAG API with FastAPI and Local Ollama

When
August 2026
Kind
Side project

Ask questions about your own documents, answered by a model running on your machine. Chunking, embedding, retrieval and generation all run on the host, with no hosted API and no per-token cost.

Problem

Asking questions about private documents means pasting them into a hosted chat tool, which sends them to someone else's server. Small local models fix that but cannot take a whole document, so something has to decide which passages they see.

Highlights

  1. Runs Ollama models on a laptop and customizes one with a Modelfile into a friendly coding tutor.
  2. Documents are split into overlapping chunks, embedded locally with nomic-embed-text and stored in ChromaDB.
  3. Retrieval is filtered by owner, so one person's chunks never leak into another's answer.
  4. Answers stream back as newline-delimited JSON, so cited chunks appear before the first token.
  5. Upload and ask endpoints with tests in pytest, a Swagger UI, and a small browser UI.
Locally hosted modelsNo document or question reaches a hosted API.

Stack

Architecture

Upload, chunk, embed, retrieve with an owner filter, generate.
FIG. A Upload, chunk, embed, retrieve with an owner filter, generate.

Screens

Links