How darkerror64/rag_python works
Agentic RAG Pipeline ingests PDFs into a searchable corpus, then answers questions through a ReAct agent whose retrieval gate requires successful content retrieval and whose citations are checked against stored chunks. The principal workflow runs from upload and asynchronous processing through PDF extraction, hierarchical parsing, semantic chunking, embedding, and database storage; queries retrieve chunks for the agent to use. The README also documents scoped search, CLI operations, provider checks, and retrieval benchmarking. Some API, worker, and database internals were not sampled; their connections below rely on the README’s architecture description.
Main entry points: main_controller.py Ingestion controller · database_manager.py PostgreSQL and pgvector · main.py FastAPI service · hierarchical_chunker.py Hierarchical chunking
Components 20
PDF Ingestion
- FastAPI service
app/main.py - Ingestion controller
app/controllers/main_controller.py - Async worker
app/worker.py - Redis broker
- PDF extraction
app/utils/pdf_extractor.py - Markdown AST parser
app/engines/markdown_parser.py - Hierarchical chunking
app/engines/hierarchical_chunker.py - Semantic chunking
app/engines/semantic_chunker.py - Token optimizer
app/utils/token_optimizer.py
Retrieval and Agent
- Vector retrieval
app/db/retrieval_manager.py - ReAct agent
app/engines/agent_engine.py - LLM service
app/core/llm.py
Storage and Providers
- PostgreSQL and pgvector
app/db/database_manager.py - Embedding providers
app/engines/embeddings.py - Runtime configuration
app/core/config.py - Hosted or local LLM
Interfaces and Evaluation
- CLI
cli.py - Retrieval evaluation
app/eval/retrieval_eval.py
Other components
- Client
- Questioner
Connections 33
- Client → FastAPI service: uploads PDF
README.md - FastAPI service → Ingestion controller: hands off ingestion
- FastAPI service → PostgreSQL and pgvector: stores upload bytes
README.md - FastAPI service → Redis broker: enqueues blob
README.md - Redis broker → Async worker: dispatches job
README.md - Async worker → PostgreSQL and pgvector: fetches PDF bytes
README.md - Async worker → Ingestion controller: runs ingestion
README.md - Ingestion controller → PDF extraction: extracts PDF
app/controllers/main_controller.py - Ingestion controller → PostgreSQL and pgvector: saves document
app/controllers/main_controller.py - Ingestion controller → Hierarchical chunking: segments document
- PDF extraction → Markdown AST parser: provides markdown
README.md - Hierarchical chunking → Markdown AST parser: parses structure
app/engines/hierarchical_chunker.py - Hierarchical chunking → Semantic chunking: detects boundaries
app/engines/hierarchical_chunker.py - Hierarchical chunking → Token optimizer: uses token limits
app/engines/hierarchical_chunker.py - Hierarchical chunking → Embedding providers: embeds chunks
README.md - Ingestion controller → PostgreSQL and pgvector: stores chunks
app/controllers/main_controller.py - Questioner → FastAPI service: asks question
README.md - FastAPI service → Ingestion controller: routes query
- Ingestion controller → Vector retrieval: runs scoped search
app/controllers/main_controller.py - ReAct agent → Vector retrieval: searches corpus
app/engines/agent_engine.py - Vector retrieval → Semantic chunking: embeds query
app/db/retrieval_manager.py - Vector retrieval → PostgreSQL and pgvector: queries vectors
app/db/retrieval_manager.py - ReAct agent → PostgreSQL and pgvector: reads chunks and verifies citations
app/engines/agent_engine.py - ReAct agent → LLM service: requests next step
app/engines/agent_engine.py - LLM service → Hosted or local LLM: calls provider
app/core/llm.py - Embedding providers → Runtime configuration: reads provider settings
app/engines/embeddings.py - LLM service → Runtime configuration: reads LLM settings
app/core/llm.py - CLI → Ingestion controller: runs ingest and query
cli.py - CLI → ReAct agent: starts agent chat
README.md - CLI → Embedding providers: checks provider
README.md - Retrieval evaluation → Hierarchical chunking: benchmarks chunking
app/eval/retrieval_eval.py - Retrieval evaluation → PostgreSQL and pgvector: stores and searches benchmark data
app/eval/retrieval_eval.py - Retrieval evaluation → Token optimizer: builds baseline chunks
app/eval/retrieval_eval.py