How breaseabrol/rag-system works
This is a local hybrid RAG application: users query ingested documents through a terminal-style React UI, while a synchronous FastAPI backend retrieves relevant chunks, fuses lexical and vector rankings, and generates cited answers. A separate ingest endpoint loads URLs, chunks and embeds their content, and stores it for later retrieval. The graph follows shown calls and README-documented integrations; unsampled implementation details are represented only where the README supports them.
Main entry points: pipeline.py Ingest pipeline · retrieval.py Hybrid retrieval · main.py FastAPI app · routes_query.py Query endpoint
Components 20
Query interface
- Query console
frontend/src/App.tsx - Query client
frontend/src/api/client.ts
Backend API
- FastAPI app
backend/app/main.py - Query endpoint
backend/app/api/routes_query.py - Ingest endpoint
backend/app/api/routes_ingest.py - API schemas
backend/app/schemas/model.py - DB sessions
backend/app/db/session.py
Ingestion
- URL loader
backend/app/ingestion/loader.py - Ingest pipeline
backend/app/ingestion/pipeline.py - Structure-aware chunker
backend/app/core/chunking.py - Local embeddings
backend/app/core/embeddings.py - Document and chunk records
backend/app/db/models.py
Retrieval and generation
- Hybrid retrieval
backend/app/core/retrieval.py - BM25 index
backend/app/core/lexical_index.py - Vector search
backend/app/db/vector_store.py - Answer generation
backend/app/core/generation.py
Other components
- User
- PostgreSQL / pgvector
- Ollama
- Source URLs
Connections 27
- User → Query console: submits query
frontend/src/App.tsx - Query console → Query client: requests answer
frontend/src/App.tsx - Query client → FastAPI app: POST /query
README.md - FastAPI app → Query endpoint: routes query
backend/app/main.py - Query endpoint → Hybrid retrieval: retrieves chunks
backend/app/api/routes_query.py - Query endpoint → Answer generation: generates answer
backend/app/api/routes_query.py - Query endpoint → API schemas: uses response models
backend/app/api/routes_query.py - Query console → API schemas: renders answer and sources
README.md - User → FastAPI app: POST /ingest
README.md - FastAPI app → Ingest endpoint: routes ingest
backend/app/main.py - Ingest endpoint → Ingest pipeline: ingests URL
backend/app/api/routes_ingest.py - Ingest endpoint → API schemas: uses request models
backend/app/api/routes_ingest.py - Ingest pipeline → URL loader: loads document
backend/app/ingestion/pipeline.py - URL loader → Source URLs: fetches content
README.md - Ingest pipeline → Structure-aware chunker: chunks text
backend/app/ingestion/pipeline.py - Ingest pipeline → Local embeddings: embeds chunks
backend/app/ingestion/pipeline.py - Ingest pipeline → Document and chunk records: creates records
backend/app/ingestion/pipeline.py - Ingest pipeline → BM25 index: rebuilds index
backend/app/ingestion/pipeline.py - Ingest pipeline → PostgreSQL / pgvector: persists documents and vectors
README.md - Hybrid retrieval → BM25 index: searches lexical index
backend/app/core/retrieval.py - Hybrid retrieval → Local embeddings: embeds query
backend/app/core/retrieval.py - Hybrid retrieval → Vector search: runs ANN search
backend/app/core/retrieval.py - Vector search → PostgreSQL / pgvector: searches vectors
README.md - Hybrid retrieval → Document and chunk records: fetches ranked chunks
backend/app/core/retrieval.py - Answer generation → Ollama: generates grounded answer
README.md - DB sessions → PostgreSQL / pgvector: opens database sessions
backend/app/db/session.py - FastAPI app → DB sessions: provides startup session
backend/app/main.py