How fakruddinbabadudekula/askyourdocs works
Notebook RAG Backend is a FastAPI service for accounts, notebooks, PDF ingestion, and document-grounded chat. The main workflow is client request → API route → application use case: uploads are stored, parsed and chunked, then indexed with user/notebook metadata; chat retrieves relevant chunks and generates a cited answer. Authentication and notebook/message persistence are separate capabilities. The graph follows the documented ports-and-adapters design. Several implementation files were not sampled, so documented relationships are included where explicit; uncertain links are omitted.
Main entry points: main.py FastAPI app · file_ingestion_service.py File ingestion · chat_service.py Chat service · auth_service.py Authentication
Components 23
HTTP interface
- FastAPI app
app/main.py - Auth routes
app/interface/api/routes/auth.py - Registration route
app/interface/api/routes/register.py - Upload route
app/interface/api/routes/upload.py - Chat route
app/interface/api/routes/chat.py
Application use cases
- Authentication
app/application/auth_service.py - File ingestion
app/application/file_ingestion_service.py - Chat service
app/application/chat_service.py - Token security
app/application/security.py
Document RAG
- Document processing
app/application/doc_processor.py - Vector operations
app/application/vector_store_service.py - RAG workflow
app/application/workflow.py - LLM client
app/infrastructure/rag/llm_client.py - PDF loader
app/infrastructure/rag/loaders.py - Text splitter
app/infrastructure/rag/splitter.py
Infrastructure adapters
- FAISS store
app/infrastructure/rag/vector_store/faiss_vector_store.py - Local file storage
app/infrastructure/file_storage_repository.py - Unit of work
app/infrastructure/unit_of_work.py - SQL repositories
app/infrastructure/sqlalchemy_repositories - Dependency composition
app/root.py
Other components
- Client
- PostgreSQL
- Chat model API
Connections 30
- Client → FastAPI app: sends requests
- FastAPI app → Auth routes: registers routes
app/main.py - FastAPI app → Registration route: registers routes
app/main.py - FastAPI app → Upload route: registers routes
app/main.py - FastAPI app → Chat route: registers routes
app/main.py - Auth routes → Authentication: calls
app/interface/api/routes/auth.py - Registration route → Authentication: delegates registration
- Upload route → File ingestion: delegates upload
- Chat route → Chat service: delegates chat
- Authentication → Token security: uses token services
app/application/auth_service.py - Authentication → Unit of work: uses repositories
app/application/auth_service.py - File ingestion → Local file storage: saves upload
app/application/file_ingestion_service.py - File ingestion → Unit of work: persists metadata
app/application/file_ingestion_service.py - File ingestion → Document processing: loads and splits
app/application/file_ingestion_service.py - File ingestion → Vector operations: indexes chunks
app/application/file_ingestion_service.py - Document processing → PDF loader: loads PDFs
- Document processing → Text splitter: splits text
- Chat service → RAG workflow: runs workflow
app/application/chat_service.py - Chat service → Unit of work: persists messages
app/application/chat_service.py - Chat service → Vector operations: retrieves context
app/application/chat_service.py - RAG workflow → FAISS store: retrieves chunks
- RAG workflow → LLM client: generates answer
- LLM client → Chat model API: invokes model
app/infrastructure/rag/llm_client.py - Vector operations → FAISS store: accesses vectors
- Unit of work → SQL repositories: coordinates repositories
- SQL repositories → PostgreSQL: persists records
- FastAPI app → Dependency composition: creates container
app/main.py - Dependency composition → File ingestion: constructs service
app/root.py - Dependency composition → Chat service: constructs service
app/root.py - Dependency composition → Authentication: constructs service
app/root.py