A streaming AI chat app for late-night builders. Dark-first, fast, and it works with zero API keys.
Built with Next.js, React, Drizzle ORM, and SQLite (libsql). Shipped as a Moonshift launch template.
- Streaming chat UI: token-by-token rendering, typing indicator, auto-scroll, Enter to send and Shift+Enter for newlines.
- Persistent conversations:
conversationsandmessagestables via Drizzle, sidebar with history, new chat, and delete. - Provider key slot with graceful fallback: set
OPENAI_API_KEYand replies stream live from OpenAI. Leave it empty and a built-in demo responder streams canned-but-charming replies, so the template demos perfectly with no setup. - Configurable system prompt: a settings drawer with presets, persisted per browser.
- Auth-ready: Better Auth login/signup pages are wired up but chat does not require an account.
bun install
bun devOpen http://localhost:3000. That is the entire setup: database tables are created automatically on first request, and demo mode needs no keys.
cp .env.example .env
# paste your key into OPENAI_API_KEY, then restart
bun devOptionally set OPENAI_MODEL (defaults to gpt-4o-mini).
| Path | Purpose |
|---|---|
app/chat/ |
The chat application |
app/api/chat/route.ts |
Streaming endpoint (OpenAI or demo responder) |
app/api/conversations/ |
Conversation list / history / delete |
lib/db/domain.ts |
Drizzle schema for conversations and messages |
lib/db/ensure.ts |
Idempotent table creation + welcome seed |
lib/chat/demo.ts |
The hand-written demo responder |
lib/chat/prompt.ts |
Default system prompt and presets |
bun dev: start the dev serverbun run build: production buildbun run db:push: push schema with drizzle-kit (optional; the app self-bootstraps)