How marcominerva/sqldatabasevectorsearch works
Main components
• User Interface / Web Frontend: Represented by the Blazor Web App components (under Components, Pages, Layout, etc.). This handles user interactions (document uploads, asking questions, etc.).
• API Endpoints: The Minimal API endpoints (AskEndpoints.cs, DocumentEndpoints.cs) that allow external systems to interact with the application.
• Data Access Layer: Uses Entity Framework Core to interact with the underlying Azure SQL Database. This includes the ApplicationDbContext, entity definitions (Document, DocumentChunk, etc.) and database migration files.
• Services: Core business logic is provided by services such as ChatService, DocumentService, TokenizerService, and VectorSearchService. They handle embedding generation, performing vector searches, tokenization, and chat completions.
• Content Handling Modules: ContentDecoders for processing different file types (PDF, DOCX, TXT) and TextChunkers for segmenting file content.
• Configuration & Settings: Managed through various appsettings.json files and Settings classes (e.g., AppSettings, AzureOpenAISettings) that hold connection strings, OpenAI configuration, and vector dimensions.
• External Dependencies: Azure SQL Database for storage, EFCore.SqlServer.VectorSearch library for vector search integration, and Semantic Kernel for interacting with Azure OpenAI services.
Relationships and interactions
• The Web App and API endpoints serve as the entry points for user actions and programmatic calls.
• Requests from the client trigger calls to the backend services (e.g., DocumentService for importing documents or ChatService for answering questions).
• These services interact with the Data Access Layer to store or retrieve data. There’s a bidirectional flow: read/write operations between the EF Core context and the database.
• The embedding and vector search capabilities (via VectorSearchService) further integrate with Azure OpenAI through Semantic Kernel and also rely on properly structured vector data stored in the database.
• Content decoders and text chunkers are used in preprocessing to extract and prepare data before further processing by the embedding service.
Important architectural patterns and design principles
• Separation of concerns: The project distinctly separates the UI layer, API layer, business logic (services), data access, and content processing modules.
• Modular design: Individual components like content decoders and text chunkers can be swapped or extended, highlighting flexibility.
• Use of Entity Framework Core for ORM and migrations ensuring data and model consistency.
• Integration of external libraries such as EFCore.SqlServer.VectorSearch and Semantic Kernel, emphasizing extensibility.
• Blazor-based frontend supports a more interactive web application experience, while the minimal API provides programmatic access.
Relevant technologies, frameworks, and libraries
• Blazor for the front end.
• ASP.NET Core Minimal API for backend HTTP-based interactions.
• Entity Framework Core with SQL Server and vector support libraries.
• Azure SQL Database as the data store.
• Semantic Kernel (for OpenAI integration).
• Use of standard .NET practices (dependency injection, configuration files).
Elements
• Components: Frontend (Blazor Web App), API Endpoints, Core Services, Data Access Layer, Database (Azure SQL Database).
• Flow paths for both document ingestion and the chat/QA features, including response streaming.
• Notes for components with special configuration or external dependency requirements, like the settings for embedding dimensions and SQL column sizes.