How fakruddinbabadudekula/layered-rag-backend works
This is a document-grounded chat API: users register or authenticate, upload PDFs into a session, then ask questions and receive cited answers; sessions, messages, and retrieved sources support conversation history. The main internal layers are API routes, business services, repositories, and the RAG components. The README documents the major capabilities and high-level flow; source excerpts and the SOURCE INDEX support several service-level relationships, but routes and some storage internals were not sampled, so their detailed call paths are not inferred.
Main entry points: main.py FastAPI application · file_ingestion.py File ingestion · chat_service.py Chat service · vector_store_service.py Vector service
Components 24
HTTP API
- FastAPI application
app/main.py - Auth routes
app/api/routes/auth.py - Chat routes
app/api/routes/chat.py - Upload routes
app/api/routes/upload.py - History routes
app/api/routes/history.py
Business Services
- Authentication
app/services/auth_service.py - File ingestion
app/services/file_ingestion.py - Chat service
app/services/chat_service.py - LLM client
app/services/llm_client.py
Document RAG
- PDF loader
app/rag/document_loaders/doc_loader.py - RAG workflow
app/rag/workflow/graph.py - Vector service
app/services/vector_store_service.py - Vector manager
app/rag/vector/vecor_store_manager.py - FAISS store
app/rag/vector/faiss_vector_store.py
Persistence
- User repository
app/repositories/user_repository.py - Conversation repository
app/repositories/conversation_repository.py - File repository
app/repositories/file_repository.py - File metadata
app/repositories/file_metadata_repository.py
Other components
- Client
- Embedding provider
- LLM provider
- PostgreSQL
- Uploaded files
- Session indexes
Connections 28
- Client → FastAPI application: sends requests
README.md - FastAPI application → Auth routes: routes requests
app/main.py - FastAPI application → Chat routes: routes requests
app/main.py - FastAPI application → Upload routes: routes requests
app/main.py - FastAPI application → History routes: routes requests
app/main.py - Auth routes → Authentication: calls
app/api/routes/auth.py - Chat routes → Chat service: dispatches chat
README.md - Upload routes → File ingestion: dispatches upload
README.md - History routes → Conversation repository: reads history
README.md - File ingestion → File repository: saves files
app/services/file_ingestion.py - File ingestion → PDF loader: processes documents
app/services/file_ingestion.py - File ingestion → Vector service: adds documents
app/services/file_ingestion.py - File ingestion → File metadata: inserts metadata
app/services/file_ingestion.py - Chat service → Conversation repository: loads and saves
app/services/chat_service.py - Chat service → Vector service: gets retriever
app/services/chat_service.py - Chat service → RAG workflow: invokes workflow
app/services/chat_service.py - Chat service → LLM client: configures graph
app/services/chat_service.py - RAG workflow → LLM client: requests generation
README.md - LLM client → LLM provider: calls model
README.md - Vector service → Vector manager: delegates operations
app/services/vector_store_service.py - Vector service → FAISS store: loads or creates
app/services/vector_store_service.py - Vector service → Embedding provider: creates embeddings
README.md - Vector manager → Session indexes: persists index
app/rag/vector/vecor_store_manager.py - User repository → PostgreSQL: reads and writes
- Conversation repository → PostgreSQL: persists history
README.md - File metadata → PostgreSQL: stores metadata
- File repository → Uploaded files: writes uploaded files
app/repositories/file_repository.py - Authentication → User repository: uses user data