Files
Nexus.Reader/docker-compose.yml
Antigravity cb4b7d0052 feat(rag): implement KM-RAG retrieval read-path, API endpoints, global Q&A UI, and unit tests (#49)
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>
2026-05-20 18:29:15 +00:00

76 lines
1.9 KiB
YAML

services:
db:
image: pgvector/pgvector:pg17
container_name: nexus-db
environment:
POSTGRES_USER: nexus_user
POSTGRES_PASSWORD: nexus_password
POSTGRES_DB: nexus_db
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U nexus_user -d nexus_db"]
interval: 5s
timeout: 5s
retries: 5
web:
build:
context: .
dockerfile: Dockerfile
container_name: nexus-web
ports:
- "5000:5000"
environment:
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__PostgresConnection=Host=db;Database=nexus_db;Username=nexus_user;Password=nexus_password
- ConnectionStrings__QdrantConnection=Host=qdrant;Port=6334
- ConnectionStrings__Neo4jConnection=bolt://neo4j:7687
- Authentication__Google__ClientId=${GOOGLE_CLIENT_ID:-placeholder}
- Authentication__Google__ClientSecret=${GOOGLE_CLIENT_SECRET:-placeholder}
- Ai__Google__ApiKey=${GOOGLE_AI_API_KEY:-placeholder}
depends_on:
db:
condition: service_healthy
qdrant:
condition: service_healthy
neo4j:
condition: service_healthy
qdrant:
image: qdrant/qdrant:latest
container_name: nexus-qdrant
ports:
- "6333:6333"
- "6334:6334"
volumes:
- qdrant_data:/qdrant/storage
healthcheck:
test: ["CMD-SHELL", "bash -c 'exec 3<>/dev/tcp/127.0.0.1/6333'"]
interval: 5s
timeout: 5s
retries: 5
neo4j:
image: neo4j:5-community
container_name: nexus-neo4j
ports:
- "7474:7474"
- "7687:7687"
environment:
- NEO4J_AUTH=none
volumes:
- neo4j_data:/data
healthcheck:
test: ["CMD-SHELL", "cypher-shell -u neo4j -p '' 'RETURN 1' || exit 0"]
interval: 5s
timeout: 5s
retries: 5
volumes:
pgdata:
qdrant_data:
neo4j_data: