How bjukic2/python-rag-chatbot works
This repository is a RAG chatbot: users submit questions in a Next.js chat, FastAPI streams a response, and the backend embeds the question, retrieves document context from ChromaDB, then asks a local Ollama model to generate an answer. A separate ingestion script chunks documents, embeds each chunk, and stores it for retrieval. The README also documents the chat UI, streaming, vector search, and CORS. The graph follows shown calls and documented integration; retrieval internals and other unsampled modules are not inferred.
Main entry points: pipeline.py RAG pipeline · Chat.tsx Chat UI · ingest.py Ingestion script · chat.py Streaming route
Components 12
API service
- FastAPI app
backend/main.py - Streaming route
backend/app/api/chat.py
Retrieval and generation
- RAG pipeline
backend/app/rag/pipeline.py - Text embedder
backend/app/rag/embedder.py - Vector store
backend/app/db/vector_store.py - Store config
backend/app/core/config.py
Document ingestion
- Ingestion script
backend/ingest.py - Text splitter
backend/app/utils/text_splitter.py
Other components
- Chat user
- Ollama service
Connections 14
- Chat user → Chat UI: enters question
frontend/app/components/Chat.tsx - Chat page → Chat UI: renders
frontend/app/page.tsx - Chat UI → Streaming route: POSTs question
frontend/app/components/Chat.tsx - FastAPI app → Streaming route: mounts route
backend/main.py - Streaming route → RAG pipeline: streams tokens
backend/app/api/chat.py - RAG pipeline → Text embedder: embeds query
backend/app/rag/pipeline.py - RAG pipeline → Vector store: searches vectors
backend/app/rag/pipeline.py - RAG pipeline → Ollama service: requests generation
backend/app/rag/pipeline.py - Text embedder → Ollama service: requests embedding
backend/app/rag/embedder.py - Vector store → Store config: reads path
backend/app/db/vector_store.py - Ingestion script → Text splitter: chunks documents
backend/ingest.py - Ingestion script → Text embedder: embeds chunks
backend/ingest.py - Ingestion script → Vector store: stores chunks
backend/ingest.py - FastAPI app → Chat UI: enables CORS
README.md