How kemalkilicaslan/on-premise-rag-document-assistant-system works
This is an on-premise Turkish PDF RAG assistant. Admins upload PDFs with reader roles; the service extracts page text, chunks and embeds it, then stores document metadata and vectors. Users authenticate, ask questions, and receive answers grounded in role-filtered chunks with page citations. The README also documents retrieval and answer evaluation; their source modules are included, but evaluation wiring is not established by the excerpts. Edges reflect shown calls or README-documented relationships; unsampled components have no inferred links.
Main entry points: db.py Database access · ingest.py PDF extraction and ingest · rag.py Role-filtered retrieval · llm.py Ollama client
Components 20
API and access
- FastAPI app
src/docrag/api.py - Authentication routes
src/docrag/routers/auth.py - JWT and RBAC
src/docrag/security.py - Document routes
src/docrag/routers/documents.py - Chat route
src/docrag/routers/chat.py - CLI client
src/docrag/cli.py - API schemas
src/docrag/schemas.py
Document ingestion
- PDF extraction and ingest
src/docrag/ingest.py - Page-aware chunking
src/docrag/chunking.py
Grounded answering
- Role-filtered retrieval
src/docrag/rag.py - Grounded prompts
src/docrag/prompt.py - Ollama client
src/docrag/llm.py
Persistence
- Database access
src/docrag/db.py - User, document, chunk models
src/docrag/models.py - Runtime settings
src/docrag/config.py
Evaluation
- Retrieval evaluation
src/docrag/evaluate.py - Answer evaluation
src/docrag/evaluate_answers.py
Other components
- User
- Ollama service
- PostgreSQL and pgvector
Connections 27
- User → FastAPI app: uses API
README.md - FastAPI app → Authentication routes: mounts routes
src/docrag/api.py - FastAPI app → Chat route: mounts routes
src/docrag/api.py - FastAPI app → Document routes: mounts routes
src/docrag/api.py - Authentication routes → JWT and RBAC: issues tokens
src/docrag/routers/auth.py - Authentication routes → Database access: queries users
src/docrag/routers/auth.py - JWT and RBAC → Database access: loads user
src/docrag/security.py - Document routes → JWT and RBAC: checks roles
src/docrag/routers/documents.py - Chat route → JWT and RBAC: authenticates user
src/docrag/routers/chat.py - Chat route → Role-filtered retrieval: requests answer
src/docrag/routers/chat.py - Document routes → PDF extraction and ingest: ingests PDF
src/docrag/routers/documents.py - PDF extraction and ingest → Page-aware chunking: chunks pages
src/docrag/ingest.py - PDF extraction and ingest → Ollama client: embeds chunks
src/docrag/ingest.py - PDF extraction and ingest → Database access: stores document
src/docrag/ingest.py - Role-filtered retrieval → Ollama client: embeds query
src/docrag/rag.py - Role-filtered retrieval → Database access: searches chunks
src/docrag/rag.py - Role-filtered retrieval → Grounded prompts: builds messages
src/docrag/rag.py - Role-filtered retrieval → Ollama client: generates answer
src/docrag/rag.py - Ollama client → Ollama service: calls API
src/docrag/llm.py - Database access → PostgreSQL and pgvector: queries and writes
src/docrag/db.py - User, document, chunk models → Database access: declares tables
src/docrag/models.py - Database access → Runtime settings: reads settings
src/docrag/db.py - PDF extraction and ingest → Runtime settings: reads settings
src/docrag/ingest.py - Ollama client → Runtime settings: reads settings
src/docrag/llm.py - Chat route → API schemas: uses response models
src/docrag/routers/chat.py - User → CLI client: asks questions
README.md - Answer evaluation → Retrieval evaluation: uses evaluation
src/docrag/evaluate_answers.py