All projects

Project 01 / Personal

Cognelle.

Ask a question. Open the page that supports the answer.

I built a self-hosted workspace for streaming chat and document search. Users can connect a model provider, index their library, and open a cited PDF page beside the answer.

My role
Creator and maintainer
Built with
Next.js / TypeScript / AI SDK / PostgreSQL / pgvector / pg-boss / Docker
Status
Open source · Hosted preview

Project in brief

The problem
A chat answer about a document is hard to verify when the source stays hidden.
My contribution
I built the workspace, source ingestion, retrieval, chat streaming, and the PDF citation viewer.
Key decision
Fuse keyword and vector rankings, scope matches to ready documents, and validate references before streaming cited text.
Result
A reader can trace a supported answer to the original PDF page or text passage. The repository includes a self-hosted setup.
Cognelle showing a chat answer with a numbered citation and the matching release checklist PDF open in the Sources panel.
Cognelle Ask with a sample document and deterministic test provider. The Sources panel opens the exact cited PDF page.View full-size Cognelle preview

01

Overview

Cognelle combines everyday chat with a personal document library. Users can chat before importing anything, then ask questions about selected documents or collections when they need source evidence.

Chat should work with an empty library. When someone asks about an indexed source, the answer should trace back to eligible passages and communicate when evidence is missing.

02

My work

I built the Next.js workspace and its backend, including provider settings, ingestion, retrieval, the Sources panel, and Docker Compose delivery.

  • Built the Library and Collections UI, a background worker for document imports, and a Sources panel that opens the cited page or passage.
  • Added streaming chat with user-connected providers and General, Auto, and Knowledge modes. Chat and embedding models can be configured independently.
  • Built a retrieval lab for comparing semantic, keyword, and hybrid results against an indexed source set.

03

Technical decisions

A pg-boss worker extracts and embeds passages before publishing a ready document version. PostgreSQL full-text search and pgvector rank candidates. The AI SDK streams answers, and the Sources panel resolves validated references to a PDF page or extracted text.

  • Combined full-text and vector ranks with reciprocal rank fusion so exact terms and semantic matches can both surface.
  • Validated server-issued citation references before streaming grounded paragraphs. Knowledge mode abstains when it finds no eligible support.
  • Published indexed document versions atomically so retrieval only sees complete, ready sources.

04

Scope & status

Testing and validation

The repository documents PostgreSQL integration and browser tests for imports, retrieval, and exact PDF-page citations using a deterministic provider. A separate live Gemini smoke exercised indexing and a persisted cited answer.

Public source, a Docker Compose setup, and a hosted sign-up preview are available.

  • Hosted chat and indexing require a configured model and embedding provider. The selected provider receives the context needed for the request.
  • Reference validation checks that a citation points to eligible material. Readers still need to check whether the passage supports the answer.

What I learned

Keep source access explicit through indexing, retrieval, and citation rendering.

Give readers the original passage so they can check how an answer uses it.

Next projectCutroom