The AI chat starter for Next.js & Supabase
Production-grade authentication, Claude-powered chat with document RAG, an artifacts workspace, long-term memory, and per-token usage analytics — ready to clone and ship.
A complete AI tool suite, wired end to end
Every tool ships with its server definition, typed UI component, and persistence — the full pattern, not a demo stub.
Chat with your documents
Upload PDFs, OCR them with Mistral, and let the AI search them autonomously — hybrid vector + keyword retrieval with page-level citations.
Artifacts workspace
Documents draft live in a side panel with streaming text, full version history, and one-click export — the canvas pattern, built in.
Long-term memory
Ask the assistant to remember things and it persists across every conversation — with a settings surface to review, edit, and delete what it knows.
Interactive charts
The AI renders bar, line, area, and pie charts from real conversation data with a colorblind-safe palette and a data-table fallback.
PDF generation
One-shot polished PDFs — style templates, cover pages, tables of contents, callouts — saved straight to the user’s file library.
Web search built in
Exa-powered search with relevance-ranked highlights, inline source citations, and links that open where they should: in a new tab.
And everything around the conversation
The parts a demo usually skips: picking a model with its price in view, memory you can audit, and chats you can find again.
Pick a model with the price in view
- Sonnet 5~$0.45/answer
- Opus 4.8~$1.25/answer
- Fable 5~$2.50/answer
- Saved to this conversation — switch any time
The catalog lives in the database with real pricing, so the picker can show an estimated cost per answer. Your pick is stored on the conversation — each chat keeps its own.
It remembers — and you can audit it
- Prefers TypeScript with strict mode enabled
- Works in CET — schedule summaries for 08:00
- Company benchmark target: churn under 3%
- Add a memory yourself
The assistant saves memories through a tool call, and every one of them is listed in AI settings to edit or delete. They ride along in the system prompt of every new chat.
Search, favorite, rename, share
Q3 report review
Today · 14 messages
Onboarding email rewrite
Yesterday
pgvector index tuning
Mon
Chats title themselves after the first exchange. Search runs across every past conversation — from the conversations screen, or as a tool the assistant can call mid-answer.
Usage analytics
Every token accounted for
Each generation step — including every individual tool call — stores its token and cache metadata with the message it belongs to. Dashboards turn that into answers.
- Per-user dashboard: tokens per day, cache hit rate, cost by model, usage by tool, per-message drill-down
- Admin view: org-wide totals, top users by cost, and user management with role control
- Cache-aware cost estimates using real Anthropic pricing multipliers (0.1× reads, 1.25× writes)
Tokens (30d)
1.2M
Cache hit rate
87%
Est. cost
$4.21
Input · Output tokens per day — every step attributed to its tool
Production architecture
Secure and fast by default
Supabase SSR authentication with row-level security on every table, and a two-tier Anthropic prompt-caching setup that serves multi-step tool turns from cache at ~10% of the input price.
- Cookie-based SSR auth — sessions verified on the server, RLS enforced in the database
- Cached static system prompt + a moving breakpoint that follows the conversation across tool steps
- One SQL file sets up the entire schema, policies, and hybrid search function
- Row Level Securityevery table, every query
- Prompt cachingstatic prefix + moving breakpoint
- Incremental saveseach step persisted as it streams
- Server-only keysnothing sensitive reaches the client
Clone it. Run one SQL file. Ship.
The whole stack — auth, chat, tools, dashboards — is a git clone and a Supabase project away.
git clone https://github.com/ElectricCodeGuy/SupabaseAuthWithSSR.git