How sanathhh05/ai_knowledge_agent works
RAMBO lets authenticated users build a private knowledge base from files, web pages, and YouTube videos, then ask questions in text or voice and receive cited answers. Ingestion extracts and chunks content, embeds it, and stores it for user-scoped retrieval; chat combines retrieved context with conversation history for local-model generation. The graph includes authentication, source ingestion, retrieval, chat, and frontend interaction. Some subsystem wiring is documented in the README or SOURCE INDEX rather than shown in excerpts; unsampled links are omitted where ownership is unclear.
Main entry points: database.py Database sessions · ingestion_service.py Ingestion orchestration · page.tsx Chat page · auth.py Auth endpoints
Components 25
User interface
- Chat page
frontend/app/chat/page.tsx - Chat API client
frontend/lib/api/chat.ts - Chat components
frontend/components/Chat/MessageBubble.tsx - Sources page
frontend/app/sources/page.tsx
Authentication
- Auth endpoints
backend/app/routers/auth.py - JWT and password security
backend/app/utils/security.py
Source ingestion
- Source endpoints
backend/app/routers/sources.py - Ingestion orchestration
backend/app/services/ingestion_service.py - Format extractors
backend/app/services/pdf_service.py - Text chunking
backend/app/services/chunking_service.py - Embedding service
backend/app/services/embedding_service.py
Retrieval and chat
- Conversation endpoints
backend/app/routers/conversations.py - Speech transcription
backend/app/services/stt_service.py - RAG orchestration
backend/app/services/rag_service.py - Vector search
backend/app/services/vector_search_service.py - Answer generation
backend/app/services/llm_service.py
Data persistence
- Database sessions
backend/app/database.py - User records
backend/app/models/user.py - Source records
backend/app/models/source.py - Chunk records
backend/app/models/chunk.py - Conversation records
backend/app/models/chat.py
Other components
- User
- PostgreSQL and pgvector
- Ollama local models
- Browser speech APIs
Connections 33
- User → Chat page: asks questions
- Chat page → Chat API client: calls
frontend/app/chat/page.tsx - Chat page → Chat components: renders
frontend/app/chat/page.tsx - Chat API client → Conversation endpoints: sends requests
frontend/lib/api/chat.ts - User → Sources page: adds sources
- User → Auth endpoints: signs in
- Auth endpoints → JWT and password security: hashes and signs
backend/app/routers/auth.py - Auth endpoints → User records: reads and writes
backend/app/routers/auth.py - Auth endpoints → Database sessions: gets session
backend/app/routers/auth.py - Source endpoints → Ingestion orchestration: invokes ingestion
backend/app/routers/sources.py - Ingestion orchestration → Format extractors: dispatches extraction
backend/app/services/ingestion_service.py - Ingestion orchestration → Text chunking: chunks text
backend/app/services/ingestion_service.py - Ingestion orchestration → Embedding service: embeds chunks
backend/app/services/ingestion_service.py - Ingestion orchestration → Source records: creates and updates
backend/app/services/ingestion_service.py - Ingestion orchestration → Chunk records: stores chunks
backend/app/services/ingestion_service.py - Embedding service → Ollama local models: requests vectors
backend/app/services/embedding_service.py - Source endpoints → Database sessions: gets session
backend/app/routers/sources.py - Conversation endpoints → Speech transcription: transcribes audio
backend/app/routers/conversations.py - Conversation endpoints → RAG orchestration: processes turn
backend/app/routers/conversations.py - Conversation endpoints → Database sessions: gets session
backend/app/routers/conversations.py - RAG orchestration → Vector search: retrieves chunks
backend/app/services/rag_service.py - RAG orchestration → Answer generation: generates answer
backend/app/services/rag_service.py - RAG orchestration → Conversation records: stores messages
backend/app/services/rag_service.py - Vector search → Embedding service: embeds query
backend/app/services/vector_search_service.py - Vector search → Chunk records: queries chunks
backend/app/services/vector_search_service.py - Vector search → Source records: joins sources
backend/app/services/vector_search_service.py - Answer generation → Ollama local models: requests generation
backend/app/services/llm_service.py - Database sessions → PostgreSQL and pgvector: connects to
backend/app/database.py - User records → Database sessions: persists in
backend/app/models/user.py - Source records → Database sessions: persists in
backend/app/models/source.py - Chunk records → Database sessions: persists in
backend/app/models/chunk.py - Conversation records → Database sessions: persists in
backend/app/models/chat.py - Chat page → Browser speech APIs: records and plays audio