How anuj0kumar/personal-ai-rag_fixed works
This is a local, multi-user PDF knowledge-base application. Users register and authenticate, upload PDFs for text extraction and user-scoped indexing, then ask questions answered from retrieved document context and recent chat history; chat is persisted in SQLite. The FastAPI app also serves a web UI. The README documents an abstract vector-store layer, but the sampled vector service calls ChromaDB directly, so no abstraction-to-service call is asserted. Other links reflect shown code or documented capabilities; unsampled wiring is omitted.
Main entry points: database.py SQLAlchemy session · main.py FastAPI application · upload.py Upload route · ai_service.py RAG chat orchestration
Components 21
Application and UI
- Web interface
static/index.html - FastAPI application
app/main.py - Settings
app/core/config.py
Identity and security
- Auth routes
app/api/endpoints/auth.py - JWT dependencies
app/api/deps.py - Password and tokens
app/core/security.py - User model
app/models/user.py
Document ingestion
- Upload route
app/api/endpoints/upload.py - PDF text extraction
app/services/document_service.py - Chunking and retrieval
app/services/vector_service.py - Vector-store abstraction
app/services/vector_store.py - Document DTOs
app/schemas/document.py
Chat and retrieval
- Chat routes
app/api/endpoints/chat.py - RAG chat orchestration
app/services/ai_service.py - Chat DTOs
app/schemas/chat.py
Persistence
- ChromaDB index
- SQLite database
- SQLAlchemy session
app/core/database.py - Chat history model
app/models/chat_history.py
Other components
- User
- Local Ollama models
Connections 34
- User → Web interface: uses
README.md - Web interface → FastAPI application: sends requests
README.md - FastAPI application → Auth routes: registers routes
app/main.py - FastAPI application → Chat routes: registers routes
app/main.py - FastAPI application → Upload route: registers routes
app/main.py - FastAPI application → Web interface: serves files
app/main.py - FastAPI application → SQLAlchemy session: initializes schema
app/main.py - User → Auth routes: registers or logs in
README.md - Auth routes → SQLAlchemy session: queries and writes
app/api/endpoints/auth.py - Auth routes → User model: queries and creates
app/api/endpoints/auth.py - Auth routes → Password and tokens: hashes and verifies
app/api/endpoints/auth.py - Password and tokens → Settings: reads settings
app/core/security.py - JWT dependencies → Settings: reads settings
app/api/deps.py - JWT dependencies → SQLAlchemy session: fetches user
app/api/deps.py - JWT dependencies → User model: queries
app/api/deps.py - Upload route → JWT dependencies: requires identity
app/api/endpoints/upload.py - Upload route → PDF text extraction: extracts text
app/api/endpoints/upload.py - Upload route → Chunking and retrieval: indexes text
app/api/endpoints/upload.py - Upload route → Document DTOs: returns response
app/api/endpoints/upload.py - Chunking and retrieval → Settings: reads index path
app/services/vector_service.py - Chunking and retrieval → ChromaDB index: adds and queries
app/services/vector_service.py - User → Chat routes: asks questions
README.md - Chat routes → JWT dependencies: requires identity
app/api/endpoints/chat.py - Chat routes → RAG chat orchestration: requests response
app/api/endpoints/chat.py - Chat routes → Chat DTOs: validates response
app/api/endpoints/chat.py - RAG chat orchestration → Chunking and retrieval: retrieves context
app/services/ai_service.py - RAG chat orchestration → Chat history model: loads and saves history
app/services/ai_service.py - RAG chat orchestration → Local Ollama models: requests completion
README.md - RAG chat orchestration → Settings: reads model settings
app/services/ai_service.py - Chat history model → SQLAlchemy session: uses ORM base
app/models/chat_history.py - User model → SQLAlchemy session: uses ORM base
app/models/user.py - SQLAlchemy session → Settings: reads database URL
app/core/database.py - SQLAlchemy session → SQLite database: connects to
app/core/database.py - Vector-store abstraction → ChromaDB index: abstracts storage
README.md