System design

Architecture

A map of the frontend, backend, ingestion, retrieval, and analytics pieces.

Stack

Next.js App Router

Public landing, docs, auth screens, the protected dashboard, and route handlers.

Convex

Database, server functions, auth integration, background OCR jobs, and the chat HTTP action.

Clerk

Google and GitHub authentication for protected dashboard access.

AI services

OpenAI powers embeddings and answers. Mistral OCR 4 handles OCR.

System map

The Next.js client subscribes to Convex queries and posts to a Convex HTTP action for streaming chat. Convex owns the database and calls external services — OpenAI and Mistral OCR — from server functions and scheduled jobs. Uploaded PDFs and OCR artifacts stay in Convex file storage.

Rendering diagram…
Services and how they connect. Convex is the hub; external AI and storage are called from the backend, never the browser.

Document flow

  1. 01User uploads a PDFThe dashboard stores the file in Convex file storage and creates the document record.
  2. 02Background processing startsA Convex action runs OCR, chunking, embeddings, and summaries, with automatic retries.
  3. 03Chunks become searchablePage-aware chunks are stored with embeddings and a full-text index for retrieval and citations.

Chat flow

Chat runs through a Convex HTTP action that verifies the session, routes the question, retrieves evidence, and streams a structured answer back over Server-Sent Events.

Rendering diagram…
A single chat request, end to end. Tokens stream to the UI while citations are validated and saved.