Jason Tudisco 01258fa958 feat: complete GroupChat app with AI tool calling, search, fetch, and UI
Full-stack real-time group chat with Rust/Axum backend and Riot.js frontend.

Features:
- Auth (register/login/JWT), rooms, invites, WebSocket messaging
- AI responses via OpenRouter with tool calling (Brave Search + web fetch)
- Real-time tool usage indicators (searching/reading page)
- Collapsible tool results in message bubbles
- AI stats bar (model, tokens, speed, response time) persisted to DB
- Room soft-delete, /clear command, dynamic model fetching
- Markdown rendering with code highlighting and copy buttons

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 18:50:52 -06:00

53 lines
1.8 KiB
SQL

-- Users table
CREATE TABLE IF NOT EXISTS users (
id TEXT PRIMARY KEY NOT NULL,
email TEXT UNIQUE NOT NULL,
display_name TEXT NOT NULL,
password_hash TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- Rooms table with model_id for OpenRouter model selection
CREATE TABLE IF NOT EXISTS rooms (
id TEXT PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
model_id TEXT NOT NULL DEFAULT 'anthropic/claude-3.5-sonnet',
created_by TEXT NOT NULL REFERENCES users(id),
ai_always_respond INTEGER NOT NULL DEFAULT 0,
system_prompt TEXT NOT NULL DEFAULT 'You are a helpful AI assistant participating in a group chat. Be conversational, helpful, and concise. You can see messages from all participants. When mentioned, respond helpfully.',
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- Messages table
CREATE TABLE IF NOT EXISTS messages (
id TEXT PRIMARY KEY NOT NULL,
room_id TEXT NOT NULL REFERENCES rooms(id),
sender_id TEXT NOT NULL,
sender_name TEXT NOT NULL,
content TEXT NOT NULL,
mentions TEXT NOT NULL DEFAULT '[]',
is_ai INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE INDEX IF NOT EXISTS idx_messages_room_id ON messages(room_id, created_at);
-- Room members join table
CREATE TABLE IF NOT EXISTS room_members (
room_id TEXT NOT NULL REFERENCES rooms(id),
user_id TEXT NOT NULL REFERENCES users(id),
joined_at TEXT NOT NULL DEFAULT (datetime('now')),
PRIMARY KEY (room_id, user_id)
);
-- Invites table
CREATE TABLE IF NOT EXISTS invites (
id TEXT PRIMARY KEY NOT NULL,
room_id TEXT NOT NULL REFERENCES rooms(id),
invited_by TEXT NOT NULL REFERENCES users(id),
email TEXT NOT NULL,
token TEXT UNIQUE NOT NULL,
used INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);