Case Study
SupportAI — an AI support widget with an intelligence core
SupportAI answers product questions from a real FAQ knowledge base and hands off to a human when it does not know. The non-trivial part is the Core: a live 3D artifact that contracts when you send a message and emits when the answer arrives.
- Role
- Solo: design, engineering, documentation.
- Stack
- Next.js 15 · Supabase pgvector · Groq / Gemini · React Three Fiber · Vercel.
- Timeline
- Oct 2 to Oct 10, 2026.

The problem
A small SaaS does not need a chatbot that guesses. It needs something narrower: answer the questions the docs already cover, and the moment a question falls outside the docs, get a human involved with context attached.
Two hard problems hide inside that sentence. First, answers must come from real docs, not invention, which means retrieval has to find the right rows and the model has to trust the retrieved context and nothing else. Second, escalation has to be clean: something must decide per turn whether the answer counts, count consecutive failures without losing state, and hand off with the conversation attached.
The third problem is less obvious. Most AI products are invisible black boxes: you type, you get a reply, and the AI itself is never felt. I built the Core to fix that. It makes the intelligence visible by reacting to everything the system does.
How it works
The RAG pipeline
One request flows through eleven steps. Embeddings come from Gemini, generation defaults to Groq with a Gemini fallback, and every turn is persisted to Postgres before the stream closes.
The Core
The widget and the Core stay in sync through two DOM events. The artifact contracts on send and resolves into an emit on the first token, so what you see is always what the system just did.
// Chat widget → Core synchronization
dispatchEvent(new CustomEvent('supportai:core:think')) // on send
dispatchEvent(new CustomEvent('supportai:core:resolve')) // on first tokenTechnical decisions
Tool-call handoff, not a similarity threshold
I started with a threshold: anything below a cutoff means no answer. Then I measured. Junk queries scored 0.57 to 0.59, real matches 0.68 to 0.77. A gap of 0.04 to 0.09 is not a threshold, it is a coin flip. So I stopped thresholding and gave the model a reportNoAnswer tool to call instead of guessing. The handoff signal is now deterministic: the model either called the tool or it did not.
junk 0.57-0.59 vs real 0.68-0.77 // too thin to threshold
The Core is wired to real product events
The Core never runs a decorative loop. Sending a message dispatches a think event and the artifact contracts while the request is still in flight. The first streamed token dispatches resolve and the signal ring opens 200ms later. A failed request dispatches resolve with error: true and the ring tints red instead of cyan. First-time visitors get one autofire think at 3.5s, gated by sessionStorage so it fires once and never again.
think at send → resolve at first token → ring at +200ms
The fallback is the product, not the failure mode
Some devices have no WebGL, and forcing live 3D there produces stutter or a black screen. Those devices get a pre-rendered loop with the same framing and motion: 900 by 900, 8 seconds, 504KB. My first loop used a video element, which iOS Safari refuses to autoplay. I switched to animated WebP, which iOS treats as an image. The 3D scene is progressive enhancement. The fallback is the baseline.
<img src="/core-fallback-loop.webp"> // plays where <video> would not
4-tier quality ladder
I replaced a 3-tier model with ultra, high, medium, and low, resolved from GPU tier plus viewport width. Particle counts run 400, 300, 200, and 120 with 20, 15, 10, and 0 motion trails. DPR caps run 1.75, 1.5, and 1.25. Phones with strong GPUs moved from low to high, and weak desktop iGPUs get a boosted medium at 250 particles. Below 25fps for 2 seconds the tier drops one rung and never climbs back.
ultra 400/20 · high 300/15 · medium 200/10 · low 120/0
PostgREST silently nulls vector RPC args
The first version of the similarity search returned zero rows with no error. The cause: passing a JS number array to a vector-typed RPC argument, which PostgREST silently drops instead of coercing. The fix is a text argument with an internal cast, and the client sends the pgvector text format.
query_embedding: JSON.stringify(embedding) // "[0.02,-0.01,...]"
RLS default-deny reads as empty, not forbidden
Supabase enables row-level security by default, and an unauthorized read returns an empty table with no error. The FAQ table looked seeded and empty at the same time. One public read policy on faqs fixed it. The other three tables stay service_role-only by design.
faqs_public_read // SELECT for anon; nothing else
The Core, specifically
The Core exists because most AI products are invisible. You type a message, you get a reply, but the AI itself is a black box behind the curtain. The Core makes the intelligence visible: it reacts. It contracts when you send. It emits a signal when the answer arrives. It tints red when the chat fails. This is not animation for its own sake. It is a UI layer that reflects the system state.
I built it in React Three Fiber as a layered composition: a diffuse center, an inner neural icosahedron, three irregular orbital rings, a sparse particle field, and connection bands that only appear while thinking. Lighting comes from drei Environment presets, the middle layer is real transmission glass, and the ultra tier runs a full post stack of bloom, chromatic aberration, vignette, and noise, scaled down per tier.
Not every device can run WebGL, and forcing it produces 15fps stutter or a black screen. The right answer is a pre-rendered video loop for devices that cannot do live 3D. iOS Safari blocked autoplay on the video element, so I switched to animated WebP, which iOS treats as an image. The Core is now universal.


What I would do differently
- Retry does not re-trigger the Core. The chat Retry button starts a new request without dispatching think, so the artifact stays still while the retry streams. Small, known, not fixed.
- Autofire timing on cold load runs about 2 seconds late. Shader compile blocks the main thread, so the 3.5s target lands near 5.5s on slow hardware. Acceptable but visible.
- The idle-reduction state is subtle. After 45 seconds with no interaction, particle drift slows 40 percent. Most visitors will never notice. I would make the transition visible in v2.
Under the hood


- First Load JS
- 173 kB for / (measured from build)
- Commits
- 30 since the initial scaffold
- Codebase
- ~6,400 lines across 70 files (app, components, lib)
- Stack
- Next.js 15 App Router · Tailwind v4 · shadcn (Base-UI) · Vercel AI SDK · Supabase pgvector · React Three Fiber · postprocessing · Groq primary / Gemini fallback
- Cost
- Zero paid tools: Gemini, Groq, Supabase, Vercel, Resend, GitHub free tiers