How ramadan-swe/ai-knowledge-assistant works
AI Knowledge Assistant is a document-grounded Q&A product. Users sign in, upload documents, and ask questions; the backend stores document metadata and chunks, indexes text in a per-user vector collection, then retrieves context and generates an answer asynchronously for chat history. The graph includes authentication, document management, chat/RAG, persistence, and the web interface. README statements establish the broad frontend-to-API and async workflow; source excerpts show backend calls and storage operations. Some frontend component wiring and external service configuration are not visible in the sampled source.
Main entry points: database.py Database sessions · retrieval.py RAG processing · api.ts HTTP client · page.tsx Chat page
Components 24
Web application
- Login page
frontend/app/login/page.tsx - Chat page
frontend/app/chat/page.tsx - File upload
frontend/components/FileUpload.tsx - Document list
frontend/components/DocumentList.tsx - Chat interface
frontend/components/ChatUI.tsx - Chat sidebar
frontend/components/Sidebar.tsx - HTTP client
frontend/lib/api.ts
Identity and API
- API application
backend/app/main.py - Route registry
backend/app/api/api.py - Authentication
backend/app/api/endpoints/auth.py - Token verification
backend/app/api/deps.py - JWT and passwords
backend/app/core/security.py
Knowledge ingestion
- Document endpoints
backend/app/api/endpoints/documents.py - PDF ingestion
backend/app/services/ingestion.py
Chat and retrieval
- Chat endpoints
backend/app/api/endpoints/chat.py - RAG processing
backend/app/services/retrieval.py
Persistence and AI
- Runtime settings
backend/app/core/config.py - Database sessions
backend/app/core/database.py - User records
backend/app/models/user.py - Document chunks
backend/app/models/document.py - Chat records
backend/app/models/chat.py - Chroma vectors
- LLM provider
Other components
- User
Connections 33
- User → Login page: signs in
- User → File upload: uploads files
- User → Chat page: asks questions
- Login page → HTTP client: requests API
- File upload → HTTP client: sends upload
- Chat page → Chat interface: presents chat
- Chat page → Chat sidebar: shows history
- Chat page → HTTP client: requests API
- Document list → HTTP client: requests API
- HTTP client → API application: HTTP requests
- API application → Route registry: mounts routes
backend/app/main.py - Route registry → Authentication: registers routes
backend/app/api/api.py - Route registry → Document endpoints: registers routes
backend/app/api/api.py - Route registry → Chat endpoints: registers routes
backend/app/api/api.py - Authentication → JWT and passwords: hashes and signs
backend/app/api/endpoints/auth.py - Authentication → Token verification: checks current user
backend/app/api/endpoints/auth.py - Token verification → JWT and passwords: decodes token
backend/app/api/deps.py - Token verification → User records: looks up user
backend/app/api/deps.py - Document endpoints → PDF ingestion: processes upload
backend/app/api/endpoints/documents.py - PDF ingestion → Document chunks: saves documents
backend/app/services/ingestion.py - PDF ingestion → Chroma vectors: stores embeddings
backend/app/services/ingestion.py - Chat endpoints → RAG processing: creates and processes prompts
backend/app/api/endpoints/chat.py - RAG processing → Chroma vectors: retrieves context
backend/app/services/retrieval.py - RAG processing → LLM provider: generates answer
backend/app/services/retrieval.py - RAG processing → Chat records: updates prompt status
backend/app/services/retrieval.py - Authentication → Database sessions: uses sessions
backend/app/api/endpoints/auth.py - Document endpoints → Database sessions: uses sessions
backend/app/api/endpoints/documents.py - RAG processing → Database sessions: opens background session
backend/app/services/retrieval.py - Database sessions → Runtime settings: loads connection URL
backend/app/core/database.py - User records → Database sessions: maps tables
backend/app/models/user.py - Document chunks → Database sessions: maps tables
backend/app/models/document.py - Chat records → Database sessions: maps tables
backend/app/models/chat.py - RAG processing → LLM provider: selects provider settings
backend/app/services/retrieval.py