DocsRetriever
An authenticated document workspace with vector retrieval and streamed answers.
- Authenticate. NextAuth obtains an OIDC token; NestJS validates its RS256 signature through Keycloak JWKS.
- Embed the question. NestJS calls FastAPI
/search/embed, which delegates to OpenAI embeddings. - Retrieve context. MongoDB vector search evaluates 100 candidates and returns the top 10 content records.
- Create a session. NestJS sends the question and retrieved text/link/table content to FastAPI, which stores it under a UUID in memory.
- Stream the answer. The browser connects through authenticated SSE; FastAPI streams model chunks through NestJS to the UI.
Problem
Project brief
Help teams organise internal documents and retrieve relevant passages before generating an answer.
Contribution
Role and scope
Owned product design, application architecture, full-stack development and deployment.
Next.js · NestJS · FastAPI · MongoDB · Keycloak · OpenAI
Implementation
Key technical decisions
- Used NestJS as the authenticated application and orchestration boundary, backed by Keycloak and MongoDB.
- Separated embeddings and streaming model calls into a FastAPI service using LangChain and OpenAI adapters.
- Stored 1536-dimensional vectors with content records and queried a MongoDB cosine index using 100 candidates and a top-10 result limit.
Constraints
Engineering constraints
- Keep authentication separate from application logic through OpenID Connect and validated RS256 access tokens.
- Coordinate TypeScript application services with a dedicated Python GenAI runtime.
- Stream generated answers without holding a long synchronous browser request open.
Outcome
Result
The completed application combined authenticated workspaces, top-10 vector retrieval and SSE answer streaming. The service is now offline.