How ayoubdammaq/enterprise-ai-assistant works
This is the backend of an enterprise AI assistant. Authenticated users can chat normally or ask document-grounded questions: the API delegates to chat/RAG services, which retrieve and screen document chunks before generating an answer with sources. A separate hosted indexing path loads and indexes documents. Authentication issues and refreshes JWTs; chat also supports memory and model tools. The source excerpts establish these principal calls, but leave much indexing and storage implementation detail unsampled.
Main entry points: SemanticKernelChatService.cs AI chat service · RagService.cs RAG orchestration · AuthService.cs Auth service · ChatController.cs Chat endpoints
Components 23
API and identity
- Auth endpoints
backend/src/EnterpriseAIAssistant.API/Controllers/AuthController.cs - Auth service
backend/src/EnterpriseAIAssistant.Infrastructure/Identity/AuthService.cs - JWT tokens
backend/src/EnterpriseAIAssistant.Infrastructure/Identity/JwtTokenService.cs - Identity database
backend/src/EnterpriseAIAssistant.Infrastructure/Identity/AuthDbContext.cs
Assistant and memory
- Chat endpoints
backend/src/EnterpriseAIAssistant.API/Controllers/ChatController.cs - RAG orchestration
backend/src/EnterpriseAIAssistant.Application/Services/RagService.cs - AI chat service
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - RAG prompt builder
backend/src/EnterpriseAIAssistant.Infrastructure/AI/RagPromptBuilder.cs - Memory service
backend/src/EnterpriseAIAssistant.Infrastructure/Memory/InMemoryMemoryService.cs - Memory user context
backend/src/EnterpriseAIAssistant.Infrastructure/Memory/MemoryUserContext.cs - Memory plugin
backend/src/EnterpriseAIAssistant.Infrastructure/Memory/MemoryPlugin.cs - Calculator tool
backend/src/EnterpriseAIAssistant.Infrastructure/AI/Plugins/CalculatorPlugin.cs - Date/time tool
backend/src/EnterpriseAIAssistant.Infrastructure/AI/Plugins/DateTimePlugin.cs
Knowledge and retrieval
- Knowledge retriever
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/KnowledgeRetriever.cs - Context evaluator
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelContextRelevanceEvaluator.cs - Indexing host
backend/src/EnterpriseAIAssistant.API/HostedServices/DocumentIndexingHostedService.cs - Document loader
backend/src/EnterpriseAIAssistant.Infrastructure/Documents/FileSystemDocumentLoader.cs - Text chunking
backend/src/EnterpriseAIAssistant.Infrastructure/Documents/TextChunker.cs - Knowledge indexer
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/KnowledgeIndexer.cs
Infrastructure providers
- Ollama embeddings
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/OllamaEmbeddingService.cs - Vector store
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/InMemoryVectorStore.cs
Other components
- User
- Ollama service
Connections 24
- User → Auth endpoints: registers or signs in
backend/src/EnterpriseAIAssistant.API/Controllers/AuthController.cs - Auth endpoints → Auth service: delegates auth
backend/src/EnterpriseAIAssistant.API/Controllers/AuthController.cs - Auth service → JWT tokens: creates tokens
backend/src/EnterpriseAIAssistant.Infrastructure/Identity/AuthService.cs - Auth service → Identity database: reads and writes
backend/src/EnterpriseAIAssistant.Infrastructure/Identity/AuthService.cs - User → Chat endpoints: sends chat request
backend/src/EnterpriseAIAssistant.API/Controllers/ChatController.cs - Chat endpoints → AI chat service: generates response
backend/src/EnterpriseAIAssistant.API/Controllers/ChatController.cs - Chat endpoints → RAG orchestration: asks with RAG
backend/src/EnterpriseAIAssistant.API/Controllers/ChatController.cs - RAG orchestration → Knowledge retriever: searches chunks
backend/src/EnterpriseAIAssistant.Application/Services/RagService.cs - RAG orchestration → Context evaluator: checks sufficiency
backend/src/EnterpriseAIAssistant.Application/Services/RagService.cs - RAG orchestration → AI chat service: generates grounded answer
backend/src/EnterpriseAIAssistant.Application/Services/RagService.cs - AI chat service → RAG prompt builder: builds RAG prompt
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - AI chat service → Memory service: uses memory
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - AI chat service → Memory user context: sets user scope
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - AI chat service → Memory plugin: registers memory tool
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - AI chat service → Calculator tool: registers tool
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - AI chat service → Date/time tool: registers tool
backend/src/EnterpriseAIAssistant.Infrastructure/AI/SemanticKernelChatService.cs - Indexing host → Document loader: loads documents
backend/src/EnterpriseAIAssistant.API/HostedServices/DocumentIndexingHostedService.cs - Indexing host → Knowledge indexer: indexes documents
backend/src/EnterpriseAIAssistant.API/HostedServices/DocumentIndexingHostedService.cs - Knowledge retriever → Ollama embeddings: embeds query
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/KnowledgeRetriever.cs - Knowledge retriever → Vector store: searches vectors
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/KnowledgeRetriever.cs - Ollama embeddings → Ollama service: requests embeddings
backend/src/EnterpriseAIAssistant.Infrastructure/Retrieval/OllamaEmbeddingService.cs - Document loader → Text chunking: chunks text
backend/src/EnterpriseAIAssistant.Infrastructure/Documents/FileSystemDocumentLoader.cs - Knowledge indexer → Ollama embeddings: embeds chunks
- Knowledge indexer → Vector store: stores vectors