Skip to content

moonshiftio/ai-chat

Repository files navigation

Nightowl

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.

What you get

  • Streaming chat UI: token-by-token rendering, typing indicator, auto-scroll, Enter to send and Shift+Enter for newlines.
  • Persistent conversations: conversations and messages tables via Drizzle, sidebar with history, new chat, and delete.
  • Provider key slot with graceful fallback: set OPENAI_API_KEY and 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.

Quickstart

bun install
bun dev

Open http://localhost:3000. That is the entire setup: database tables are created automatically on first request, and demo mode needs no keys.

Going live with OpenAI

cp .env.example .env
# paste your key into OPENAI_API_KEY, then restart
bun dev

Optionally set OPENAI_MODEL (defaults to gpt-4o-mini).

Where things live

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

Scripts

  • bun dev: start the dev server
  • bun run build: production build
  • bun run db:push: push schema with drizzle-kit (optional; the app self-bootstraps)

About

Moonshift template: ai-chat. Fork it or remix it at https://moonshift.io/templates/ai-chat

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages