WIP - agentic chat application template built with TypeScript, Next.js, TailwindCSS, and Shadcn.
Find a file
Cole Medin 61e18a1d3f
Merge pull request #7 from coleam00/fix/issue-5
Add health check banner to chat interface
2026-03-24 08:09:07 -05:00
.agents/plans Initial AI chat application 2026-02-11 11:12:55 -06:00
.claude Initial AI chat application 2026-02-11 11:12:55 -06:00
.github/workflows fix: correct Coder template name to github-issues 2026-03-23 16:43:32 -05:00
drizzle/migrations Initial AI chat application 2026-02-11 11:12:55 -06:00
public Initial commit 2026-02-10 15:33:13 -06:00
src Add health check banner to chat interface 2026-03-24 13:03:42 +00:00
.env.example Initial AI chat application 2026-02-11 11:12:55 -06:00
.gitignore Initial commit 2026-02-10 15:33:13 -06:00
biome.json Initial AI chat application 2026-02-11 11:12:55 -06:00
bun.lock Initial AI chat application 2026-02-11 11:12:55 -06:00
bunfig.toml Initial commit 2026-02-10 15:33:13 -06:00
CLAUDE.md Initial commit 2026-02-10 15:33:13 -06:00
CODEBASE-GUIDE.md Initial commit 2026-02-10 15:33:13 -06:00
components.json Initial commit 2026-02-10 15:33:13 -06:00
drizzle.config.ts Initial AI chat application 2026-02-11 11:12:55 -06:00
Excal-6-AI-Optimized-Codebases.png Initial commit 2026-02-10 15:33:13 -06:00
happydom.ts Initial commit 2026-02-10 15:33:13 -06:00
next.config.ts Initial AI chat application 2026-02-11 11:12:55 -06:00
package.json Initial AI chat application 2026-02-11 11:12:55 -06:00
postcss.config.mjs Initial commit 2026-02-10 15:33:13 -06:00
README.md Add Contributing section to README 2026-03-23 22:24:33 +00:00
testing-library.ts Initial commit 2026-02-10 15:33:13 -06:00
tsconfig.json Initial commit 2026-02-10 15:33:13 -06:00

AI Chat

A real-time AI chat application built with Next.js, Supabase, and OpenRouter. Features streaming responses, conversation management, markdown rendering with syntax-highlighted code blocks, and a polished dark blue theme.

Features

  • Streaming AI responses via Server-Sent Events (SSE)
  • Conversation management — create, rename, delete with confirmation
  • Markdown rendering with syntax highlighting and copy-to-clipboard on code blocks
  • Dark/light theme with blue accent colors
  • Responsive mobile layout with collapsible sidebar
  • Persistent conversations stored in Supabase Postgres via Drizzle ORM
  • Toast notifications for error feedback
  • Keyboard shortcuts — Enter to send, Shift+Enter for new line

Stack

Layer Technology
Framework Next.js 16 (App Router)
Runtime Bun
UI React 19, Tailwind CSS 4, shadcn/ui
Database Supabase Postgres + Drizzle ORM
Auth Supabase Auth
AI OpenRouter (configurable model)
Linting Biome
Testing Bun test + React Testing Library
Logging Pino (structured JSON)

Quick Start

# Install dependencies
bun install

# Set up environment
cp .env.example .env
# Edit .env with your credentials (see Environment Variables below)

# Run database migrations
bun run db:migrate

# Start development server
bun run dev

Environment Variables

# OpenRouter (required for AI responses)
OPENROUTER_API_KEY=your-openrouter-api-key
OPENROUTER_MODEL=anthropic/claude-haiku-4.5    # or any OpenRouter model

# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

# Database (use transaction pooler port 6543 for serverless)
DATABASE_URL=postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres

Commands

bun run dev          # Start development server
bun run build        # Production build (includes type checking)
bun run lint         # Check for lint/format errors
bun run lint:fix     # Auto-fix lint/format issues
bun test             # Run tests with coverage
bun run db:migrate   # Run pending database migrations
bun run db:studio    # Open Drizzle Studio GUI

Architecture

src/
├── app/                    # Next.js App Router
│   ├── (auth)/            # Login & register pages
│   ├── (dashboard)/       # Protected chat interface
│   └── api/               # API routes (chat, health, projects)
│       └── chat/          # SSE streaming endpoint
├── core/                   # Shared infrastructure
│   ├── config/            # Environment validation (Zod)
│   ├── database/          # Drizzle client & schema
│   ├── logging/           # Pino structured logging
│   └── supabase/          # Server & client Supabase clients
├── features/              # Vertical slices (self-contained)
│   ├── auth/              # Auth actions & hooks
│   ├── chat/              # Conversations, messages, AI streaming
│   └── projects/          # Example CRUD feature
├── hooks/                 # React hooks (useChat, useAutoScroll)
├── shared/                # Cross-feature utilities
└── components/            # UI components
    ├── chat/              # Chat UI (layout, input, messages, sidebar)
    └── ui/                # shadcn/ui primitives

Features follow the vertical slice pattern — each feature owns its models, schemas, repository, service, errors, and tests:

src/features/chat/
├── models.ts      # Drizzle types
├── schemas.ts     # Zod validation
├── repository.ts  # Database queries
├── service.ts     # Business logic
├── stream.ts      # OpenRouter SSE streaming
├── errors.ts      # Custom error classes
├── index.ts       # Public API
└── tests/         # Feature tests

Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/my-change)
  3. Run bun install and bun test to verify
  4. Commit and open a PR

License

MIT