OLH
Back to the overview
Open source · MIT

SupaChat. The AI chat starter for Next.js and Supabase.

A production-ready base for AI chat applications: authentication, document search, tools and cost tracking, wired together and set up with a single SQL file. It is built on the same architecture as Lovguiden, without the Danish legal data.

397
GitHub stars
60
forks
MIT
license
What is included
01

Authentication done properly

Supabase SSR auth with sign-up, sign-in, magic links and password reset. Row-level security on every table, column-level grants, and no keys in the browser.

02

Chat with documents

Uploaded PDFs are read with Mistral OCR, embedded with Voyage and searched with hybrid pgvector and full-text search, merged by reciprocal rank fusion.

03

Claude with tools

Eight tools the model calls on its own: document search, web search, memory, conversation search, visualisations, PDFs, artifacts and image generation.

04

Prompt caching

A two-tier Anthropic cache keeps multi-step tool turns at around a tenth of the normal input price.

05

Local models

An OpenAI-compatible vLLM provider runs open models on own hardware next to Claude.

06

Usage and cost

Token usage stored per step and rolled up into user and admin dashboards with cache-aware cost estimates.

From PDF to answer
  1. 01

    Upload

    PDF into a private Supabase bucket

  2. 02

    OCR

    Text and structure with Mistral OCR

  3. 03

    Embed

    Voyage embeddings into pgvector

  4. 04

    Search

    HNSW vector and full-text, fused with RRF

  5. 05

    Answer

    Claude answers and cites the pages

Set up in four steps
$ git clone https://github.com/ElectricCodeGuy/SupabaseAuthWithSSR
  1. 01Clone the repository.
  2. 02Run database/setup.sql in the Supabase SQL editor. It is idempotent and doubles as the upgrade path.
  3. 03Create a private storage bucket named userfiles.
  4. 04Add the API keys to .env.local and start the dev server.
SupaChat and Lovguiden

SupaChat was released in October 2023, a month before work on Lovguiden began, and the two share the same architecture. SupaChat is the open, general-purpose part: accounts, chat, tools and document search. Lovguiden adds the Danish legal database, the automated collection from 2,000+ public sources and the MCP server.

Read the Lovguiden case study
Contact

The same foundation, built on company data.

AI assistants over internal documents, contracts or case files, with sources on every answer, can be built on this base and run in the cloud or on own infrastructure.

oh@opkurser.dk