How yourdrug/rag-assistant works
This repository is a self-hostable corporate RAG assistant with a React client and FastAPI backend. The main user workflow is document ingestion followed by a question-and-answer flow: the README documents retrieval from Qdrant, reranking, and streaming an LLM answer. Admin and user pages expose ingestion, chat, search, document, and operational capabilities. The graph includes the sampled ingestion orchestration and RAG implementation; unsampled connections are omitted rather than inferred from directory structure.
Main entry points: rag_service.py RAG service · main.py FastAPI application · App.tsx React application · ingest.py Ingestion endpoints
Components 19
Web client
- React application
client/src/App.tsx - Chat and search
client/src/pages/chat.tsx - Admin console
client/src/pages/admin/ingest.tsx
API surface
- FastAPI application
server/app/main.py - Ingestion endpoints
server/app/presentation/api/routes/ingest.py
Application services
- Ingestion service
server/app/application/services/ingest_service.py - Job service
server/app/application/services/job_service.py - Document queries
server/app/application/services/document_query_service.py - Chunk queries
server/app/application/services/chunk_query_service.py - Ingestion port
server/app/application/ports/ingestion_port.py
RAG and ingestion
- RAG service
server/app/infrastructure/ml/rag_service.py - RAG pipeline state
server/app/infrastructure/ml/rag_pipeline.py - Document parsers
server/app/infrastructure/ml/ingestion
Infrastructure
- Ingestion registry
server/app/infrastructure/repositories/document/sqlalchemy_ingestion_registry_repository.py - PostgreSQL
server/app/infrastructure/database/models.py - Qdrant
- Reranker
- LLM
Other components
- User
Connections 20
- User → React application: uses
README.md - React application → Chat and search: offers chat
- React application → Admin console: offers administration
- User → FastAPI application: asks questions
README.md - User → Admin console: submits documents
README.md - FastAPI application → Ingestion endpoints: routes requests
server/app/main.py - Ingestion endpoints → Ingestion service: calls
server/app/presentation/api/routes/ingest.py - Ingestion endpoints → Job service: creates jobs
server/app/presentation/api/routes/ingest.py - Ingestion service → Ingestion port: delegates ingestion
server/app/application/services/ingest_service.py - Ingestion port → Document parsers: parses documents
- Ingestion registry → PostgreSQL: reads and writes
server/app/infrastructure/repositories/document/sqlalchemy_ingestion_registry_repository.py - Chat and search → FastAPI application: sends questions
- FastAPI application → RAG service: dispatches chat
- RAG service → RAG pipeline state: uses state
server/app/infrastructure/ml/rag_service.py - RAG service → Qdrant: retrieves context
README.md - RAG service → Reranker: reranks results
README.md - RAG service → LLM: streams answer
README.md - Document queries → PostgreSQL: reads documents
- Chunk queries → PostgreSQL: reads chunks
- Ingestion service → Ingestion registry: reads registry