How hueiboi/rag works
This is a personalized document-question-answering RAG chatbot: users authenticate, upload documents, and ask questions through a Next.js UI; FastAPI indexes files and retrieves user-scoped context before generating an answer with Groq. The map preserves upload/indexing, chat/retrieval, history, auth, and the hybrid retrieval internals. Edges reflect sampled calls or README-described integrations; several frontend and retrieval adapter details are unsampled, so only documented or directly supported links are shown.
Main entry points: chat.py Chat and document API · retrieval_factory.py Retrieval assembly · engine.py Hybrid retrieval engine · pipeline.py RAG orchestration
Components 25
Web application
- Chat interface
rag-ui/app/chat/page.tsx - Auth screens
rag-ui/components/auth-page/AuthPage.tsx - OAuth callback
rag-ui/app/auth/callback/route.ts - Session route guard
rag-ui/proxy.ts - API client
rag-ui/lib/api.ts
API and domain
- Chat and document API
src/api/routes/chat.py - Request authentication
src/auth.py - Request dependencies
src/dependencies.py - Document ingestion
src/ingestion.py - File storage adapter
src/storage.py - Chat history
src/history.py - RAG orchestration
src/pipeline.py - Context formatting
src/prompt_context.py - Prompt and LLM setup
src/llm_service.py
Retrieval system
- Retrieval assembly
src/retrieval_factory.py - Hybrid retrieval engine
src/retrieval/engine.py - Lexical ranking
src/retrieval/lexical.py - Corpus statistics
src/retrieval/adapters/pg_corpus_stats.py - Vector store adapter
src/retrieval/adapters/pgvector_store.py - Embedding adapter
src/retrieval/adapters/hf_embedder.py
External services
- Supabase Auth
- Supabase Storage
- PostgreSQL pgvector
- Groq LLM
Other components
- User
Connections 32
- User → Chat interface: asks or uploads
README.md - User → Auth screens: signs in
README.md - Chat interface → API client: uses
rag-ui/app/chat/page.tsx - API client → Chat and document API: sends requests
README.md - Auth screens → Supabase Auth: authenticates
README.md - OAuth callback → Supabase Auth: completes OAuth
- Session route guard → Supabase Auth: checks session
README.md - Chat and document API → Request dependencies: depends on
src/api/routes/chat.py - Request dependencies → Request authentication: uses
src/dependencies.py - Chat and document API → RAG orchestration: invokes
src/api/routes/chat.py - Chat and document API → Document ingestion: indexes upload
src/api/routes/chat.py - Chat and document API → File storage adapter: manages files
src/api/routes/chat.py - Chat and document API → Chat history: reads and saves
src/api/routes/chat.py - Document ingestion → File storage adapter: downloads file
src/ingestion.py - File storage adapter → Supabase Storage: reads and writes
src/storage.py - Document ingestion → PostgreSQL pgvector: stores indexed chunks
README.md - Chat and document API → PostgreSQL pgvector: deletes file vectors
src/api/routes/chat.py - RAG orchestration → Retrieval assembly: retrieves context
src/pipeline.py - RAG orchestration → Context formatting: formats chunks
src/pipeline.py - RAG orchestration → Prompt and LLM setup: builds chain with
src/pipeline.py - Prompt and LLM setup → Groq LLM: configures model
src/llm_service.py - Retrieval assembly → Document ingestion: opens vector store
src/retrieval_factory.py - Retrieval assembly → Hybrid retrieval engine: constructs
src/retrieval_factory.py - Retrieval assembly → Embedding adapter: configures
src/retrieval_factory.py - Retrieval assembly → Vector store adapter: configures
src/retrieval_factory.py - Retrieval assembly → Corpus statistics: configures
src/retrieval_factory.py - Hybrid retrieval engine → Lexical ranking: reranks candidates
src/retrieval/engine.py - Hybrid retrieval engine → Embedding adapter: embeds query
- Hybrid retrieval engine → Vector store adapter: searches chunks
- Hybrid retrieval engine → Corpus statistics: gets token stats
- Corpus statistics → PostgreSQL pgvector: queries chunk text
- Vector store adapter → PostgreSQL pgvector: accesses vectors