ScanX - AI Note Taker
ScanX is an AI note-taking web app built with Next.js, Convex and LangChain. Users upload a PDF, the text is chunked and embedded into a vector index, and a retrieval-augmented chat answers questions against that document with citations back to the source pages.
- Role
- Sole developer — architecture, retrieval pipeline, UI and deployment.
- Year
- 2025
- Stack
- Next.js, Clerk, Shadcn, Langchain, Convex DB, Tailwind CSS
The problem
Reading a long PDF to find three facts is wasted time, but a plain chatbot given a whole document either exceeds the context window or hallucinates. The product needed answers grounded in the actual uploaded file, with the source visible so a reader could verify each claim.
How it was built
01Document ingestion and chunking
Uploaded PDFs are parsed, split into overlapping chunks sized to keep semantic units intact, and embedded. Overlap matters: splitting purely on a character count cuts sentences in half and produces embeddings that retrieve badly. Each chunk keeps a reference to its source page so answers can cite it.
02Retrieval-augmented generation
A question is embedded and matched against the stored vectors, and only the top-matching chunks are passed to the model as context. This keeps token cost proportional to the question rather than the document, and it is what makes answers verifiable — the model is reasoning over retrieved text, not recalling from training.
03Real-time state with Convex
Convex holds documents, chunks and chat history, and pushes updates to the client reactively. Ingestion progress and streamed answers appear without polling, which matters because embedding a large PDF is slow enough that a silent UI reads as broken.
04Auth and access boundaries
Clerk handles authentication, and every query is scoped to the owning user so one account cannot retrieve another's document chunks. On a RAG product this is a data-isolation requirement, not a nice-to-have: the retrieval layer will happily return any vector it can reach.
Stack decisions
Why each piece was chosen, rather than just what was used.
Next.js
Server components keep the API keys and the retrieval call server-side, so no model credential is ever shipped to the browser. Streaming responses are a first-class primitive, which a chat interface needs.
Convex
Reactive queries remove the polling layer a document-processing pipeline would otherwise need, and it stores the vectors alongside the application data instead of requiring a separate vector database for a project at this scale.
LangChain
Handles the loader, splitter and retriever plumbing so the work goes into chunking strategy and prompt design rather than re-implementing document parsing.
Clerk
Managed auth with organisation support, avoiding a hand-rolled session layer on a product where the access boundary protects user documents.
Tailwind CSS + shadcn/ui
Accessible primitives with keyboard and focus behaviour already correct, styled to the product rather than inherited from a component library's opinions.
What it does
- PDF upload with parsing and chunked embedding
- Retrieval-augmented chat with citations to source pages
- Streamed responses rather than a blocking spinner
- Per-user document isolation enforced at the query layer
- Context-aware summarisation of long documents
- Reactive ingestion progress with no client polling
Questions this raises
How do you stop an AI document chat from hallucinating?
Ground it with retrieval instead of context-stuffing. Embed the document in chunks, retrieve only the passages that match the question, and pass those as context with an instruction to answer only from them. Then cite the source page so the reader can verify. Hallucination usually means the model was asked to recall rather than to read.
Do you need a dedicated vector database for RAG?
Not at this scale. Convex stores the vectors next to the application data, which removes an entire service from the deployment. A dedicated vector store earns its place when the index grows past what a general-purpose database serves quickly, or when you need specialised filtering and hybrid search.
Related work
Building something similar?
Naman Gundaniya takes on full stack and AI projects like this one. Available for hire, replies within 24 hours.