Skip to content

About

Production-oriented RAG platform using FastAPI, PostgreSQL/pgvector, Redis, background ingestion, retries, Docker Compose and nginx.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

AI RAG Chatbot — Production-Oriented RAG Platform

A document-grounded Retrieval-Augmented Generation (RAG) platform that combines FastAPI, PostgreSQL + pgvector, Redis, background ingestion, retry handling, vector retrieval, Docker Compose and nginx.

Rather than stopping at a notebook-level RAG demo, this repository separates the API, retrieval/services layer and background ingestion worker. Users can upload PDF, TXT or Markdown documents; the worker chunks and embeds them asynchronously; PostgreSQL/pgvector stores and retrieves vectorised content; Redis supports caching and the ingestion queue; and the question-answering path returns answers grounded in retrieved chunks with source filenames.

If relevant context is not indexed, the API reports that rather than inventing an answer.

Engineering Evidence

  • RAG / retrieval: document chunking, embeddings, pgvector similarity retrieval and source-aware answers
  • Python backend: FastAPI endpoints for document ingestion, question answering, deletion and health checks
  • Data infrastructure: PostgreSQL + pgvector for document/vector storage and Redis for caching/queueing
  • Asynchronous processing: background ingestion worker with retry handling when embedding fails
  • Deployment architecture: Dockerfile/Docker Compose-based services with nginx as the front/API entry point
  • Operational behaviour: Postgres/Redis health checks and explicit handling of unavailable retrieval context

Architecture

PDF / TXT / Markdown
        |
        v
   FastAPI API
        |
        +----> document metadata / content ----> PostgreSQL + pgvector
        |
        +----> ingestion queue ----------------> Redis
                                                    |
                                                    v
                                            Background Worker
                                                    |
                                          chunk + embed + index
                                                    |
                                                    v
                                            PostgreSQL + pgvector

Question ---> FastAPI ---> retrieve relevant chunks ---> grounded answer
                    |
                    +----> Redis cache

Client ---> nginx ---> API

API Capabilities

  • Upload documents: POST /documents
  • Background ingestion with retries if embedding fails
  • Ask grounded questions: POST /ask
  • Return source filenames with answers
  • Delete documents: DELETE /documents/{id}
  • Check PostgreSQL and Redis health: GET /health

Run Locally

cp .env.example .env
# set METIS_API_KEY in .env
docker compose up --build

Open:

  • http://localhost — nginx entry point
  • http://localhost:8000 — API directly

Grounding Behaviour

Answers are generated from retrieved document chunks. When nothing relevant is indexed, the service explicitly says so instead of guessing. This keeps the RAG behaviour inspectable and makes retrieval failure different from generation failure.

Technology Focus

FastAPI • RAG • PostgreSQL • pgvector • Redis • Background Workers • Retry Handling • Docker • Docker Compose • nginx • Vector Retrieval

About

Production-oriented RAG platform using FastAPI, PostgreSQL/pgvector, Redis, background ingestion, retries, Docker Compose and nginx.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages