How binapani/llm-chat-api works
LLM Chat API is a local, SQLite-backed RAG and agent application. Users can upload documents for extraction and ingestion, then query them through grounded RAG or agent tool use; separate endpoints expose chat, hybrid/BM25 search, and retrieval evaluation. The sampled code establishes the main ingestion, retrieval, and generation calls. Agent internals, document extraction/repository behavior, and some persistence wiring are unsampled, so those relationships are shown only when documented or left unconnected. Planned roadmap capabilities are excluded.
Main entry points: ChatController.cs Chat endpoints · VectorDbContext.cs SQLite context · RAGService.cs RAG pipeline · EmbeddingService.cs Embedding service
Components 24
API entry points
- Chat endpoints
src/LLMChat.Api/Controllers/ChatController.cs - Document endpoints
src/LLMChat.Api/Controllers/DocumentsController.cs - BM25 endpoint
src/LLMChat.Api/Controllers/Bm25Controller.cs
Knowledge ingestion
- Ingestion pipeline
src/LLMChat.Api/Services/DocumentIngestionService.cs - Text extraction
src/LLMChat.Api/Services/DocumentTextExtractorResolver.cs - Chunking
src/LLMChat.Api/Services/DocumentChunker.cs - Embedding service
src/LLMChat.Api/Services/EmbeddingService.cs - Document repository
src/LLMChat.Api/Services/SQLiteDocumentRepository.cs
Retrieval and RAG
- RAG pipeline
src/LLMChat.Api/Services/RAGService.cs - Vector search
src/LLMChat.Api/Services/SQLiteVectorStore.cs - BM25 search
src/LLMChat.Api/Services/SQLiteBm25SearchService.cs - Hybrid search
src/LLMChat.Api/Services/HybridSearchService.cs - Reranking
src/LLMChat.Api/Services/HybridRerankerService.cs - RAG evaluation
src/LLMChat.Api/Services/RAGEvaluationService.cs - LLM service
src/LLMChat.Api/Services/LLMService.cs
Agent and memory
- Agent orchestration
src/LLMChat.Api/Services/AgentService.cs - Agent tools
src/LLMChat.Api/Services/AgentTools.cs - Conversation memory
src/LLMChat.Api/Services/EfConversationMemoryService.cs
Models and persistence
- SQLite context
src/LLMChat.Api/Data/VectorDbContext.cs - Document records
src/LLMChat.Api/Data/Entities/DocumentEntity.cs - Vector records
src/LLMChat.Api/Data/Entities/DocumentVectorEntity.cs - Conversation records
src/LLMChat.Api/Data/Entities/ConversationSessionEntity.cs
Other components
- User
- Ollama
Connections 40
- User → Chat endpoints: sends query
src/LLMChat.Api/Controllers/ChatController.cs - User → Document endpoints: uploads documents
src/LLMChat.Api/Controllers/DocumentsController.cs - User → BM25 endpoint: submits query
src/LLMChat.Api/Controllers/Bm25Controller.cs - Document endpoints → Text extraction: resolves extractor
src/LLMChat.Api/Controllers/DocumentsController.cs - Document endpoints → Ingestion pipeline: ingests content
src/LLMChat.Api/Controllers/DocumentsController.cs - Document endpoints → Document repository: stores metadata
src/LLMChat.Api/Controllers/DocumentsController.cs - Ingestion pipeline → Chunking: chunks content
src/LLMChat.Api/Services/DocumentIngestionService.cs - Ingestion pipeline → Embedding service: embeds chunks
src/LLMChat.Api/Services/DocumentIngestionService.cs - Ingestion pipeline → Vector search: stores vectors
src/LLMChat.Api/Services/DocumentIngestionService.cs - Chat endpoints → Embedding service: generates embedding
src/LLMChat.Api/Controllers/ChatController.cs - Chat endpoints → Vector search: searches vectors
src/LLMChat.Api/Controllers/ChatController.cs - Chat endpoints → RAG pipeline: requests answer
src/LLMChat.Api/Controllers/ChatController.cs - Chat endpoints → Hybrid search: requests hybrid search
src/LLMChat.Api/Controllers/ChatController.cs - Chat endpoints → RAG evaluation: evaluates retrieval
src/LLMChat.Api/Controllers/ChatController.cs - Chat endpoints → Agent orchestration: runs agent
src/LLMChat.Api/Controllers/ChatController.cs - BM25 endpoint → BM25 search: searches keywords
src/LLMChat.Api/Controllers/Bm25Controller.cs - RAG pipeline → Embedding service: embeds query
src/LLMChat.Api/Services/RAGService.cs - RAG pipeline → Vector search: retrieves candidates
src/LLMChat.Api/Services/RAGService.cs - RAG pipeline → Reranking: reranks candidates
src/LLMChat.Api/Services/RAGService.cs - RAG pipeline → LLM service: generates grounded answer
src/LLMChat.Api/Services/RAGService.cs - Hybrid search → Embedding service: embeds query
src/LLMChat.Api/Services/HybridSearchService.cs - Hybrid search → Vector search: gets dense candidates
src/LLMChat.Api/Services/HybridSearchService.cs - Hybrid search → BM25 search: gets keyword candidates
src/LLMChat.Api/Services/HybridSearchService.cs - Hybrid search → Reranking: reranks merged results
- RAG evaluation → Embedding service: embeds questions
src/LLMChat.Api/Services/RAGEvaluationService.cs - RAG evaluation → Vector search: retrieves candidates
src/LLMChat.Api/Services/RAGEvaluationService.cs - RAG evaluation → Reranking: scores candidates
src/LLMChat.Api/Services/RAGEvaluationService.cs - Embedding service → Ollama: requests embeddings
- LLM service → Ollama: requests generation
src/LLMChat.Api/Services/LLMService.cs - Agent orchestration → Agent tools: dispatches tools
- Agent orchestration → Conversation memory: uses session memory
- Agent tools → RAG pipeline: searches knowledge
- Agent orchestration → Ollama: uses model
- SQLite context → Document records: maps entity
src/LLMChat.Api/Data/VectorDbContext.cs - SQLite context → Vector records: maps entity
src/LLMChat.Api/Data/VectorDbContext.cs - SQLite context → Conversation records: maps entity
src/LLMChat.Api/Data/VectorDbContext.cs - Vector search → SQLite context: persists vectors
- BM25 search → SQLite context: reads vectors
src/LLMChat.Api/Services/SQLiteBm25SearchService.cs - Document repository → SQLite context: persists metadata
- Conversation memory → SQLite context: persists messages