Marginalia - Chat With Your Documents - Next.js AI SaaS Template

Marginalia - Chat With Your Documents - AI SaaS template preview

About this template

Marginalia is the complete product UI for a chat-with-your-documents SaaS - the part of a RAG product users actually see. It ships the whole product spine: a marketing landing that demos the citation-linked chat, pricing, login and signup screens, a 3-step onboarding wizard, a gated app shell with sidebar and workspace switcher, a dashboard launcher that turns a question into a cited answer, a document library with an animated ingestion state machine, a source viewer that citations deep-link into, the two-pane citation chat (the signature 'citation-as-source-preview' interaction: hover a citation and a synced source panel scrolls to and highlights the exact passage and page), settings, and billing. It runs zero-config in demo mode: documents, retrieval, and answers come from a seeded sample corpus, ingestion is simulated so you can watch the status transitions, answers are revealed word by word from the demo data, and auth and billing are mocked - so no model is called and no database or API keys are needed. Going live is real backend work that the template documents rather than ships: a six-step guide covers Postgres with pgvector for app data and vectors in one database, ingestion (store, chunk, embed), workspace-scoped retrieval, streaming generation through the Vercel AI Gateway with 'provider/model' strings, and your auth and billing providers - all behind the same typed helper signatures, so the UI doesn't change. The 'Reading Room' design system - warm porcelain neutrals, an espresso-and-sienna palette, and Fraunces editorial serif - reskins from a few CSS variables. Flash-free light and dark mode, fully responsive, strict TypeScript, deterministic SSR (no hydration mismatches), zero backend required to run. Every page type is audited to WCAG 2.2 AA with axe-core in both themes at phone and desktop widths, including text contrast over images and gradients and keyboard focus, and the same check ships with the template as npm run test:a11y.

Who Marginalia - Chat With Your Documents is for

Marginalia is built for founders shipping a RAG product - document Q&A, internal knowledge search, support-ticket lookup - who want the product users see finished: the document library, the citation-linked chat with its synced source panel, onboarding, settings, and billing. It's the product half of a RAG app; the retrieval pipeline is the half you connect.

It's designed for a single-database setup (Postgres + pgvector, so app data and vectors share one connection string) with model calls through the Vercel AI Gateway, so you're not locked into one provider or a second piece of infrastructure. The going-live guide walks through all six steps, and the typed helper signatures mean the UI doesn't change when the real pipeline replaces the demo data.

Zero-config demo mode means you can evaluate the whole product - the citation-linked chat, the ingestion state machine, the source viewer - on a seeded sample corpus before writing a line of integration code. Nothing is faked about the UI; only the data behind it is sample data until you connect your own.

  • Founder building a 'chat with your docs' or internal knowledge-base product
  • Dev agency that needs a finished product UI to put in front of a client's RAG pipeline
  • Team that has a working retrieval prototype and needs the product around it
  • SaaS founder who wants model flexibility (OpenAI, Anthropic, open models) without vendor lock-in

What's included

Complete RAG SaaS product UI: document library, citation-linked chat, onboarding, settings, billing
Citation-as-source-preview: hover a citation to reveal the exact passage
Answers with inline citations that deep-link to the source page
Document library with an animated ingestion state machine (queued -> ready)
Zero-config demo mode: seeded sample corpus, simulated ingestion, no model or database needed
Six-step going-live guide: Postgres + pgvector, ingestion, workspace-scoped retrieval, AI Gateway
Typed helper seams - swap the demo data for your pipeline without changing the UI
Login and signup screens, 3-step onboarding, gated app shell with workspace switcher
Dashboard launcher that turns a question into a cited answer
Billing UI: plans, usage meters, invoices - wire Dodo where marked
'Reading Room' design - porcelain + espresso/sienna, Fraunces serif
Flash-free light and dark mode, fully responsive, strict TypeScript
Audited to WCAG 2.2 AA with axe-core on every page type, in both themes at phone and desktop widths, with menus and panels checked open. The check ships with the template as npm run test:a11y

Pages Included

LandingPricingLoginSignupOnboardingWorkspace overviewDocumentsSource viewerChatSettingsBilling

Common questions about Marginalia - Chat With Your Documents

Does it run a real RAG pipeline out of the box?

No - it runs in demo mode. Documents, retrieval, and answers come from a seeded sample corpus, ingestion is simulated, answers are revealed word by word from the demo data, and auth and billing are mocked, so no model is called and no database or API keys are needed. The database, ingestion, retrieval, generation, auth, and billing are yours to connect; the README's six-step Going live guide covers each one.

Do I need a separate vector database like Pinecone or Weaviate?

No. Marginalia is designed to store embeddings in the same Postgres database as the rest of your app data, using the pgvector extension (Neon is the intended setup). You add that database when you go live - the guide covers enabling pgvector and creating the tables. One connection string, one database to operate and back up.

Which AI models does it support?

Demo mode doesn't call a model. When you go live, the guide routes generation and embeddings through the Vercel AI Gateway using 'provider/model' strings, so any model the Gateway offers - OpenAI, Anthropic, Google, open-weight models - is a config change rather than a code change.

What does demo mode actually do?

It serves a seeded sample corpus so the full product - upload, ingestion status, citation chat, source viewer - runs with zero setup. Demo retrieval is simple keyword scoring over the seeded passages, with the same return shape a pgvector similarity search will have. To go live, you replace the helpers in src/lib/mock-data.ts with your database, ingestion, retrieval, and model calls behind the same signatures.

How does the citation linking actually work?

Each answer carries metadata pointing at the exact source chunk and page it came from. Hovering or clicking a citation opens the source viewer scrolled to that passage - it's wired through React state and the stored chunk offsets, not a separate lookup service. In demo mode that metadata comes with the sample answers; live, your generation step returns it alongside the retrieved chunks.

Can I use this for something other than document Q&A?

Yes. The ask-a-question, get-a-sourced-answer pattern works for support knowledge bases, internal wikis, and research tools. The document library, ingestion status UI, and citation chat are domain-agnostic; only the seeded demo corpus assumes documents.

Solo license

$79.00

Solo license · one-time payment · tax included

Doing client work? That needs a Team license.

Need Team or Agency licensing?Want every template? Get All-Access - $399

One-time purchase · Instant delivery via email

7-day refund, no questions asked. See our refund policy

Need custom changes?

Brand colors, new pages, integrations - we build it for you.

Request Customization

We'll get back to you within 24 hours

Built for AI coding agents

Ships with CLAUDE.md, AGENTS.md, and .cursorrules, so Claude Code, Cursor, and Codex understand this codebase from the first prompt.

See the prompt cookbook

Audited to WCAG 2.2 AA

52/52 checks passing with axe-core, contrast measured from the rendered page, and a keyboard pass across 11 page types, light and dark, phone and desktop, plus both menus and an open citation.

The same check ships with the template, so you can re-run it after you change anything: npm run test:a11y.

See what the audit fixed

Tech Stack

Next.js16
React19
TailwindCSS v4
TypeScriptLatest

Every Plan Includes

Full source code
Commercial license
Documentation
Dark & light mode
Responsive design
Updates (plan-based)

Pricing

Choose your plan

One-time purchase. No subscriptions, no renewals.

Solo

1 developer

$79$150

per template, one-time payment · tax included

  • Full source code
  • 1 developer license
  • 1 end product
  • Own products only
  • 6 months of updates
  • Email support (48h)
Most Popular

Team

Up to 5 developers

$149$299

per template, one-time payment · tax included

  • Full source code
  • Up to 5 developers
  • Up to 5 end products
  • Client work permitted
  • 1 year of updates
  • Priority email support (24h)

Agency

Unlimited developers

$299$499

per template, one-time payment · tax included

  • Full source code
  • Unlimited developers
  • Unlimited end products
  • Client work permitted
  • Lifetime updates
  • Priority support
  • Dedicated onboarding call