How alexlawren/rag-django-project-lawrentiev works
This is a local Django document-question-answering assistant. A user uploads a document, which the web view passes through parsing, sentence-window chunking, embedding, and persistent ChromaDB indexing. The active collection is tracked in the session; a later question is embedded for vector retrieval, candidates are cross-encoder re-ranked, and their context windows are used to prompt local Qwen generation. The page displays the answer and retrieved context. README documents these capabilities; implementation details below are grounded in the sampled views and RAG module.
Main entry points: views.py Request handler · rag_logic.py Vector candidate search · config/urls.py Django routing · core/urls.py App route
Components 18
Web interaction
- Django routing
config/urls.py - App route
core/urls.py - Request handler
core/views.py - Upload/question form
core/forms.py - Assistant page
core/templates/core/main_page.html
Document ingestion
- Document parsing
core/rag_logic.py - Sentence segmentation
core/rag_logic.py - Sentence windows
core/rag_logic.py - Sentence embeddings
core/rag_logic.py - Chunk indexing
core/rag_logic.py
Retrieval and generation
- Vector candidate search
core/rag_logic.py - Cross-encoder reranker
core/rag_logic.py - Context windows
core/rag_logic.py - Grounded prompt
core/rag_logic.py - Local Qwen generation
core/rag_logic.py
Persistent state
- ChromaDB collection
chroma_db - Active document session
core/views.py
Other components
- User
Connections 22
- User → Django routing: opens app
README.md - Django routing → App route: includes routes
config/urls.py - App route → Request handler: routes request
core/urls.py - Request handler → Upload/question form: validates input
core/views.py - Request handler → Active document session: reads and updates
core/views.py - Request handler → Document parsing: processes upload
core/views.py - Document parsing → Sentence segmentation: segments text
core/rag_logic.py - Sentence segmentation → Sentence windows: forms windows
core/rag_logic.py - Request handler → Chunk indexing: indexes chunks
core/views.py - Sentence windows → Chunk indexing: provides chunks
core/rag_logic.py - Chunk indexing → Sentence embeddings: encodes sentences
core/rag_logic.py - Chunk indexing → ChromaDB collection: writes vectors
core/rag_logic.py - Request handler → Vector candidate search: searches question
core/views.py - Vector candidate search → Sentence embeddings: encodes query
core/rag_logic.py - Vector candidate search → ChromaDB collection: queries candidates
core/rag_logic.py - Vector candidate search → Cross-encoder reranker: ranks candidates
core/rag_logic.py - Cross-encoder reranker → Context windows: selects windows
core/rag_logic.py - Request handler → Grounded prompt: builds answer context
core/views.py - Context windows → Grounded prompt: supplies context
core/rag_logic.py - Grounded prompt → Local Qwen generation: generates answer
core/rag_logic.py - Request handler → Assistant page: renders answer
core/views.py - Context windows → Assistant page: displays retrieved context
README.md