A clean, fast chat dashboard with expert personas, authenticated personal workspaces, streaming replies, attachments, and readable code blocks.
Built with Next.js (App Router) + Vercel AI SDK + Supabase.
- Expert personas: switch between different “experts” with their own system prompts.
- Supabase Auth: sign up, sign in, sign out, and change password flows are built in.
- Multi-session chat: sessions list + titles + last-message preview.
- User-isolated chat history: sessions and messages are scoped to the authenticated user.
- Streaming responses: responsive UI while the model streams tokens.
- Attachments: upload images/files to Supabase Storage and send them with messages.
- Markdown + code blocks: readable rendering with syntax highlighting.
Create .env.local:
cp .env.local.example .env.localRequired:
OPENAI_API_KEY– your OpenAI API keyOPENAI_MODEL– e.g.gpt-5-mini(model is not hardcoded in code)
Optional chat context compaction:
OPENAI_CONVERSATION_SUMMARY_MODEL– model used for session title and context summary generation; falls back toOPENAI_MODELBOTCHAT_COMPACT_AFTER_TOTAL_TOKENS– actual unsummarized chat token threshold before persisting a rolling session summary; defaults to1000BOTCHAT_COMPACT_AFTER_USER_MESSAGE_COUNT– user-message count threshold before runtime context compaction; defaults to4
Supabase (recommended for sessions/experts/attachments):
PUBLIC_SUPABASE_URLPUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY
Supabase admin (required for expert deletion to remove all linked sessions/messages):
SUPABASE_SERVICE_ROLE_KEY(server-only secret; never expose to browser/client code)
bun install
bun devOpen http://localhost:3000.
Authentication UI is available at http://localhost:3000/auth.
- Create a Supabase project.
- Run
supabase/schema.sqlin the Supabase SQL Editor. - Enable Supabase Auth email/password sign-in for the project.
- If email confirmation is enabled, new users must activate their account from email before signing in.
- Create a public Storage bucket named
chat-attachments.
The database schema now assumes authenticated access:
chat_sessions.user_idowns each chat session.chat_messagesinherit ownership throughsession_id.- Row Level Security allows users to read/write only their own sessions and messages.
expertsremain global/shared and are not user-owned.
This repo includes a production Docker build for the Next.js app:
docker compose up -d --buildApp is exposed at http://localhost:3202 (mapped from container 3000).
Tip: for Docker envs, set OPENAI_API_KEY, OPENAI_MODEL, OPENAI_CONVERSATION_SUMMARY_MODEL, BOTCHAT_COMPACT_AFTER_TOTAL_TOKENS, BOTCHAT_COMPACT_AFTER_USER_MESSAGE_COUNT, PUBLIC_SUPABASE_URL, PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY, and SUPABASE_SERVICE_ROLE_KEY in your deployment platform or docker-compose.yml.
app/– Next.js routes (UI + API routes)components/botchat/– chat UI (sessions, experts, input, panels)components/ai-elements/– AI-friendly UI primitives (rendering, message building blocks)lib/– shared utilities + Supabase clientssupabase/schema.sql– database schema + RLS policies
bun dev # local dev
bun run build # production build
bun start # run production server on :3000