cb4b7d0052e0c641ae57f3cb98d60764a9e98195
This Pull Request implements the complete **Retrieval module (Read Path)** for the Knowledge-Map RAG (KM-RAG) architecture within the NexusReader platform. It resolves all requirements for vector-based semantic search, Neo4j graph context expansion, structured grounding with Google Gemini, API/Wasm integration, and an interactive front-end global Q&A panel. Resolves #48 ### 🚀 Key Implementations 1. **Grounded DTOs & Schema Definition** - Added `GroundedResponseDto` and `CitationDto` for strict JSON Schema matching with Gemini. 2. **Core Service & Read Path Logic** - Implemented the robust **5-step pipeline** in `KnowledgeService.AskQuestionAsync`: 1. *Embedding*: Query vectorization using `IEmbeddingGenerator`. 2. *Semantic Search*: Multi-tenant vector search with Qdrant, supporting scoping to a specific book or global search. 3. *Graph Expansion*: Fetching connected concepts and parent relationships using Neo4j Cypher. 4. *Citation Hydration*: Cross-referencing results with PostgreSQL to fetch book titles and accurate chapter citations. 5. *Grounded Generation*: Strict structured generation via `IChatClient` (Gemini) preventing hallucinations and using citations. 3. **CQRS & Endpoints** - Added `AskLibraryQuestionQuery` and its handler. - Mapped `/api/knowledge/ask` and `/api/knowledge/search` endpoints inside `Program.cs`. - Updated `WasmKnowledgeService` to support proxying retrieval requests. 4. **Premium Blazor UI Panel** - Implemented `/intelligence` (Global AI Q&A) with a curated HSL palette, dark theme, smooth micro-animations, loading shimmers, and side-by-side citation cards. - Registered the panel within the `MainHubLayout` sidebar. 5. **Test Coverage** - Wrote comprehensive xUnit tests in `QueryTests.cs` using Moq and FluentAssertions to assert that handlers correctly validate input and interact with services. ### 🧪 Verification - Verified compilation and build gate successfully (`dotnet build`: 0 errors). - All 7 tests passed perfectly (`dotnet test`). --------- Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Reviewed-on: #49 Reviewed-by: Marek Jaisński <jasins.marek@gmail.com> Co-authored-by: Antigravity <antigravity@google.com> Co-committed-by: Antigravity <antigravity@google.com>
feat(ai-ux): deduplicate AI queries, handle ServiceUnavailable retries, and optimize reader canvas graph prerendering (#44)
feat(ai-ux): deduplicate AI queries, handle ServiceUnavailable retries, and optimize reader canvas graph prerendering (#44)
📖 Nexus Reader
Nexus Reader is a state-of-the-art, cross-platform Blazor .NET 10 immersive e-book reader, powered by Native AOT, Clean Architecture, CQRS, and interactive D3.js Relationship Graphs built on vector-based AI semantics.
✨ Features & Architecture Highlights
📁 Ingestion & Description persistence
- Extracted and persistent book descriptions from EPUB package metadata during book ingestion.
- The
Descriptionfield propagates cleanly from theEbookentity through Mapster toLastReadBookDtoandUserProfileDto.
🔗 Deep-Link Routing
- Implemented deep-link route activation:
/reader/{bookId}?chapter=N. - Allows instant resume of reading session coordinates and loads the specific chapter chapter directly via URL query parameters.
🛡️ Downstream AI Resilience
- Standard resilience engine in
DependencyInjection.csutilizing the Polly package (ai-retry). - Automatically intercepts, handles, and retries on both rate-limits (
429 Too Many Requests) and downstream capacity overloads (503 ServiceUnavailable/high demand).
⚙️ Concurrent Request Deduplication
- Multi-client InteractiveAuto Blazor circuit synchronization is backed by a thread-safe active task registry in
KnowledgeServicewhich ensures that identical concurrent requests await a single shared task instance, eliminating redundant LLM queries.
🛠️ Build & Verification Gate
Ensure the dotnet workload matches the active SDK, and compile the full solution utilizing:
dotnet build NexusReader.slnx --no-restore
Run test suite:
dotnet test --no-restore
Description
Languages
C#
46.2%
HTML
25.8%
CSS
23%
JavaScript
4.1%
Shell
0.8%
Other
0.1%