Skip to content

All work / Personal

Notee AI document assistant built with Next.js and LangChain

An AI assistant for your own documents: upload sources, then ask across them in threads.

What it does

Each chat in Notee has its own sources: you attach PDFs to it, then ask questions in Arabic or English. For every question, an agent decides whether to search those PDFs or the web, and answers from what it finds. It is a personal project; I built both the Next.js front end and the Strapi back end.

How a question gets answered

When a chat's sources change, its PDFs are split into 500-character chunks with a 50-character overlap, embedded with OpenAI's text-embedding-3-small and stored in a Redis vector index that belongs to that chat alone. A LangChain tools agent then has two tools: retrieval over that index, returning the three closest chunks, and Tavily web search. Each chat's history is kept in Redis for seven days, and the reply streams to the browser as it is generated.

Decisions behind it

The index is rebuilt only when a chat's list of sources actually changes: the source URLs are stored beside it and compared on each request, so asking a question never re-embeds the same files. The model sits behind an OpenAI-compatible endpoint, OpenRouter by default, so it can be swapped through configuration. Temperature is set to 0 because tool calls are more reliable that way, and the agent stops after six steps at most.

Front end and back end

The API is Strapi 5 in TypeScript, with custom routes to add and remove a chat's sources, read its messages and stream a reply. Sign-in goes through Strapi's users and permissions, Google included. The front end uses the Next.js App Router with TanStack Query, React Hook Form and Zod, shadcn/ui components, and renders answers as Markdown. Redis Stack, which provides the vector search, runs from a Docker Compose file.

More work

Esc

↑↓ to move · Enter to open · Esc to close